Author: scabanovich
Date: 2009-12-04 12:26:03 -0500 (Fri, 04 Dec 2009)
New Revision: 19062
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/
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/AnnotationHelper.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/TypeDefinition.java
Removed:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotatedTypeDeclaration.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/scanner/CDIBuilderDelegate.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4943
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java 2009-12-04
17:26:03 UTC (rev 19062)
@@ -0,0 +1,38 @@
+package org.jboss.tools.cdi.core;
+
+public interface CDIConstants {
+ public String INHERITED_ANNOTATION_TYPE_NAME =
"java.lang.annotation.Inherited";
+ public String TARGET_ANNOTATION_TYPE_NAME = "java.lang.annotation.Target";
+ public String RETENTION_ANNOTATION_TYPE_NAME =
"java.lang.annotation.Retention";
+
+ public String QUALIFIER_ANNOTATION_TYPE_NAME = "javax.inject.Qualifier";
+
+ public String NAMED_QUALIFIER_TYPE_NAME = "javax.inject.Named";
+ public String ANY_QUALIFIER_TYPE_NAME = "javax.enterprise.inject.Any";
+ public String DEFAULT_QUALIFIER_TYPE_NAME =
"javax.enterprise.inject.Default";
+ public String NEW_QUALIFIER_TYPE_NAME = "javax.enterprise.inject.New";
+
+ public String STEREOTYPE_ANNOTATION_TYPE_NAME =
"javax.enterprise.inject.Stereotype";
+ public String MODEL_STEREOTYPE_TYPE_NAME = "javax.enterprise.inject.Model";
+ public String DECORATOR_STEREOTYPE_TYPE_NAME = "javax.decorator.Decorator";
+
+ public String TYPED_ANNOTATION_TYPE_NAME = "javax.enterprise.inject.Typed";
+
+ public String PRODUCES_ANNOTATION_TYPE_NAME =
"javax.enterprise.inject.Produces";
+
+ public String SCOPE_ANNOTATION_TYPE_NAME = "javax.inject.Scope";
+
+ public String PROVIDER_ANNOTATION_TYPE_NAME = "javax.inject.Provider";
+
+ public String INJECT_ANNOTATION_TYPE_NAME = "javax.inject.Inject";
+
+ public String ALTERNATIVE_ANNOTATION_TYPE_NAME =
"javax.enterprise.inject.Alternative";
+
+ public String INTERCEPTOR_BINDING_ANNOTATION_TYPE_NAME =
"javax.interceptor.InterceptorBinding";
+
+ public String APPLICATION_SCOPED_ANNOTATION_TYPE_NAME =
"javax.enterprise.context.ApplicationScoped";
+ public String CONVERSATION_SCOPED_ANNOTATION_TYPE_NAME =
"javax.enterprise.context.ConversationScoped";
+ public String REQUEST_SCOPED_ANNOTATION_TYPE_NAME =
"javax.enterprise.context.RequestScoped";
+ public String SESSION_SCOPED_ANNOTATION_TYPE_NAME =
"javax.enterprise.context.SessionScoped";
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotatedTypeDeclaration.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotatedTypeDeclaration.java 2009-12-04
16:58:34 UTC (rev 19061)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotatedTypeDeclaration.java 2009-12-04
17:26:03 UTC (rev 19062)
@@ -1,37 +0,0 @@
-package org.jboss.tools.cdi.internal.core.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jdt.core.IType;
-import org.jboss.tools.cdi.core.CDICorePlugin;
-
-public class AnnotatedTypeDeclaration {
- List<AnnotationDeclaration> annotations = new
ArrayList<AnnotationDeclaration>();
- String qualifiedName;
- IType type;
-
- public AnnotatedTypeDeclaration() {
- }
-
- public void setType(IType type) {
- this.type = type;
- try {
- init();
- } catch (CoreException e) {
- CDICorePlugin.getDefault().logError(e);
- }
- }
-
- void init() throws CoreException {
- qualifiedName = type.getFullyQualifiedName();
- IAnnotation[] ts = type.getAnnotations();
- for (int i = 0; i < annotations.size(); i++) {
- AnnotationDeclaration a = new AnnotationDeclaration();
- a.setDeclaration(ts[i], type);
- annotations.add(a);
- }
- }
-}
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 2009-12-04
16:58:34 UTC (rev 19061)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java 2009-12-04
17:26:03 UTC (rev 19062)
@@ -8,13 +8,13 @@
import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.common.model.util.EclipseJavaUtil;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
public class AnnotationDeclaration implements IAnnotationDeclaration {
IAnnotation annotation;
int startPosition = -1;
int length = 0;
String annotationTypeName = null;
+ IType type = null;
public AnnotationDeclaration() {}
@@ -26,11 +26,12 @@
startPosition = range.getOffset();
length = range.getLength();
}
+ String name = annotation.getElementName();
+ annotationTypeName = EclipseJavaUtil.resolveType(declaringType, name);
+ type = EclipseJavaUtil.findType(declaringType.getJavaProject(), annotationTypeName);
} catch (JavaModelException e) {
CDICorePlugin.getDefault().logError(e);
}
- String name = annotation.getElementName();
- annotationTypeName = EclipseJavaUtil.resolveType(declaringType, name);
}
public IAnnotation getDeclaration() {
@@ -41,8 +42,12 @@
return (IMember)annotation.getParent();
}
+ public String getTypeName() {
+ return annotationTypeName;
+ }
+
public IType getType() {
- return getParentMember().getDeclaringType();
+ return type;
}
public int getLength() {
Added:
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
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractMemberDefinition.java 2009-12-04
17:26:03 UTC (rev 19062)
@@ -0,0 +1,37 @@
+package org.jboss.tools.cdi.internal.core.impl.definition;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IAnnotatable;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.IType;
+import org.jboss.tools.cdi.core.CDICorePlugin;
+import org.jboss.tools.cdi.internal.core.impl.AnnotationDeclaration;
+
+public abstract class AbstractMemberDefinition {
+ protected List<AnnotationDeclaration> annotations = new
ArrayList<AnnotationDeclaration>();
+ protected IAnnotatable member;
+
+ public AbstractMemberDefinition() {}
+
+ protected void setAnnotatable(IAnnotatable member, IType contextType, DefinitionContext
context) {
+ this.member = member;
+ try {
+ init(contextType, context);
+ } catch (CoreException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
+ }
+
+ protected void init(IType contextType, DefinitionContext context) throws CoreException
{
+ IAnnotation[] ts = member.getAnnotations();
+ for (int i = 0; i < annotations.size(); i++) {
+ AnnotationDeclaration a = new AnnotationDeclaration();
+ a.setDeclaration(ts[i], contextType);
+ annotations.add(a);
+ }
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractMemberDefinition.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractTypeDefinition.java 2009-12-04
17:26:03 UTC (rev 19062)
@@ -0,0 +1,31 @@
+package org.jboss.tools.cdi.internal.core.impl.definition;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IType;
+
+public class AbstractTypeDefinition extends AbstractMemberDefinition {
+ protected String qualifiedName;
+ IType type;
+
+ public AbstractTypeDefinition() {}
+
+ public String getQualifiedName() {
+ return qualifiedName;
+ }
+
+ public IType getType() {
+ return type;
+ }
+
+ public void setType(IType type, DefinitionContext context) {
+ super.setAnnotatable(type, type,context);
+ }
+
+ @Override
+ protected void init(IType contextType, DefinitionContext context) throws CoreException
{
+ this.type = contextType;
+ super.init(contextType, context);
+ qualifiedName = getType().getFullyQualifiedName();
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractTypeDefinition.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AnnotationDefinition.java 2009-12-04
17:26:03 UTC (rev 19062)
@@ -0,0 +1,59 @@
+package org.jboss.tools.cdi.internal.core.impl.definition;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IType;
+import org.jboss.tools.cdi.core.CDIConstants;
+import org.jboss.tools.cdi.internal.core.impl.AnnotationDeclaration;
+
+public class AnnotationDefinition extends AbstractTypeDefinition {
+ public static final int NON_RELEVANT = 0;
+ public static final int BASIC = 1; //has Inherited, Target, Retention
+ public static final int CDI = 2; //has Model, Named, Typed, *Scoped, New
+ public static final int QUALIFIER = 3; //has Qualifier
+ public static final int STEREOTYPE = 4; //has Stereotype
+ public static final int INTERCEPTOR_BINDING = 5; //has InterceptorBinding
+ //TODO add other definition kinds of interest
+
+ protected int kind = NON_RELEVANT;
+
+ public AnnotationDefinition() {}
+
+ public void setKind(int kind) {
+ this.kind = kind;
+ }
+
+ public int getKind() {
+ return kind;
+ }
+
+ @Override
+ protected void init(IType contextType, DefinitionContext context) throws CoreException
{
+ super.init(contextType, context);
+ if(annotations.isEmpty()) {
+ //TODO check super ?
+ return;
+ }
+ Map<String, AnnotationDeclaration> ds = new HashMap<String,
AnnotationDeclaration>();
+
+ for (AnnotationDeclaration a: annotations) {
+ String typeName = a.getTypeName();
+ ds.put(typeName, a);
+ }
+
+ if(ds.containsKey(CDIConstants.STEREOTYPE_ANNOTATION_TYPE_NAME)) {
+ kind = STEREOTYPE;
+ } else if(ds.containsKey(CDIConstants.QUALIFIER_ANNOTATION_TYPE_NAME)) {
+ kind = QUALIFIER;
+ } else if(ds.containsKey(CDIConstants.INTERCEPTOR_BINDING_ANNOTATION_TYPE_NAME)) {
+ kind = INTERCEPTOR_BINDING;
+ } else if(AnnotationHelper.BASIC_ANNOTATION_TYPES.contains(qualifiedName)) {
+ kind = AnnotationDefinition.BASIC;
+ } else if(AnnotationHelper.CDI_ANNOTATION_TYPES.contains(qualifiedName)) {
+ kind = AnnotationDefinition.CDI;
+ }
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AnnotationDefinition.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AnnotationHelper.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AnnotationHelper.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AnnotationHelper.java 2009-12-04
17:26:03 UTC (rev 19062)
@@ -0,0 +1,41 @@
+package org.jboss.tools.cdi.internal.core.impl.definition;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.tools.cdi.core.CDIConstants;
+
+public class AnnotationHelper implements CDIConstants {
+ public static final Set<String> BASIC_ANNOTATION_TYPES = new
HashSet<String>();
+ public static final Set<String> CDI_ANNOTATION_TYPES = new
HashSet<String>();
+ public static final Set<String> SCOPE_ANNOTATION_TYPES = new
HashSet<String>();
+
+ {
+ BASIC_ANNOTATION_TYPES.add(INHERITED_ANNOTATION_TYPE_NAME);
+ BASIC_ANNOTATION_TYPES.add(TARGET_ANNOTATION_TYPE_NAME);
+ BASIC_ANNOTATION_TYPES.add(RETENTION_ANNOTATION_TYPE_NAME);
+
+ SCOPE_ANNOTATION_TYPES.add(APPLICATION_SCOPED_ANNOTATION_TYPE_NAME);
+ SCOPE_ANNOTATION_TYPES.add(CONVERSATION_SCOPED_ANNOTATION_TYPE_NAME);
+ SCOPE_ANNOTATION_TYPES.add(REQUEST_SCOPED_ANNOTATION_TYPE_NAME);
+ SCOPE_ANNOTATION_TYPES.add(SESSION_SCOPED_ANNOTATION_TYPE_NAME);
+
+ CDI_ANNOTATION_TYPES.add(QUALIFIER_ANNOTATION_TYPE_NAME);
+ CDI_ANNOTATION_TYPES.add(NAMED_QUALIFIER_TYPE_NAME);
+ CDI_ANNOTATION_TYPES.add(ANY_QUALIFIER_TYPE_NAME);
+ CDI_ANNOTATION_TYPES.add(DEFAULT_QUALIFIER_TYPE_NAME);
+ CDI_ANNOTATION_TYPES.add(NEW_QUALIFIER_TYPE_NAME);
+ CDI_ANNOTATION_TYPES.add(STEREOTYPE_ANNOTATION_TYPE_NAME);
+ CDI_ANNOTATION_TYPES.add(MODEL_STEREOTYPE_TYPE_NAME);
+ CDI_ANNOTATION_TYPES.add(DECORATOR_STEREOTYPE_TYPE_NAME);
+ CDI_ANNOTATION_TYPES.add(TYPED_ANNOTATION_TYPE_NAME);
+ CDI_ANNOTATION_TYPES.add(PRODUCES_ANNOTATION_TYPE_NAME);
+ CDI_ANNOTATION_TYPES.add(SCOPE_ANNOTATION_TYPE_NAME);
+ CDI_ANNOTATION_TYPES.add(PROVIDER_ANNOTATION_TYPE_NAME);
+ CDI_ANNOTATION_TYPES.add(INJECT_ANNOTATION_TYPE_NAME);
+ CDI_ANNOTATION_TYPES.add(ALTERNATIVE_ANNOTATION_TYPE_NAME);
+ CDI_ANNOTATION_TYPES.add(INTERCEPTOR_BINDING_ANNOTATION_TYPE_NAME);
+ CDI_ANNOTATION_TYPES.addAll(SCOPE_ANNOTATION_TYPES);
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AnnotationHelper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java 2009-12-04
17:26:03 UTC (rev 19062)
@@ -0,0 +1,90 @@
+package org.jboss.tools.cdi.internal.core.impl.definition;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.jboss.tools.cdi.core.CDICoreNature;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+
+public class DefinitionContext {
+ protected CDICoreNature project;
+ protected IJavaProject javaProject;
+
+ Set<IType> types = new HashSet<IType>();
+ Map<IPath, Set<IType>> resources = new HashMap<IPath,
Set<IType>>();
+ Map<IType, AbstractTypeDefinition> typeDefinitions = new HashMap<IType,
AbstractTypeDefinition>();
+ Map<IType, AnnotationDefinition> annotations = new HashMap<IType,
AnnotationDefinition>();
+
+ public DefinitionContext() {}
+
+ public void setProject(CDICoreNature project) {
+ this.project = project;
+ javaProject = EclipseResourceUtil.getJavaProject(project.getProject());
+ }
+
+ public CDICoreNature getProject() {
+ return project;
+ }
+
+ public void addType(IPath file, IType type, AbstractTypeDefinition def) {
+ if(file != null) {
+ Set<IType> ts = resources.get(file);
+ if(ts == null) {
+ ts = new HashSet<IType>();
+ resources.put(file, ts);
+ }
+ ts.add(type);
+ types.add(type);
+ }
+ if(def != null) {
+ typeDefinitions.put(type, def);
+ if(def instanceof AnnotationDefinition) {
+ annotations.put(type, (AnnotationDefinition)def);
+ }
+ }
+ }
+
+ public void clean(IPath path) {
+ Set<IType> ts = resources.remove(path);
+ if(ts == null) return;
+ for (IType t: ts) {
+ types.remove(t);
+ typeDefinitions.remove(t);
+ annotations.remove(t);
+ }
+ }
+
+ public int getAnnotationKind(IType annotationType) {
+ if(annotationType == null) return -1;
+ AnnotationDefinition d = annotations.get(annotationType);
+ if(d != null) {
+ return d.getKind();
+ }
+ //? use cache for basic?
+ if(types.contains(annotationType)) {
+ return AnnotationDefinition.NON_RELEVANT;
+ }
+ String name = annotationType.getFullyQualifiedName();
+ if(AnnotationHelper.BASIC_ANNOTATION_TYPES.contains(name)) {
+ return AnnotationDefinition.BASIC;
+ }
+ if(AnnotationHelper.CDI_ANNOTATION_TYPES.contains(name)) {
+ return AnnotationDefinition.CDI;
+ }
+
+ d = new AnnotationDefinition();
+ d.setType(annotationType, this);
+ int kind = d.getKind();
+ if(kind <= AnnotationDefinition.CDI) {
+ d = null;
+ }
+ addType(annotationType.getPath(), annotationType, d);
+ return kind;
+ }
+}
+
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/FieldDefinition.java 2009-12-04
17:26:03 UTC (rev 19062)
@@ -0,0 +1,19 @@
+package org.jboss.tools.cdi.internal.core.impl.definition;
+
+import org.eclipse.jdt.core.IField;
+
+public class FieldDefinition extends AbstractMemberDefinition {
+ IField field;
+
+ public FieldDefinition() {}
+
+ public void setField(IField field, DefinitionContext context) {
+ this.field = field;
+ setAnnotatable(field, field.getDeclaringType(), context);
+ }
+
+ public IField getField() {
+ return field;
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/FieldDefinition.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java 2009-12-04
17:26:03 UTC (rev 19062)
@@ -0,0 +1,19 @@
+package org.jboss.tools.cdi.internal.core.impl.definition;
+
+import org.eclipse.jdt.core.IMethod;
+
+public class MethodDefinition extends AbstractMemberDefinition {
+ IMethod method;
+
+ public MethodDefinition() {}
+
+ public void setMethod(IMethod method, DefinitionContext context) {
+ this.method = method;
+ setAnnotatable(method, method.getDeclaringType(), context);
+ }
+
+ public IMethod getMethod() {
+ return method;
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java
(from rev 19032,
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotatedTypeDeclaration.java)
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java 2009-12-04
17:26:03 UTC (rev 19062)
@@ -0,0 +1,42 @@
+package org.jboss.tools.cdi.internal.core.impl.definition;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.jboss.tools.cdi.internal.core.impl.AnnotationDeclaration;
+
+public class TypeDefinition extends AbstractTypeDefinition {
+ List<FieldDefinition> fields = new ArrayList<FieldDefinition>();
+ List<MethodDefinition> methods = new ArrayList<MethodDefinition>();
+
+ public TypeDefinition() {
+ }
+
+ @Override
+ protected void init(IType contextType, DefinitionContext context) throws CoreException
{
+ super.init(contextType, context);
+ for (AnnotationDeclaration d: annotations) {
+ int kind = context.getAnnotationKind(d.getType());
+ //TODO do we need to create members for specific annotations?
+ }
+ IField[] fs = getType().getFields();
+ for (int i = 0; i < fs.length; i++) {
+ FieldDefinition f = new FieldDefinition();
+ f.setField(fs[i], context);
+ //TODO check if it is annotated
+ fields.add(f);
+ }
+ IMethod[] ms = getType().getMethods();
+ for (int i = 0; i < ms.length; i++) {
+ MethodDefinition m = new MethodDefinition();
+ m.setMethod(ms[i], context);
+ //TODO check if it is annotated
+ methods.add(m);
+ }
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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 2009-12-04
16:58:34 UTC (rev 19061)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/CDIBuilderDelegate.java 2009-12-04
17:26:03 UTC (rev 19062)
@@ -4,14 +4,17 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.ICompilationUnit;
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.ICDIBuilderDelegate;
import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.internal.core.impl.CDIProject;
+import org.jboss.tools.cdi.internal.core.impl.definition.DefinitionContext;
public class CDIBuilderDelegate implements ICDIBuilderDelegate {
@@ -29,9 +32,24 @@
}
public void build(FileSet fileSet, CDICoreNature projectNature) {
+ //TODO get context from projectNature
+ DefinitionContext context = new DefinitionContext();
+ context.setProject(projectNature);
Map<IFile, ICompilationUnit> as = fileSet.getAnnotations();
for (IFile f: as.keySet()) {
-
+ ICompilationUnit u = as.get(f);
+ IType[] ts = null;
+ try {
+ ts = u.getTypes();
+ if(ts != null) for (int i = 0; i < ts.length; i++) {
+ if(ts[i].isAnnotation()) {
+ //this builds annotation definition
+ context.getAnnotationKind(ts[i]);
+ }
+ }
+ } catch (CoreException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
}
Map<IFile, ICompilationUnit> is = fileSet.getInterfaces();