Author: scabanovich
Date: 2009-12-24 08:55:51 -0500 (Thu, 24 Dec 2009)
New Revision: 19570
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIAnnotation.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IScoped.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IStereotype.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/StereotypeElement.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/TypeDeclaration.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractMemberDefinition.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4943
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java 2009-12-24
08:46:20 UTC (rev 19569)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java 2009-12-24
13:55:51 UTC (rev 19570)
@@ -37,12 +37,15 @@
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IType;
+import org.jboss.tools.cdi.internal.core.impl.CDIAnnotationElement;
+import org.jboss.tools.cdi.internal.core.impl.definition.AnnotationHelper;
import org.jboss.tools.cdi.internal.core.scanner.CDIBuilderDelegate;
import org.jboss.tools.cdi.internal.core.scanner.FileSet;
import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.project.ProjectHome;
+import org.jboss.tools.common.model.util.EclipseJavaUtil;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
public class CDICoreBuilder extends IncrementalProjectBuilder {
@@ -217,9 +220,27 @@
XModelObject beansXML = newJars.get(jar);
fileSet.setBeanXML(path, beansXML);
}
+ addBasicTypes(fileSet);
builderDelegate.build(fileSet, getCDICoreNature());
}
+ void addBasicTypes(FileSet fs) throws CoreException {
+ IJavaProject jp = EclipseResourceUtil.getJavaProject(getProject());
+ if(jp == null) return;
+ for (String s: AnnotationHelper.SCOPE_ANNOTATION_TYPES) {
+ IType type = EclipseJavaUtil.findType(jp, s);
+ if(type != null) fs.add(type.getPath(), type);
+ }
+ for (String s: AnnotationHelper.QUALIFIER_ANNOTATION_TYPES) {
+ IType type = EclipseJavaUtil.findType(jp, s);
+ if(type != null) fs.add(type.getPath(), type);
+ }
+ for (String s: AnnotationHelper.STEREOTYPE_ANNOTATION_TYPES) {
+ IType type = EclipseJavaUtil.findType(jp, s);
+ if(type != null) fs.add(type.getPath(), type);
+ }
+ }
+
protected void clean(IProgressMonitor monitor) throws CoreException {
CDICoreNature n = getCDICoreNature();
if(n != null) n.clean();
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIAnnotation.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIAnnotation.java 2009-12-24
08:46:20 UTC (rev 19569)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIAnnotation.java 2009-12-24
13:55:51 UTC (rev 19570)
@@ -10,8 +10,19 @@
*/
public interface ICDIAnnotation extends ICDIElement {
+ /**
+ * Returns the corresponding IType of the annotation type.
+ *
+ * @return the corresponding IType
+ */
public IType getSourceType();
+ /**
+ * Returns the location of @Inherited declaration of this annotation type. If the bean
+ * doesn't have the @Inherited declaration then null will be returned.
+ *
+ * @return the location of @Name declaration of this bean.
+ */
public IAnnotationDeclaration getInheritedDeclaration();
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IScoped.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IScoped.java 2009-12-24
08:46:20 UTC (rev 19569)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IScoped.java 2009-12-24
13:55:51 UTC (rev 19570)
@@ -29,7 +29,7 @@
*
* @return the scope type
*/
- IType getScope();
+ IScope getScope();
/**
* Obtains all the scope declarations of the bean class or producer method
@@ -38,5 +38,5 @@
*
* @return the scope
*/
- Set<IAnnotationDeclaration> getScopeDeclarations();
+ Set<IScopeDeclaration> getScopeDeclarations();
}
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IStereotype.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IStereotype.java 2009-12-24
08:46:20 UTC (rev 19569)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IStereotype.java 2009-12-24
13:55:51 UTC (rev 19570)
@@ -20,16 +20,9 @@
*
* @author Alexey Kazakov
*/
-public interface IStereotype extends IScoped, ICDIElement {
+public interface IStereotype extends IScoped, ICDIAnnotation {
/**
- * Returns the corresponding IType of the stereotype.
- *
- * @return the corresponding IType
- */
- IType getSourceType();
-
- /**
* Returns the location of @Name declaration of this stereotype. If the bean
* doesn't have the @Name declaration then null will be returned.
*
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java 2009-12-24
08:46:20 UTC (rev 19569)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java 2009-12-24
13:55:51 UTC (rev 19570)
@@ -15,15 +15,20 @@
import java.util.Set;
import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMemberValuePair;
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.IScopeDeclaration;
import org.jboss.tools.cdi.core.IStereotypeDeclaration;
import org.jboss.tools.cdi.core.ITypeDeclaration;
import org.jboss.tools.cdi.internal.core.impl.definition.AbstractMemberDefinition;
import org.jboss.tools.cdi.internal.core.impl.definition.AnnotationDefinition;
+import org.jboss.tools.cdi.internal.core.impl.definition.ParametedTypeFactory;
import org.jboss.tools.common.model.util.EclipseJavaUtil;
/**
@@ -79,6 +84,21 @@
return result;
}
+ public Set<IScopeDeclaration> getScopeDeclarations() {
+ return getScopeDeclarations(getCDIProject().getNature(), definition.getAnnotations());
+ }
+
+ public static Set<IScopeDeclaration> getScopeDeclarations(CDICoreNature n,
List<? extends IAnnotationDeclaration> ds) {
+ Set<IScopeDeclaration> result = new HashSet<IScopeDeclaration>();
+ for (IAnnotationDeclaration d: ds) {
+ int k = n.getDefinitions().getAnnotationKind(d.getType());
+ if(k == AnnotationDefinition.SCOPE) {
+ result.add((IScopeDeclaration)d);
+ }
+ }
+ return result;
+ }
+
public Set<ITypeDeclaration> getRestrictedTypeDeclaratios() {
Set<ITypeDeclaration> result = new HashSet<ITypeDeclaration>();
AnnotationDeclaration typed = getDefinition().getTypedAnnotation();
@@ -92,16 +112,16 @@
Object[] os = (Object[])value;
for (int i = 0; i < os.length; i++) {
String typeName = os[i].toString();
- IType type =
EclipseJavaUtil.findType(getCDIProject().getNature().getDefinitions().getJavaProject(),
typeName);
- if(type != null) {
- result.add(new TypeDeclaration(type, -1, 0));
+ ParametedType p =
ParametedTypeFactory.getParametedType(((IMember)definition.getMember()).getDeclaringType(),
typeName);
+ if(p != null) {
+ result.add(new TypeDeclaration(p, -1, 0));
}
}
} else if(value != null) {
String typeName = value.toString();
- IType type =
EclipseJavaUtil.findType(getCDIProject().getNature().getDefinitions().getJavaProject(),
typeName);
- if(type != null) {
- result.add(new TypeDeclaration(type, -1, 0));
+ ParametedType p =
ParametedTypeFactory.getParametedType(((IMember)definition.getMember()).getDeclaringType(),
typeName);
+ if(p != null) {
+ result.add(new TypeDeclaration(p, -1, 0));
}
}
} catch (JavaModelException e) {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java 2009-12-24
08:46:20 UTC (rev 19569)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java 2009-12-24
13:55:51 UTC (rev 19570)
@@ -10,7 +10,9 @@
******************************************************************************/
package org.jboss.tools.cdi.internal.core.impl;
+import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
@@ -19,6 +21,7 @@
import org.jboss.tools.cdi.core.IClassBean;
import org.jboss.tools.cdi.core.ITypeDeclaration;
import org.jboss.tools.cdi.internal.core.impl.definition.BeanMemberDefinition;
+import org.jboss.tools.cdi.internal.core.impl.definition.ParametedTypeFactory;
import org.jboss.tools.common.model.util.EclipseJavaUtil;
/**
@@ -38,11 +41,12 @@
protected void setMember(IMember member) {
try {
- String returnType = EclipseJavaUtil.getMemberTypeAsString(member);
+ String returnType = member instanceof IField ? ((IField)member).getTypeSignature()
+ : member instanceof IMethod ? ((IMethod)member).getReturnType() : null;
if(returnType != null) {
- IType t = EclipseJavaUtil.findType(member.getJavaProject(), returnType);
- if(t != null) {
- typeDeclaration = new TypeDeclaration(t, -1, 0);
+ ParametedType p = ParametedTypeFactory.getParametedType(member.getDeclaringType(),
returnType);
+ if(p != null) {
+ typeDeclaration = new TypeDeclaration(p, -1, 0);
}
}
} catch (JavaModelException e) {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2009-12-24
08:46:20 UTC (rev 19569)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2009-12-24
13:55:51 UTC (rev 19570)
@@ -27,6 +27,7 @@
import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.cdi.core.CDIConstants;
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.IBean;
import org.jboss.tools.cdi.core.ICDIProject;
@@ -57,7 +58,7 @@
private Map<String, Set<IBean>> beansByName = new HashMap<String,
Set<IBean>>();
private Set<IBean> namedBeans = new HashSet<IBean>();
private Map<IType, ClassBean> classBeans = new HashMap<IType, ClassBean>();
-
+
BeansXMLData beansXMLData = new BeansXMLData();
public CDIProject() {}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2009-12-24
08:46:20 UTC (rev 19569)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2009-12-24
13:55:51 UTC (rev 19570)
@@ -22,7 +22,6 @@
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.cdi.core.IAnnotationDeclaration;
-import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.IBeanMethod;
import org.jboss.tools.cdi.core.IClassBean;
import org.jboss.tools.cdi.core.IInjectionPoint;
@@ -30,6 +29,8 @@
import org.jboss.tools.cdi.core.IObserverMethod;
import org.jboss.tools.cdi.core.IParametedType;
import org.jboss.tools.cdi.core.IProducer;
+import org.jboss.tools.cdi.core.IScope;
+import org.jboss.tools.cdi.core.IScopeDeclaration;
import org.jboss.tools.cdi.core.IStereotype;
import org.jboss.tools.cdi.core.IStereotypeDeclaration;
import org.jboss.tools.cdi.core.ITypeDeclaration;
@@ -51,6 +52,8 @@
protected List<BeanField> fields = new ArrayList<BeanField>();
protected List<BeanMethod> methods = new ArrayList<BeanMethod>();
+ protected IScope scope = null;
+
public ClassBean() {}
public void setDefinition(TypeDefinition definition) {
@@ -155,8 +158,12 @@
}
public Set<ITypeDeclaration> getAllTypeDeclarations() {
- // TODO Auto-generated method stub
- return null;
+ Set<IParametedType> ps = getDefinition().getInheritedTypes();
+ Set<ITypeDeclaration> result = new HashSet<ITypeDeclaration>();
+ for (IParametedType p: ps) {
+ result.add(new TypeDeclaration((ParametedType)p, -1, 0));
+ }
+ return result;
}
public IAnnotationDeclaration getAlternativeDeclaration() {
@@ -249,8 +256,8 @@
}
public boolean isDependent() {
- IType scope = getScope();
- return scope != null &&
CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME.equals(scope.getFullyQualifiedName());
+ IScope scope = getScope();
+ return scope != null &&
CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME.equals(scope.getSourceType().getFullyQualifiedName());
}
public boolean isEnabled() {
@@ -270,14 +277,67 @@
return getDefinition().getSpecializesAnnotation() != null;
}
- public IType getScope() {
- // TODO Auto-generated method stub
- return null;
+ public IScope getScope() {
+ if(scope == null) {
+ computeScope();
+ }
+ return scope;
}
- public Set<IAnnotationDeclaration> getScopeDeclarations() {
- // TODO Auto-generated method stub
- return null;
+ protected void computeScope() {
+ //1. Declaration of scope in the class.
+ Set<IScopeDeclaration> scopes = getScopeDeclarations();
+ if(!scopes.isEmpty()) {
+ scope = scopes.iterator().next().getScope();
+ return;
+ }
+ //2. Declaration of inheritable scope in a superclass.
+ ClassBean scb = getSuperClassBean();
+ while(scb != null) {
+ scopes = getScopeDeclarations();
+ if(!scopes.isEmpty()) {
+ scope = scopes.iterator().next().getScope();
+ if(scope.getInheritedDeclaration() == null) {
+ scope = null;
+ } else {
+ return;
+ }
+ }
+ scb = scb.getSuperClassBean();
+ }
+ //3. Get default scope from stereotype.
+ Set<IScope> defaults = new HashSet<IScope>();
+ Set<IStereotypeDeclaration> ss = getStereotypeDeclarations();
+ for (IStereotypeDeclaration d: ss) {
+ IStereotype s = d.getStereotype();
+ IScope sc = s.getScope();
+ if(sc != null) {
+ defaults.add(sc);
+ }
+ }
+ scb = getSuperClassBean();
+ while(scb != null) {
+ ss = getStereotypeDeclarations();
+ for (IStereotypeDeclaration d: ss) {
+ IStereotype s = d.getStereotype();
+ if(s.getInheritedDeclaration() == null) {
+ continue;
+ }
+ IScope sc = s.getScope();
+ if(sc != null) {
+ defaults.add(sc);
+ }
+ }
+ scb = scb.getSuperClassBean();
+ }
+ if(defaults.size() == 1) {
+ scope = defaults.iterator().next();
+ } else if(defaults.size() > 1) {
+ scope = getCDIProject().getScope(CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME);
+ } else {
+ //4. Scope is @Dependent
+ scope = getCDIProject().getScope(CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME);
+ }
}
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java 2009-12-24
08:46:20 UTC (rev 19569)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java 2009-12-24
13:55:51 UTC (rev 19570)
@@ -19,13 +19,14 @@
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.cdi.core.CDIConstants;
-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.IBean;
import org.jboss.tools.cdi.core.IInjectionPoint;
import org.jboss.tools.cdi.core.IParametedType;
import org.jboss.tools.cdi.core.IProducerField;
+import org.jboss.tools.cdi.core.IScope;
+import org.jboss.tools.cdi.core.IScopeDeclaration;
import org.jboss.tools.cdi.core.IStereotype;
import org.jboss.tools.cdi.core.IStereotypeDeclaration;
import org.jboss.tools.cdi.core.ITypeDeclaration;
@@ -117,8 +118,8 @@
}
public boolean isDependent() {
- IType scope = getScope();
- return scope != null &&
CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME.equals(scope.getFullyQualifiedName());
+ IScope scope = getScope();
+ return scope != null &&
CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME.equals(scope.getSourceType().getFullyQualifiedName());
}
public boolean isEnabled() {
@@ -129,43 +130,26 @@
return false;
}
- public IType getScope() {
- Set<IAnnotationDeclaration> ds = getScopeDeclarations();
+ public IScope getScope() {
+ Set<IScopeDeclaration> ds = getScopeDeclarations();
if(!ds.isEmpty()) {
- return ds.iterator().next().getType();
+ return ds.iterator().next().getScope();
}
- List<AnnotationDeclaration> ds2 = definition.getAnnotations();
- for (AnnotationDeclaration d: ds2) {
- int k = getCDIProject().getNature().getDefinitions().getAnnotationKind(d.getType());
- if(k == AnnotationDefinition.STEREOTYPE) {
- AnnotationDefinition a =
getCDIProject().getNature().getDefinitions().getAnnotation(d.getType());
- ds = getScopeDeclarations(getCDIProject().getNature(), a.getAnnotations());
- if(!ds.isEmpty()) {
- return ds.iterator().next().getType();
- }
+ Set<IStereotypeDeclaration> ss = getStereotypeDeclarations();
+ Set<IScope> defaults = new HashSet<IScope>();
+ for (IStereotypeDeclaration d: ss) {
+ IStereotype s = d.getStereotype();
+ IScope sc = s.getScope();
+ if(sc != null) {
+ defaults.add(sc);
}
}
- try {
- return EclipseJavaUtil.findType(getField().getJavaProject(),
CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME);
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
+ if(defaults.size() == 1) {
+ return defaults.iterator().next();
+ } else if(defaults.size() > 1) {
+ return null;
}
- return null;
+ return getCDIProject().getScope(CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME);
}
- public Set<IAnnotationDeclaration> getScopeDeclarations() {
- return getScopeDeclarations(getCDIProject().getNature(), definition.getAnnotations());
- }
-
- public static Set<IAnnotationDeclaration> getScopeDeclarations(CDICoreNature n,
List<? extends IAnnotationDeclaration> ds) {
- Set<IAnnotationDeclaration> result = new
HashSet<IAnnotationDeclaration>();
- for (IAnnotationDeclaration d: ds) {
- int k = n.getDefinitions().getAnnotationKind(d.getType());
- if(k == AnnotationDefinition.SCOPE) {
- result.add(d);
- }
- }
- return result;
- }
-
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java 2009-12-24
08:46:20 UTC (rev 19569)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java 2009-12-24
13:55:51 UTC (rev 19570)
@@ -25,6 +25,8 @@
import org.jboss.tools.cdi.core.IInjectionPoint;
import org.jboss.tools.cdi.core.IParametedType;
import org.jboss.tools.cdi.core.IProducerMethod;
+import org.jboss.tools.cdi.core.IScope;
+import org.jboss.tools.cdi.core.IScopeDeclaration;
import org.jboss.tools.cdi.core.IStereotype;
import org.jboss.tools.cdi.core.IStereotypeDeclaration;
import org.jboss.tools.cdi.core.ITypeDeclaration;
@@ -133,8 +135,8 @@
}
public boolean isDependent() {
- IType scope = getScope();
- return scope != null &&
CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME.equals(scope.getFullyQualifiedName());
+ IScope scope = getScope();
+ return scope != null &&
CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME.equals(scope.getSourceType().getFullyQualifiedName());
}
public boolean isEnabled() {
@@ -147,32 +149,26 @@
}
//same as ProducerField.getScope
- public IType getScope() {
- Set<IAnnotationDeclaration> ds = getScopeDeclarations();
+ public IScope getScope() {
+ Set<IScopeDeclaration> ds = getScopeDeclarations();
if(!ds.isEmpty()) {
- return ds.iterator().next().getType();
+ return ds.iterator().next().getScope();
}
- List<AnnotationDeclaration> ds2 = definition.getAnnotations();
- for (AnnotationDeclaration d: ds2) {
- int k = getCDIProject().getNature().getDefinitions().getAnnotationKind(d.getType());
- if(k == AnnotationDefinition.STEREOTYPE) {
- AnnotationDefinition a =
getCDIProject().getNature().getDefinitions().getAnnotation(d.getType());
- ds = ProducerField.getScopeDeclarations(getCDIProject().getNature(),
a.getAnnotations());
- if(!ds.isEmpty()) {
- return ds.iterator().next().getType();
- }
+ Set<IStereotypeDeclaration> ss = getStereotypeDeclarations();
+ Set<IScope> defaults = new HashSet<IScope>();
+ for (IStereotypeDeclaration d: ss) {
+ IStereotype s = d.getStereotype();
+ IScope sc = s.getScope();
+ if(sc != null) {
+ defaults.add(sc);
}
}
- try {
- return EclipseJavaUtil.findType(getMethod().getJavaProject(),
CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME);
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
+ if(defaults.size() == 1) {
+ return defaults.iterator().next();
+ } else if(defaults.size() > 1) {
+ return null;
}
- return null;
+ return getCDIProject().getScope(CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME);
}
- public Set<IAnnotationDeclaration> getScopeDeclarations() {
- return ProducerField.getScopeDeclarations(getCDIProject().getNature(),
definition.getAnnotations());
- }
-
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/StereotypeElement.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/StereotypeElement.java 2009-12-24
08:46:20 UTC (rev 19569)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/StereotypeElement.java 2009-12-24
13:55:51 UTC (rev 19570)
@@ -18,6 +18,8 @@
import org.eclipse.jdt.core.IType;
import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.core.IInterceptorBindingDeclaration;
+import org.jboss.tools.cdi.core.IScope;
+import org.jboss.tools.cdi.core.IScopeDeclaration;
import org.jboss.tools.cdi.core.IStereotype;
import org.jboss.tools.cdi.core.IStereotypeDeclaration;
@@ -73,19 +75,23 @@
return false;
}
- public IType getScope() {
- Set<IAnnotationDeclaration> ss = getScopeDeclarations();
+ public IScope getScope() {
+ Set<IScopeDeclaration> ss = getScopeDeclarations();
if(!ss.isEmpty()) {
- return ss.iterator().next().getType();
+ return ss.iterator().next().getScope();
}
Set<IStereotypeDeclaration> ds = getStereotypeDeclarations();
for (IStereotypeDeclaration d: ds) {
- //TODO
+ IStereotype s = d.getStereotype();
+ IScope result = s.getScope();
+ if(result != null) {
+ return result;
+ }
}
return null;
}
- public Set<IAnnotationDeclaration> getScopeDeclarations() {
+ public Set<IScopeDeclaration> getScopeDeclarations() {
return ProducerField.getScopeDeclarations(getCDIProject().getNature(),
definition.getAnnotations());
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/TypeDeclaration.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/TypeDeclaration.java 2009-12-24
08:46:20 UTC (rev 19569)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/TypeDeclaration.java 2009-12-24
13:55:51 UTC (rev 19570)
@@ -24,10 +24,12 @@
public TypeDeclaration() {}
- TypeDeclaration(IType type, int startPosition, int length) {
- this.type = type;
+ TypeDeclaration(ParametedType type, int startPosition, int length) {
+ this.type = type.getType();
this.length = length;
this.startPosition = startPosition;
+ this.signature = type.signature;
+ this.parameterTypes = type.parameterTypes;
}
public int getLength() {
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 2009-12-24
08:46:20 UTC (rev 19569)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractMemberDefinition.java 2009-12-24
13:55:51 UTC (rev 19570)
@@ -48,6 +48,10 @@
}
}
+ public IAnnotatable getMember() {
+ return member;
+ }
+
protected void init(IType contextType, DefinitionContext context) throws CoreException
{
IAnnotation[] ts = member.getAnnotations();
for (int i = 0; i < ts.length; i++) {