Author: scabanovich
Date: 2011-03-31 18:16:06 -0400 (Thu, 31 Mar 2011)
New Revision: 30196
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IJavaAnnotation.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationLiteral.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/JavaAnnotation.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractMemberDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParameterDefinition.java
Log:
JBIDE-3120
https://issues.jboss.org/browse/JBIDE-3120
Removed org.eclipse.jdt.core.IAnnotation from CDI interfaces.
IAnnotationDeclaration implementation should handle it or work without it when annotation
info is provided by non-java sources.
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IJavaAnnotation.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IJavaAnnotation.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IJavaAnnotation.java 2011-03-31
22:16:06 UTC (rev 30196)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.core;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMemberValuePair;
+import org.eclipse.jdt.core.IType;
+import org.jboss.tools.common.text.ITextSourceReference;
+
+/**
+ * Hides IAnnotation and allows to subtitute another implementation than wrapper for
IAnnotation.
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public interface IJavaAnnotation extends ITextSourceReference {
+
+ /**
+ * Returns resource that declares this annotation.
+ *
+ * @return resource that declares this annotation
+ */
+ public IResource getResource();
+
+ /**
+ * Returns fully qualified type name if resolved or element name otherwise.
+ *
+ * @return fully qualified type name if resolved or element name otherwise
+ */
+ public String getTypeName();
+
+ /**
+ * Returns annotation type.
+ *
+ * @return annotation type
+ */
+ public IType getType();
+ /**
+ * Returns Java element on which or for which this annotation was created.
+ *
+ * @return Java element on which or for which this annotation was created
+ */
+ public IMember getParentMember();
+
+ /**
+ * Returns member value pairs as IAnnotation does.
+ *
+ * @return member value pairs as IAnnotation does
+ */
+ public IMemberValuePair[] getMemberValuePairs();
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IJavaAnnotation.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java 2011-03-31
20:11:36 UTC (rev 30195)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java 2011-03-31
22:16:06 UTC (rev 30196)
@@ -14,14 +14,11 @@
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMemberValuePair;
-import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.cdi.core.CDICoreNature;
-import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.core.ICDIAnnotation;
-import org.jboss.tools.common.model.util.EclipseJavaUtil;
+import org.jboss.tools.cdi.core.IJavaAnnotation;
/**
*
@@ -30,104 +27,49 @@
*/
public class AnnotationDeclaration implements IAnnotationDeclaration {
protected CDICoreNature project;
- protected IAnnotation annotation;
- protected int startPosition = -1;
- protected int length = 0;
- protected String annotationTypeName = null;
- protected IType type = null;
+ protected IJavaAnnotation annotation;
public AnnotationDeclaration() {}
protected void copyTo(AnnotationDeclaration other) {
other.project = project;
other.annotation = annotation;
- other.startPosition = startPosition;
- other.length = length;
- other.annotationTypeName = annotationTypeName;
- other.type = type;
}
public void setProject(CDICoreNature project) {
this.project = project;
}
- public void setDeclaration(IAnnotation annotation, IType declaringType) {
+ public void setDeclaration(IJavaAnnotation annotation) {
this.annotation = annotation;
- try {
- ISourceRange range = annotation.getSourceRange();
- if(range != null) {
- startPosition = range.getOffset();
- length = range.getLength();
- }
- String name = annotation.getElementName();
- annotationTypeName = EclipseJavaUtil.resolveType(declaringType, name);
- type = EclipseJavaUtil.findType(annotation.getJavaProject(), annotationTypeName);
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
- }
}
-// public IAnnotation getDeclaration() {
-// return annotation;
-// }
-
public IResource getResource() {
- if(annotation != null) {
- return annotation.getResource();
- }
- //TODO
- return null;
+ return annotation.getResource();
}
public IMemberValuePair[] getMemberValuePairs() {
- if(annotation != null) {
- try {
- return annotation.getMemberValuePairs();
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
- }
- }
- //
- return new IMemberValuePair[0];
+ return annotation.getMemberValuePairs();
}
-
public IMember getParentMember() {
- return (IMember)annotation.getParent();
+ return annotation.getParentMember();
}
public String getTypeName() {
- return annotationTypeName;
+ return annotation.getTypeName();
}
public IType getType() {
- return type;
+ return annotation.getType();
}
public int getLength() {
- //while annotation is available, it can be updated, we should take actual value.
- if(annotation != null) try {
- ISourceRange range = annotation.getSourceRange();
- if(range != null) {
- return length = range.getLength();
- }
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
- }
- return length;
+ return annotation.getLength();
}
public int getStartPosition() {
- //while annotation is available, it can be updated, we should take actual value.
- if(annotation != null) try {
- ISourceRange range = annotation.getSourceRange();
- if(range != null) {
- return startPosition = range.getOffset();
- }
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
- }
- return startPosition;
+ return annotation.getStartPosition();
}
/*
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationLiteral.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationLiteral.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationLiteral.java 2011-03-31
22:16:06 UTC (rev 30196)
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.internal.core.impl;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMemberValuePair;
+import org.eclipse.jdt.core.ISourceRange;
+import org.eclipse.jdt.core.IType;
+import org.jboss.tools.cdi.core.IJavaAnnotation;
+
+public class AnnotationLiteral implements IJavaAnnotation {
+ IResource declaringResource;
+ IType annotationType;
+
+ String source;
+ ISourceRange range;
+ IMemberValuePair[] memberValues = new IMemberValuePair[0];
+
+ public AnnotationLiteral(IResource declaringResource, String source, ISourceRange range,
IMemberValuePair[] memberValues, IType annotationType) {
+ this.declaringResource = declaringResource;
+ this.source = source;
+ this.range = range;
+ this.memberValues = memberValues;
+ this.annotationType = annotationType;
+ }
+
+ public int getStartPosition() {
+ return range == null ? -1 : range.getOffset();
+ }
+
+ public int getLength() {
+ return range == null ? -1 : range.getLength();
+ }
+
+ public IResource getResource() {
+ return declaringResource;
+ }
+
+ @Override
+ public String getTypeName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IType getType() {
+ return annotationType;
+ }
+
+ public IMember getParentMember() {
+ //Do we need it?
+ return null;
+ }
+
+ public IMemberValuePair[] getMemberValuePairs() {
+ return memberValues;
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationLiteral.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/JavaAnnotation.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/JavaAnnotation.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/JavaAnnotation.java 2011-03-31
22:16:06 UTC (rev 30196)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.internal.core.impl;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMemberValuePair;
+import org.eclipse.jdt.core.ISourceRange;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.jboss.tools.cdi.core.CDICorePlugin;
+import org.jboss.tools.cdi.core.IJavaAnnotation;
+import org.jboss.tools.common.model.util.EclipseJavaUtil;
+
+public class JavaAnnotation implements IJavaAnnotation {
+ IAnnotation annotation;
+ protected int startPosition = -1;
+ protected int length = 0;
+
+ String annotationTypeName;
+ IType type;
+
+ public JavaAnnotation(IAnnotation annotation, IType declaringType) {
+ this.annotation = annotation;
+ try {
+ String name = annotation.getElementName();
+ annotationTypeName = EclipseJavaUtil.resolveType(declaringType, name);
+ type = EclipseJavaUtil.findType(annotation.getJavaProject(), annotationTypeName);
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
+ }
+
+ public IResource getResource() {
+ return annotation.getResource();
+ }
+
+ public String getTypeName() {
+ return annotationTypeName;
+ }
+
+ public IType getType() {
+ return type;
+ }
+
+ public int getLength() {
+ try {
+ ISourceRange range = annotation.getSourceRange();
+ if(range != null) {
+ return length = range.getLength();
+ }
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
+ return length;
+ }
+
+ public int getStartPosition() {
+ try {
+ ISourceRange range = annotation.getSourceRange();
+ if(range != null) {
+ return startPosition = range.getOffset();
+ }
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
+ return startPosition;
+ }
+
+ public IMember getParentMember() {
+ return (IMember)annotation.getParent();
+ }
+
+ public IMemberValuePair[] getMemberValuePairs() {
+ try {
+ return annotation.getMemberValuePairs();
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
+ return new IMemberValuePair[0];
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/JavaAnnotation.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractMemberDefinition.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractMemberDefinition.java 2011-03-31
20:11:36 UTC (rev 30195)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractMemberDefinition.java 2011-03-31
22:16:06 UTC (rev 30196)
@@ -28,6 +28,7 @@
import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.internal.core.impl.AnnotationDeclaration;
import org.jboss.tools.cdi.internal.core.impl.InterceptorBindingDeclaration;
+import org.jboss.tools.cdi.internal.core.impl.JavaAnnotation;
import org.jboss.tools.cdi.internal.core.impl.QualifierDeclaration;
import org.jboss.tools.cdi.internal.core.impl.ScopeDeclaration;
import org.jboss.tools.cdi.internal.core.impl.StereotypeDeclaration;
@@ -81,7 +82,7 @@
for (int i = 0; i < ts.length; i++) {
AnnotationDeclaration a = new AnnotationDeclaration();
a.setProject(context.getProject());
- a.setDeclaration(ts[i], contextType);
+ a.setDeclaration(new JavaAnnotation(ts[i], contextType));
AnnotationDeclaration b = null;
int kind = context.getAnnotationKind(a.getType());
if(kind > 0 && (kind & AnnotationDefinition.STEREOTYPE) > 0) {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParameterDefinition.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParameterDefinition.java 2011-03-31
20:11:36 UTC (rev 30195)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParameterDefinition.java 2011-03-31
22:16:06 UTC (rev 30196)
@@ -21,6 +21,7 @@
import org.jboss.tools.cdi.core.IAnnotated;
import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.internal.core.impl.AnnotationDeclaration;
+import org.jboss.tools.cdi.internal.core.impl.JavaAnnotation;
import org.jboss.tools.cdi.internal.core.impl.ParametedType;
import org.jboss.tools.common.text.ITextSourceReference;
@@ -61,7 +62,9 @@
}
// JDT doesn't have API for annotations for method params. So let's wrap
ITextSourceReference into IAnnotationDeclaration.
AnnotationDeclaration ad = new AnnotationDeclaration();
- ad.setDeclaration(null, methodDefinition.getMethod().getDeclaringType());
+ //TODO it should be annotation literal!
+ System.out.println("!!!!!!!!!!!!!Here we are!!!!!!!!");
+ ad.setDeclaration(new JavaAnnotation(null,
methodDefinition.getMethod().getDeclaringType()));
CDICoreNature nature =
CDICorePlugin.getCDI(methodDefinition.getResource().getProject(), false);
ad.setProject(nature);
return ad;