Author: scabanovich
Date: 2011-04-29 16:37:39 -0400 (Fri, 29 Apr 2011)
New Revision: 30980
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IAnnotationDeclaration.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/AbstractTypeDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AnnotationDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AnnotationMemberDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/FieldDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/PackageDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/CDIBuilderDelegate.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
Log:
JBIDE-3120
https://issues.jboss.org/browse/JBIDE-3120
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IAnnotationDeclaration.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IAnnotationDeclaration.java 2011-04-29
20:29:40 UTC (rev 30979)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IAnnotationDeclaration.java 2011-04-29
20:37:39 UTC (rev 30980)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.cdi.core;
+import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMemberValuePair;
@@ -66,4 +67,10 @@
* @return underlying Java annotation if it exists
*/
IAnnotation getJavaAnnotation();
+
+ /**
+ * Returns resource which contains this declaration
+ * @return
+ */
+ IResource getResource();
}
\ No newline at end of file
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-04-29
20:29:40 UTC (rev 30979)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractMemberDefinition.java 2011-04-29
20:37:39 UTC (rev 30980)
@@ -43,6 +43,9 @@
*
*/
public abstract class AbstractMemberDefinition implements IAnnotated {
+ public static int FLAG_NO_ANNOTATIONS = 1;
+ public static int FLAG_ALL_MEMBERS = 2;
+
CDICoreNature project;
protected List<IAnnotationDeclaration> annotations = new
ArrayList<IAnnotationDeclaration>();
protected IAnnotatable member;
@@ -51,10 +54,10 @@
public AbstractMemberDefinition() {}
- protected void setAnnotatable(IAnnotatable member, IType contextType,
IRootDefinitionContext context) {
+ protected void setAnnotatable(IAnnotatable member, IType contextType,
IRootDefinitionContext context, int flags) {
this.member = member;
try {
- init(contextType, context);
+ init(contextType, context, flags);
} catch (CoreException e) {
CDICorePlugin.getDefault().logError(e);
}
@@ -78,13 +81,15 @@
return project.getDefinitions().getPackageDefinition(packageName);
}
- protected void init(IType contextType, IRootDefinitionContext context) throws
CoreException {
+ protected void init(IType contextType, IRootDefinitionContext context, int flags) throws
CoreException {
project = context.getProject();
resource = ((IJavaElement)member).getResource();
- IAnnotation[] ts = member.getAnnotations();
- for (int i = 0; i < ts.length; i++) {
- IJavaAnnotation ja = new JavaAnnotation(ts[i], contextType);
- addAnnotation(ja, context);
+ if((flags & FLAG_NO_ANNOTATIONS) == 0) {
+ IAnnotation[] ts = member.getAnnotations();
+ for (int i = 0; i < ts.length; i++) {
+ IJavaAnnotation ja = new JavaAnnotation(ts[i], contextType);
+ addAnnotation(ja, context);
+ }
}
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractTypeDefinition.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractTypeDefinition.java 2011-04-29
20:29:40 UTC (rev 30979)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractTypeDefinition.java 2011-04-29
20:37:39 UTC (rev 30980)
@@ -65,14 +65,14 @@
return type;
}
- public void setType(IType type, IRootDefinitionContext context) {
- super.setAnnotatable(type, type, context);
+ public void setType(IType type, IRootDefinitionContext context, int flags) {
+ super.setAnnotatable(type, type, context, flags);
}
@Override
- protected void init(IType contextType, IRootDefinitionContext context) throws
CoreException {
+ protected void init(IType contextType, IRootDefinitionContext context, int flags) throws
CoreException {
this.type = contextType;
- super.init(contextType, context);
+ super.init(contextType, context, flags);
qualifiedName = getType().getFullyQualifiedName();
parametedType =
context.getProject().getDelegate().getNature().getTypeFactory().newParametedType(type);
if(type != null && !type.isBinary()) {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AnnotationDefinition.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AnnotationDefinition.java 2011-04-29
20:29:40 UTC (rev 30979)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AnnotationDefinition.java 2011-04-29
20:37:39 UTC (rev 30980)
@@ -72,8 +72,8 @@
}
@Override
- protected void init(IType contextType, IRootDefinitionContext context) throws
CoreException {
- super.init(contextType, context);
+ protected void init(IType contextType, IRootDefinitionContext context, int flags) throws
CoreException {
+ super.init(contextType, context, flags);
if(annotations.isEmpty()) {
//TODO check super ?
return;
@@ -139,7 +139,7 @@
for (int i = 0; i < ms.length; i++) {
AnnotationMemberDefinition m = new AnnotationMemberDefinition();
m.setAnnotationDefinition(this);
- m.setMethod(ms[i], context);
+ m.setMethod(ms[i], context, 0);
if(m.isCDIAnnotated()) {
methods.add(m);
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AnnotationMemberDefinition.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AnnotationMemberDefinition.java 2011-04-29
20:29:40 UTC (rev 30979)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AnnotationMemberDefinition.java 2011-04-29
20:37:39 UTC (rev 30980)
@@ -34,9 +34,9 @@
return annotationDefinition;
}
- public void setMethod(IMethod method, IRootDefinitionContext context) {
+ public void setMethod(IMethod method, IRootDefinitionContext context, int flags) {
this.method = method;
- setAnnotatable(method, method.getDeclaringType(), context);
+ setAnnotatable(method, method.getDeclaringType(), context, flags);
}
public IMethod getMethod() {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java 2011-04-29
20:29:40 UTC (rev 30979)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java 2011-04-29
20:37:39 UTC (rev 30980)
@@ -303,7 +303,7 @@
private int createAnnotation(IType annotationType, String name) {
underConstruction.add(name);
AnnotationDefinition d = new AnnotationDefinition();
- d.setType(annotationType, this);
+ d.setType(annotationType, this, 0);
int kind = d.getKind();
if(kind <= AnnotationDefinition.CDI) {
// d = null; //We need it to compare kind if extensions change it.
@@ -447,6 +447,17 @@
d.annotationKindChanged(typeName, this);
}
}
+
+ public void veto(IType type) {
+ TypeDefinition d = typeDefinitions.get(type.getFullyQualifiedName());
+ if(d != null) d.veto();
+
+ }
+ public void unveto(IType type) {
+ TypeDefinition d = typeDefinitions.get(type.getFullyQualifiedName());
+ if(d != null) d.unveto();
+ }
+
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/FieldDefinition.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/FieldDefinition.java 2011-04-29
20:29:40 UTC (rev 30979)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/FieldDefinition.java 2011-04-29
20:37:39 UTC (rev 30980)
@@ -25,9 +25,9 @@
public FieldDefinition() {}
- public void setField(IField field, IRootDefinitionContext context) {
+ public void setField(IField field, IRootDefinitionContext context, int flags) {
this.field = field;
- setAnnotatable(field, field.getDeclaringType(), context);
+ setAnnotatable(field, field.getDeclaringType(), context, flags);
}
public IField getField() {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java 2011-04-29
20:29:40 UTC (rev 30979)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java 2011-04-29
20:37:39 UTC (rev 30980)
@@ -46,9 +46,9 @@
public MethodDefinition() {}
- public void setMethod(IMethod method, IRootDefinitionContext context) {
+ public void setMethod(IMethod method, IRootDefinitionContext context, int flags) {
this.method = method;
- setAnnotatable(method, method.getDeclaringType(), context);
+ setAnnotatable(method, method.getDeclaringType(), context, flags);
}
public IMethod getMethod() {
@@ -59,8 +59,9 @@
return isConstructor;
}
- protected void init(IType contextType, IRootDefinitionContext context) throws
CoreException {
- super.init(contextType, context);
+ @Override
+ protected void init(IType contextType, IRootDefinitionContext context, int flags) throws
CoreException {
+ super.init(contextType, context, flags);
isConstructor = method.isConstructor();
//TODO process parameters for disposers and observers
loadParamDefinitions(contextType, context);
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/PackageDefinition.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/PackageDefinition.java 2011-04-29
20:29:40 UTC (rev 30979)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/PackageDefinition.java 2011-04-29
20:37:39 UTC (rev 30980)
@@ -35,7 +35,7 @@
public void setBinaryType(IType pkg, IRootDefinitionContext context) {
binaryType = pkg;
- setAnnotatable(pkg, pkg, context);
+ setAnnotatable(pkg, pkg, context, 0);
qualifiedName = pkg.getPackageFragment().getElementName();
}
@@ -51,7 +51,7 @@
}
}
- super.setAnnotatable(pkg, contextType, context);
+ super.setAnnotatable(pkg, contextType, context, 0);
if (u != null) {
try {
u.discardWorkingCopy();
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java 2011-04-29
20:29:40 UTC (rev 30979)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java 2011-04-29
20:37:39 UTC (rev 30980)
@@ -41,8 +41,9 @@
}
@Override
- protected void init(IType contextType, IRootDefinitionContext context) throws
CoreException {
- super.init(contextType, context);
+ protected void init(IType contextType, IRootDefinitionContext context, int flags) throws
CoreException {
+ super.init(contextType, context, flags);
+ boolean allMembers = (flags & FLAG_ALL_MEMBERS) > 0;
isAbstract = Flags.isAbstract(type.getFlags());
for (IAnnotationDeclaration a: annotations) {
//provide initialization
@@ -53,11 +54,11 @@
for (int i = 0; i < fs.length; i++) {
FieldDefinition f = new FieldDefinition();
f.setTypeDefinition(this);
- f.setField(fs[i], context);
+ f.setField(fs[i], context, flags);
for (IProcessAnnotatedMemberFeature e: extensions) {
e.processAnnotatedMember(f, context);
}
- if(f.isCDIAnnotated()) {
+ if(allMembers || f.isCDIAnnotated()) {
fields.add(f);
}
}
@@ -66,11 +67,11 @@
for (int i = 0; i < ms.length; i++) {
MethodDefinition m = new MethodDefinition();
m.setTypeDefinition(this);
- m.setMethod(ms[i], context);
+ m.setMethod(ms[i], context, flags);
for (IProcessAnnotatedMemberFeature e: extensions) {
e.processAnnotatedMember(m, context);
}
- if(m.isCDIAnnotated() || (ms[i].isConstructor() &&
ms[i].getNumberOfParameters()==0)) {
+ if(allMembers || m.isCDIAnnotated() || (ms[i].isConstructor() &&
ms[i].getNumberOfParameters()==0)) {
methods.add(m);
}
if(ms[i].isConstructor()) {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/CDIBuilderDelegate.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/CDIBuilderDelegate.java 2011-04-29
20:29:40 UTC (rev 30979)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/CDIBuilderDelegate.java 2011-04-29
20:37:39 UTC (rev 30980)
@@ -64,7 +64,7 @@
Set<IType> ts = cs.get(f);
for (IType type: ts) {
TypeDefinition def = new TypeDefinition();
- def.setType(type, context);
+ def.setType(type, context, 0);
context.addType(f, type.getFullyQualifiedName(), def);
}
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2011-04-29
20:29:40 UTC (rev 30979)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2011-04-29
20:37:39 UTC (rev 30980)
@@ -1089,7 +1089,7 @@
*/
IAnnotationDeclaration inject =
producer.getAnnotation(CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
if (inject != null) {
- addError(CDIValidationMessages.PRODUCER_ANNOTATED_INJECT,
CDIPreferences.PRODUCER_ANNOTATED_INJECT, inject, producer.getResource());
+ addError(CDIValidationMessages.PRODUCER_ANNOTATED_INJECT,
CDIPreferences.PRODUCER_ANNOTATED_INJECT, inject, inject.getResource() != null ?
inject.getResource() : producer.getResource());
}
if (producer instanceof IProducerField) {