Author: scabanovich
Date: 2010-01-22 12:42:26 -0500 (Fri, 22 Jan 2010)
New Revision: 19890
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/definition/AbstractTypeDefinition.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3125
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 2010-01-22
16:59:41 UTC (rev 19889)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2010-01-22
17:42:26 UTC (rev 19890)
@@ -229,8 +229,27 @@
public Set<IParametedType> getLegalTypes() {
Set<IParametedType> result = new HashSet<IParametedType>();
AnnotationDeclaration d = getDefinition().getTypedAnnotation();
+ IType type = getDefinition().getType();
+ if(type != null) {
+ ParametedType p = new ParametedType();
+ p.setType(type);
+ String[] ps = null;
+ try {
+ ps = type.getTypeParameterSignatures();
+ p.setSignature(type.getFullyQualifiedName());
+ } catch (CoreException e) {
+ //TODO
+ }
+ if(ps == null || ps.length == 0) {
+ //type with parameters is not legal
+ result.add(p);
+ }
+ }
+ Set<IParametedType> inh = getDefinition().getAllInheritedTypes();
+ if(inh != null) result.addAll(inh);
if(d != null) {
try {
+ Set<IParametedType> reducedResult = new HashSet<IParametedType>();
IMemberValuePair[] ps = d.getDeclaration().getMemberValuePairs();
if(ps != null) for (IMemberValuePair p: ps) {
Object o = p.getValue();
@@ -240,29 +259,17 @@
String s = os[i].toString();
if(!s.endsWith(";")) s = "Q" + s + ";";
IParametedType t =
ParametedTypeFactory.getParametedType(getDefinition().getType(), s);
- result.add(t);
+ if(CDIProject.containsType(result, t)) {
+ reducedResult.add(t);
+ }
}
}
}
+ result = reducedResult;
} catch (CoreException e) {
//TODO
}
}
- IType type = getDefinition().getType();
- if(type != null) {
- ParametedType p = new ParametedType();
- p.setType(type);
- try {
- String[] ps = type.getTypeParameterSignatures();
- //TODO set parameters
- p.setSignature(type.getFullyQualifiedName());
- } catch (CoreException e) {
- //TODO
- }
- result.add(p);
- }
- Set<IParametedType> inh = getDefinition().getInheritedTypes();
- if(inh != null) result.addAll(inh);
return result;
}
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 2010-01-22
16:59:41 UTC (rev 19889)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractTypeDefinition.java 2010-01-22
17:42:26 UTC (rev 19890)
@@ -30,6 +30,7 @@
protected IType type;
protected ParametedType superType = null;
protected Set<IParametedType> inheritedTypes = new
HashSet<IParametedType>();
+ protected Set<IParametedType> allInheritedTypes = new
HashSet<IParametedType>();
public AbstractTypeDefinition() {}
@@ -60,10 +61,36 @@
ParametedType t = ParametedTypeFactory.getParametedType(type, is[i]);
if(t != null) inheritedTypes.add(t);
}
+ buildAllInheritedTypes(new HashSet<String>(), inheritedTypes);
}
+ void buildAllInheritedTypes(Set<String> processed, Set<IParametedType>
addition) throws CoreException {
+ for (IParametedType p: addition) {
+ IType t = p.getType();
+ if(t == null) continue;
+ if(processed.contains(t.getFullyQualifiedName())) continue;
+ allInheritedTypes.add(p);
+ Set<IParametedType> add = new HashSet<IParametedType>();
+ if(!t.isInterface() && !t.isAnnotation()) {
+ String sc = t.getSuperclassTypeSignature();
+ IParametedType st = ParametedTypeFactory.getParametedType(t, sc);
+ if(st != null) add.add(st);
+ }
+ String[] is = t.getSuperInterfaceTypeSignatures();
+ if(is != null) for (int i = 0; i < is.length; i++) {
+ ParametedType t1 = ParametedTypeFactory.getParametedType(t, is[i]);
+ if(t1 != null) add.add(t1);
+ }
+ buildAllInheritedTypes(processed, add);
+ }
+ }
+
public Set<IParametedType> getInheritedTypes() {
return inheritedTypes;
}
+ public Set<IParametedType> getAllInheritedTypes() {
+ return allInheritedTypes;
+ }
+
}