Author: scabanovich
Date: 2010-03-02 07:09:00 -0500 (Tue, 02 Mar 2010)
New Revision: 20554
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/CDICoreNature.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/scanner/lib/ClassPathMonitor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5948
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 2010-03-02
11:41:03 UTC (rev 20553)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java 2010-03-02
12:09:00 UTC (rev 20554)
@@ -144,10 +144,13 @@
n.getDefinitions().newWorkingCopy(kind == FULL_BUILD);
if(n.getClassPath().update()) {
+ n.getClassPath().setSrcs(getResourceVisitor().srcs);
Map<String, XModelObject> newJars = n.getClassPath().process();
buildJars(newJars);
n.getClassPath().validateProjectDependencies();
+
+ kind = FULL_BUILD;
} else if(n.getClassPath().hasToUpdateProjectDependencies()) {
n.getClassPath().validateProjectDependencies();
}
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-03-02
11:41:03 UTC (rev 20553)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreNature.java 2010-03-02
12:09:00 UTC (rev 20554)
@@ -268,7 +268,7 @@
public void pathRemoved(IPath source) {
// sourcePaths2.remove(source);
- definitions.clean(source);
+ definitions.getWorkingCopy().clean(source);
//TODO
}
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-03-02
11:41:03 UTC (rev 20553)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java 2010-03-02
12:09:00 UTC (rev 20554)
@@ -33,6 +33,7 @@
protected IJavaProject javaProject;
private Set<String> types = new HashSet<String>();
+ private Map<IPath, Set<IPath>> childPaths = new HashMap<IPath,
Set<IPath>>();
private Map<IPath, Set<String>> resources = new HashMap<IPath,
Set<String>>();
private Map<String, TypeDefinition> typeDefinitions = new HashMap<String,
TypeDefinition>();
private Map<String, AnnotationDefinition> annotations = new HashMap<String,
AnnotationDefinition>();
@@ -60,6 +61,14 @@
copy.resources.put(p, s1);
}
}
+ for (IPath p: childPaths.keySet()) {
+ Set<IPath> set = childPaths.get(p);
+ if(set != null) {
+ Set<IPath> s1 = new HashSet<IPath>();
+ s1.addAll(set);
+ copy.childPaths.put(p, s1);
+ }
+ }
copy.beanXMLs.putAll(beanXMLs);
}
@@ -88,6 +97,7 @@
}
ts.add(typeName);
types.add(typeName);
+ addToParents(file);
}
if(def != null) {
if(def instanceof AnnotationDefinition) {
@@ -106,9 +116,25 @@
synchronized (beanXMLs) {
beanXMLs.put(path, def);
}
+ addToParents(path);
}
+ private void addToParents(IPath file) {
+ if(file == null) return;
+ if(file.segmentCount() < 2) return;
+ IPath q = file;
+ while(q.segmentCount() >= 2) {
+ q = q.removeLastSegments(1);
+ Set<IPath> cs = childPaths.get(q);
+ if(cs == null) {
+ childPaths.put(q, cs = new HashSet<IPath>());
+ }
+ cs.add(file);
+ }
+ }
+
public void clean() {
+ childPaths.clear();
resources.clear();
types.clear();
synchronized (typeDefinitions) {
@@ -136,8 +162,33 @@
synchronized (beanXMLs) {
beanXMLs.remove(path);
}
+
+ Set<IPath> cs = childPaths.get(path);
+ if(cs != null) {
+ IPath[] ps = cs.toArray(new IPath[0]);
+ for (IPath p: ps) {
+ clean(p);
+ }
+ } else {
+ removeFromParents(path);
+ }
}
+ void removeFromParents(IPath file) {
+ if(file == null) return;
+ IPath q = file;
+ while(q.segmentCount() >= 2) {
+ q = q.removeLastSegments(1);
+ Set<IPath> cs = childPaths.get(q);
+ if(cs != null) {
+ cs.remove(file);
+ if(cs.isEmpty()) {
+ childPaths.remove(q);
+ }
+ }
+ }
+ }
+
private Set<String> underConstruction = new HashSet<String>();
public int getAnnotationKind(IType annotationType) {
@@ -217,6 +268,7 @@
types = workingCopy.types;
resources = workingCopy.resources;
+ childPaths = workingCopy.childPaths;
typeDefinitions = workingCopy.typeDefinitions;
annotations = workingCopy.annotations;
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/lib/ClassPathMonitor.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/lib/ClassPathMonitor.java 2010-03-02
11:41:03 UTC (rev 20553)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/lib/ClassPathMonitor.java 2010-03-02
12:09:00 UTC (rev 20554)
@@ -13,11 +13,14 @@
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.jboss.tools.cdi.core.CDICoreNature;
import org.jboss.tools.common.model.XModelObject;
@@ -28,6 +31,7 @@
import org.jboss.tools.jst.web.kb.internal.scanner.ScannerException;
public class ClassPathMonitor extends AbstractClassPathMonitor<CDICoreNature>{
+ IPath[] srcs = new IPath[0];
public ClassPathMonitor(CDICoreNature project) {
this.project = project;
@@ -78,4 +82,17 @@
return project.getProject();
}
+ public void setSrcs(IPath[] newSrcs) {
+ Set<IPath> ss = new HashSet<IPath>();
+ for (IPath s: newSrcs) {
+ ss.add(s);
+ }
+ for (IPath s: srcs) {
+ if(!ss.contains(s)) {
+ project.pathRemoved(s);
+ }
+ }
+ srcs = newSrcs;
+ }
+
}