Author: scabanovich
Date: 2011-08-31 14:50:16 -0400 (Wed, 31 Aug 2011)
New Revision: 34446
Modified:
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreNature.java
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIProject.java
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIProjectTree.java
branches/jbosstools-3.3.0.M3/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/testmodel/CDIProject.java
Log:
JBIDE-9608
https://issues.jboss.org/browse/JBIDE-9608
Prevented multiple invocation of update for dependent cdi projects.
Merge to 3.3.0.M3
Modified:
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreNature.java
===================================================================
---
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreNature.java 2011-08-31
18:42:46 UTC (rev 34445)
+++
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreNature.java 2011-08-31
18:50:16 UTC (rev 34446)
@@ -13,9 +13,12 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.ICommand;
@@ -178,7 +181,7 @@
public List<AnnotationDefinition> getAllAnnotations() {
Set<CDICoreNature> ps = getCDIProjects(false);
- if(ps == null || ps.isEmpty()) {
+ if(ps == null || ps.isEmpty() || getCDIProjects(true).contains(this)) {
return getDefinitions().getAllAnnotations();
}
List<AnnotationDefinition> result = new ArrayList<AnnotationDefinition>();
@@ -236,6 +239,35 @@
return usedBy;
}
+ public CDICoreNature[] getAllDependentProjects() {
+ Map<CDICoreNature, Integer> set = new HashMap<CDICoreNature, Integer>();
+ getAllDependentProjects(set, 0);
+ CDICoreNature[] result = set.keySet().toArray(new CDICoreNature[set.size()]);
+ Arrays.sort(result, new D(set));
+ return result;
+ }
+ private void getAllDependentProjects(Map<CDICoreNature, Integer> result, int
level) {
+ if(level > 10) return;
+ for (CDICoreNature n:usedBy) {
+ if(!result.containsKey(n) || result.get(n).intValue() < level) {
+ result.put(n, level);
+ n.getAllDependentProjects(result, level + 1);
+ }
+ }
+ }
+ private static class D implements Comparator<CDICoreNature> {
+ Map<CDICoreNature, Integer> set;
+ D(Map<CDICoreNature, Integer> set) {
+ this.set = set;
+ }
+ @Override
+ public int compare(CDICoreNature o1, CDICoreNature o2) {
+ return set.get(o1).intValue() - set.get(o2).intValue();
+ }
+
+ }
+
+
public void addCDIProject(final CDICoreNature p) {
if(dependsOn.contains(p)) return;
addUsedCDIProject(p);
@@ -246,7 +278,7 @@
public void run() {
p.resolve();
if(p.getDelegate() != null) {
- p.getDelegate().update();
+ p.getDelegate().update(true);
}
}
@@ -361,7 +393,7 @@
definitions.clean();
if(cdiProjectDelegate != null) {
- cdiProjectDelegate.update();
+ cdiProjectDelegate.update(true);
}
// IPath[] ps = sourcePaths2.keySet().toArray(new IPath[0]);
// for (int i = 0; i < ps.length; i++) {
Modified:
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIProject.java
===================================================================
---
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIProject.java 2011-08-31
18:42:46 UTC (rev 34445)
+++
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIProject.java 2011-08-31
18:50:16 UTC (rev 34446)
@@ -17,5 +17,5 @@
public CDICoreNature getNature();
public void setNature(CDICoreNature n);
- public void update();
+ public void update(boolean updateDependent);
}
\ No newline at end of file
Modified:
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
===================================================================
---
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2011-08-31
18:42:46 UTC (rev 34445)
+++
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2011-08-31
18:50:16 UTC (rev 34446)
@@ -973,7 +973,7 @@
return scopesByPath.get(path);
}
- public void update() {
+ public void update(boolean updateDependent) {
rebuildXML();
rebuildAnnotationTypes();
rebuildBeans();
@@ -988,13 +988,15 @@
bp.buildBeans(this);
}
}
-
- CDICoreNature[] ps = n.getDependentProjects().toArray(new CDICoreNature[0]);
- for (CDICoreNature p: ps) {
- if(p.getProject() != null && p.getProject().isAccessible() &&
p.getDelegate() != null) {
- p.getDelegate().update();
+
+ if(updateDependent) {
+ CDICoreNature[] ps = n.getAllDependentProjects();
+ for (CDICoreNature p: ps) {
+ if(p.getProject() != null && p.getProject().isAccessible() &&
p.getDelegate() != null) {
+ p.getDelegate().update(false);
+ }
}
- }
+ }
CDICorePlugin.fire(new CDIProjectChangeEvent(this));
}
Modified:
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java
===================================================================
---
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java 2011-08-31
18:42:46 UTC (rev 34445)
+++
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java 2011-08-31
18:50:16 UTC (rev 34446)
@@ -380,7 +380,7 @@
//extensions may add to dependencies while they change
dependencies = workingCopy.dependencies;
- project.getDelegate().update();
+ project.getDelegate().update(true);
workingCopy = null;
}
@@ -414,9 +414,15 @@
|| (result.getType().getResource() != null &&
result.getType().getResource().getProject() != project.getProject())
) {
//3. Look in annotations loaded by used projects
- Set<CDICoreNature> ns = project.getCDIProjects(true);
+ Set<CDICoreNature> ns = project.getCDIProjects(false);
+ Set<CDICoreNature> ns2 = project.getCDIProjects(true);
+ boolean cyclic = ns2.contains(project);
+ if(cyclic) {
+ ns = ns2;
+ }
for (CDICoreNature n: ns) {
- AnnotationDefinition r = n.getDefinitions().getAnnotation(fullyQualifiedName);
+ DefinitionContext d = n.getDefinitions();
+ AnnotationDefinition r = (!cyclic) ? d.getAnnotation(fullyQualifiedName) :
d.annotations.get(fullyQualifiedName);
if(r != null) {
result = r;
//4. Store result for the case if used project is cleaned.
Modified:
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIProjectTree.java
===================================================================
---
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIProjectTree.java 2011-08-31
18:42:46 UTC (rev 34445)
+++
branches/jbosstools-3.3.0.M3/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIProjectTree.java 2011-08-31
18:50:16 UTC (rev 34446)
@@ -104,14 +104,14 @@
private Set<CDICoreNature> getRootProjects(CDICoreNature project) {
Set<CDICoreNature> result = new HashSet<CDICoreNature>();
- Set<CDICoreNature> dependentProjects = project.getDependentProjects();
- if(dependentProjects.isEmpty()) {
+ CDICoreNature[] dependentProjects = project.getAllDependentProjects();
+ if(dependentProjects.length == 0) {
result.add(project);
} else {
for (CDICoreNature nature : dependentProjects) {
if(!nature.getProject().isAccessible()) continue;
- if(!result.contains(nature)) {
- result.addAll(getRootProjects(nature));
+ if(nature.getDependentProjects().isEmpty()) {
+ result.add(nature);
}
}
}
Modified:
branches/jbosstools-3.3.0.M3/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/testmodel/CDIProject.java
===================================================================
---
branches/jbosstools-3.3.0.M3/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/testmodel/CDIProject.java 2011-08-31
18:42:46 UTC (rev 34445)
+++
branches/jbosstools-3.3.0.M3/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/testmodel/CDIProject.java 2011-08-31
18:50:16 UTC (rev 34446)
@@ -297,7 +297,7 @@
}
@Override
- public void update() {
+ public void update(boolean updateDependent) {
}
-}
+}
\ No newline at end of file