Author: scabanovich
Date: 2010-12-21 11:47:11 -0500 (Tue, 21 Dec 2010)
New Revision: 27645
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreNature.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/definition/DefinitionContext.java
Log:
JBIDE-7946
https://issues.jboss.org/browse/JBIDE-7946
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreNature.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreNature.java 2010-12-21
16:39:09 UTC (rev 27644)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreNature.java 2010-12-21
16:47:11 UTC (rev 27645)
@@ -12,6 +12,7 @@
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -25,8 +26,11 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IType;
+import org.jboss.tools.cdi.internal.core.impl.definition.AnnotationDefinition;
import org.jboss.tools.cdi.internal.core.impl.definition.DefinitionContext;
import org.jboss.tools.cdi.internal.core.impl.definition.ParametedTypeFactory;
+import org.jboss.tools.cdi.internal.core.impl.definition.TypeDefinition;
import org.jboss.tools.cdi.internal.core.scanner.lib.ClassPathMonitor;
import org.jboss.tools.common.model.XJob;
import org.jboss.tools.common.model.XJob.XRunnable;
@@ -87,6 +91,77 @@
return dependsOn;
}
+ public Set<CDICoreNature> getCDIProjects(boolean hierarchy) {
+ if(hierarchy) {
+ if(dependsOn.isEmpty()) return dependsOn;
+ Set<CDICoreNature> result = new HashSet<CDICoreNature>();
+ getAllCDIProjects(result);
+ return result;
+ } else {
+ return dependsOn;
+ }
+ }
+
+ void getAllCDIProjects(Set<CDICoreNature> result) {
+ for (CDICoreNature n:dependsOn) {
+ if(result.contains(n)) continue;
+ result.add(n);
+ n.getAllCDIProjects(result);
+ }
+ }
+
+ public List<TypeDefinition> getAllTypeDefinitions() {
+ Set<CDICoreNature> ps = getCDIProjects(true);
+ if(ps == null || ps.isEmpty()) {
+ return getDefinitions().getTypeDefinitions();
+ }
+ List<TypeDefinition> ds = getDefinitions().getTypeDefinitions();
+ List<TypeDefinition> result = new ArrayList<TypeDefinition>();
+ result.addAll(ds);
+ Set<IType> types = new HashSet<IType>();
+ for (TypeDefinition d: ds) {
+ IType t = d.getType();
+ if(t != null) types.add(t);
+ }
+ for (CDICoreNature p: ps) {
+ List<TypeDefinition> ds2 = p.getDefinitions().getTypeDefinitions();
+ for (TypeDefinition d: ds2) {
+ IType t = d.getType();
+ if(t != null && !types.contains(t)) {
+ types.add(t);
+ result.add(d);
+ }
+ }
+ }
+ return result;
+ }
+
+ public List<AnnotationDefinition> getAllAnnotations() {
+ Set<CDICoreNature> ps = getCDIProjects(true);
+ if(ps == null || ps.isEmpty()) {
+ return getDefinitions().getAllAnnotations();
+ }
+ List<AnnotationDefinition> ds = getDefinitions().getAllAnnotations();
+ List<AnnotationDefinition> result = new ArrayList<AnnotationDefinition>();
+ result.addAll(ds);
+ Set<IType> types = new HashSet<IType>();
+ for (AnnotationDefinition d: ds) {
+ IType t = d.getType();
+ if(t != null) types.add(t);
+ }
+ for (CDICoreNature p: ps) {
+ List<AnnotationDefinition> ds2 = p.getDefinitions().getAllAnnotations();
+ for (AnnotationDefinition d: ds2) {
+ IType t = d.getType();
+ if(t != null && !types.contains(t)) {
+ types.add(t);
+ result.add(d);
+ }
+ }
+ }
+ return result;
+ }
+
public Set<CDICoreNature> getDependentProjects() {
return usedBy;
}
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 2010-12-21
16:39:09 UTC (rev 27644)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2010-12-21
16:47:11 UTC (rev 27645)
@@ -1041,7 +1041,7 @@
interceptorBindingsByPath.clear();
scopes.clear();
scopesByPath.clear();
- List<AnnotationDefinition> ds = getAllAnnotations();
+ List<AnnotationDefinition> ds = n.getAllAnnotations();
for (AnnotationDefinition d: ds) {
if((d.getKind() & AnnotationDefinition.STEREOTYPE) > 0) {
StereotypeElement s = new StereotypeElement();
@@ -1087,60 +1087,8 @@
}
}
- List<AnnotationDefinition> getAllAnnotations() {
- Set<CDICoreNature> ps = n.getCDIProjects();
- if(ps == null || ps.isEmpty()) {
- return n.getDefinitions().getAllAnnotations();
- }
- List<AnnotationDefinition> ds = n.getDefinitions().getAllAnnotations();
- List<AnnotationDefinition> result = new ArrayList<AnnotationDefinition>();
- result.addAll(ds);
- Set<IType> types = new HashSet<IType>();
- for (AnnotationDefinition d: ds) {
- IType t = d.getType();
- if(t != null) types.add(t);
- }
- for (CDICoreNature p: ps) {
- List<AnnotationDefinition> ds2 = p.getDefinitions().getAllAnnotations();
- for (AnnotationDefinition d: ds2) {
- IType t = d.getType();
- if(t != null && !types.contains(t)) {
- types.add(t);
- result.add(d);
- }
- }
- }
- return result;
- }
-
- List<TypeDefinition> getAllTypeDefinitions() {
- Set<CDICoreNature> ps = n.getCDIProjects();
- if(ps == null || ps.isEmpty()) {
- return n.getDefinitions().getTypeDefinitions();
- }
- List<TypeDefinition> ds = n.getDefinitions().getTypeDefinitions();
- List<TypeDefinition> result = new ArrayList<TypeDefinition>();
- result.addAll(ds);
- Set<IType> types = new HashSet<IType>();
- for (TypeDefinition d: ds) {
- IType t = d.getType();
- if(t != null) types.add(t);
- }
- for (CDICoreNature p: ps) {
- List<TypeDefinition> ds2 = p.getDefinitions().getTypeDefinitions();
- for (TypeDefinition d: ds2) {
- IType t = d.getType();
- if(t != null && !types.contains(t)) {
- types.add(t);
- result.add(d);
- }
- }
- }
- return result;
- }
-
void rebuildBeans() {
- List<TypeDefinition> typeDefinitions = getAllTypeDefinitions();
+ List<TypeDefinition> typeDefinitions = n.getAllTypeDefinitions();
List<IBean> beans = new ArrayList<IBean>();
Map<IType, ClassBean> newClassBeans = new HashMap<IType, ClassBean>();
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 2010-12-21
16:39:09 UTC (rev 27644)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java 2010-12-21
16:47:11 UTC (rev 27645)
@@ -282,7 +282,7 @@
String name = type.getFullyQualifiedName();
AnnotationDefinition result = annotations.get(name);
if(result == null) {
- Set<CDICoreNature> ns = project.getCDIProjects();
+ Set<CDICoreNature> ns = project.getCDIProjects(true);
for (CDICoreNature n: ns) {
result = n.getDefinitions().getAnnotation(type);
if(result != null) {