Author: scabanovich
Date: 2010-10-12 11:37:25 -0400 (Tue, 12 Oct 2010)
New Revision: 25752
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCorePlugin.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamScope.java
Log:
JBIDE-7319
https://jira.jboss.org/browse/JBIDE-7319
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java 2010-10-12
15:34:12 UTC (rev 25751)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java 2010-10-12
15:37:25 UTC (rev 25752)
@@ -61,13 +61,13 @@
long end = System.currentTimeMillis();
seamProject.fullBuildTime += end - begin;
- try {
- //It is important to save results of build right after the build is done.
- //Otherwise, at Eclipse restart, the results can be lost.
- seamProject.store();
- } catch (IOException e) {
- SeamCorePlugin.getDefault().logError(e);
- }
+// try {
+// //It is important to save results of build right after the build is done.
+// //Otherwise, at Eclipse restart, the results can be lost.
+// seamProject.store();
+// } catch (IOException e) {
+// SeamCorePlugin.getDefault().logError(e);
+// }
seamProject.postBuild();
} finally {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCorePlugin.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCorePlugin.java 2010-10-12
15:34:12 UTC (rev 25751)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCorePlugin.java 2010-10-12
15:37:25 UTC (rev 25752)
@@ -77,11 +77,24 @@
switch (context.getKind()) {
case ISaveContext.SNAPSHOT:
case ISaveContext.FULL_SAVE:
+ IProject[] ps = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for (IProject p: ps) {
+ SeamProject sp = (SeamProject)SeamCorePlugin.getSeamProject(p, false);
+ if(sp != null && sp.getModificationsSinceLastStore() > 0) {
+// sp.printModifications();
+ try {
+ sp.store();
+ } catch (IOException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ }
+ }
break;
case ISaveContext.PROJECT_SAVE:
SeamProject sp = (SeamProject)SeamCorePlugin.getSeamProject(context.getProject(),
false);
try {
- if(sp != null) {
+ if(sp != null && sp.getModificationsSinceLastStore() > 0) {
+ sp.printModifications();
//Not any project is a seam project
sp.store();
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2010-10-12
15:34:12 UTC (rev 25751)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2010-10-12
15:37:25 UTC (rev 25752)
@@ -110,6 +110,8 @@
ProjectValidationContext validationContext;
+ protected int modifications = 0;
+
/**
*
*/
@@ -284,6 +286,7 @@
public void addSeamProject(SeamProject p) {
if(dependsOn.contains(p)) return;
dependsOn.add(p);
+ modifications++;
p.addDependentSeamProject(this);
if(!p.isStorageResolved) {
p.resolve();
@@ -314,7 +317,7 @@
* @param p
*/
public void addDependentSeamProject(SeamProject p) {
- usedBy.add(p);
+ if(usedBy.add(p)) modifications++;
}
public Map<String, Set<ISeamNamespace>> getNamespaces() {
@@ -329,6 +332,7 @@
if(!dependsOn.contains(p)) return;
p.usedBy.remove(this);
dependsOn.remove(p);
+ modifications++;
IPath[] ps = sourcePaths2.keySet().toArray(new IPath[0]);
for (int i = 0; i < ps.length; i++) {
IPath pth = ps[i];
@@ -413,6 +417,11 @@
} finally {
fireChanges();
+
+ modifications = 0;
+ namespaces.modifications = 0;
+ components.modifications = 0;
+ factories.modifications = 0;
}
}
@@ -479,6 +488,25 @@
scopesMap.put(types[i], scopes[i]);
}
}
+
+ public int getModificationsSinceLastStore() {
+ return modifications +
+ namespaces.modifications +
+ components.modifications +
+ factories.modifications +
+ ((validationContext != null) ? validationContext.getModificationsSinceLastStore() :
0);
+ }
+
+ public void printModifications() {
+ System.out.println(project.getName());
+ System.out.println("" + modifications);
+ System.out.println("namespaces " + namespaces.modifications);
+ System.out.println("components " + components.modifications);
+ System.out.println("factories " + factories.modifications);
+ if(validationContext != null)
+ System.out.println("validationContext " +
validationContext.getModificationsSinceLastStore());
+ }
+
/**
* Stores results of last build, so that on exit/enter Eclipse
* load them without rebuilding project
@@ -498,6 +526,11 @@
if(validationContext != null) validationContext.store(root);
XMLUtilities.serialize(root, file.getAbsolutePath());
+
+ modifications = 0;
+ namespaces.modifications = 0;
+ components.modifications = 0;
+ factories.modifications = 0;
}
/*
@@ -785,6 +818,7 @@
* @param source
*/
public void registerComponents(LoadedDeclarations ds, IPath source) {
+ boolean isThisProject = pathCheck.isThisProject(source);
ISeamNamespace[] ns = ds.getNamespaces().toArray(new ISeamNamespace[0]);
ISeamComponentDeclaration[] components = ds.getComponents().toArray(new
ISeamComponentDeclaration[0]);
@@ -848,7 +882,7 @@
Change cc = new Change(c, null, null, null);
cc.addChildren(changes);
List<Change> cchanges = Change.addChange(null, cc);
- fireChanges(cchanges);
+ fireChanges(cchanges, isThisProject);
//TODO if java, fire to others
}
if(nameChanged) {
@@ -897,7 +931,7 @@
} else if(c != null) {
c.addDeclaration(loaded);
List<Change> changes = Change.addChange(null, new Change(c, null, null,
loaded));
- fireChanges(changes);
+ fireChanges(changes, isThisProject);
}
if(loaded instanceof ISeamJavaComponentDeclaration) {
@@ -908,7 +942,7 @@
SeamComponent cii = (SeamComponent)ci;
cii.addDeclaration(loaded);
List<Change> changes = Change.addChange(null, new Change(ci, null, null,
loaded));
- fireChanges(changes);
+ fireChanges(changes, isThisProject);
affectedComponents.add(cii);
}
SeamComponent empty = this.components.getByName("");
@@ -920,7 +954,7 @@
List<Change> changes = Change.addChange(null, new Change(empty, null, x,
null));
c.addDeclaration(x);
changes = Change.addChange(changes, new Change(empty, null, null, x));
- fireChanges(changes);
+ fireChanges(changes, isThisProject);
}
}
}
@@ -947,7 +981,7 @@
empty.addDeclaration(d);
changes = Change.addChange(changes, new Change(empty, null, null, d));
}
- fireChanges(changes);
+ fireChanges(changes, isThisProject);
}
}
} else if(loaded instanceof ISeamXmlComponentDeclaration) {
@@ -961,7 +995,7 @@
addedComponents = sc.revalidate(addedComponents);
}
- fireChanges(addedComponents);
+ fireChanges(addedComponents, isThisProject);
componentDeclarationsRemoved(currentComponents);
@@ -978,7 +1012,7 @@
}
if(current != null) {
List<Change> changes = current.merge(loaded);
- fireChanges(changes);
+ fireChanges(changes, isThisProject);
continue;
}
if(factories[i].getParent() == null) {
@@ -987,7 +1021,7 @@
this.factories.addFactory(factories[i]);
addedFactories = Change.addChange(addedFactories, new Change(this, null, null,
loaded));
}
- fireChanges(addedFactories);
+ fireChanges(addedFactories, isThisProject);
factoryDeclarationsRemoved(currentFactories);
@@ -1116,7 +1150,7 @@
changes = Change.addChange(changes, new Change(c, null, null, j));
}
if(changes != null) c.revalidate(changes);
- fireChanges(changes);
+ fireChanges(changes, pathCheck.isThisProject(xml.getSourcePath()));
}
public boolean isPathLoaded(IPath source) {
@@ -1152,7 +1186,7 @@
components.removePath(source);
- fireChanges(changes);
+ fireChanges(changes, false);
// revalidate();
@@ -1161,7 +1195,7 @@
if(fs != null) for (ISeamFactory f: fs) {
changes = Change.addChange(changes, new Change(this, null, f, null));
}
- fireChanges(changes);
+ fireChanges(changes, false);
firePathRemovedToDependentProjects(source);
}
@@ -1221,7 +1255,7 @@
}
}
- fireChanges(changes);
+ fireChanges(changes, false);
}
/*
@@ -1275,7 +1309,7 @@
removeVariable(c);
changes = Change.addChange(changes, new Change(this, null, c, null));
}
- fireChanges(changes);
+ fireChanges(changes, false);
}
/**
@@ -1347,6 +1381,7 @@
public void setImports(String source, List<String> paths) {
if(equalLists(imports.get(source), paths)) return;
+ modifications++;
synchronized(variables) {
variables.allVariablesPlusShort = null;
variables.byName = null;
@@ -1365,6 +1400,7 @@
public void removeImports(String source) {
if(!imports.containsKey(source)) return;
+ modifications++;
synchronized(variables) {
variables.allVariablesPlusShort = null;
}
@@ -1609,15 +1645,16 @@
if(postponedChanges == null) return;
List<Change> changes = postponedChanges;
postponedChanges = null;
- fireChanges(changes);
+ fireChanges(changes, false);
}
/**
*
* @param changes
*/
- void fireChanges(List<Change> changes) {
+ void fireChanges(List<Change> changes, boolean increaseModification) {
if(changes == null || changes.isEmpty()) return;
+ if(increaseModification) modifications++;
if(postponedChanges != null) {
postponedChanges.addAll(changes);
return;
@@ -1842,10 +1879,19 @@
p.getComponents().add(c);
}
- class NamespaceStorage {
+ class Storage {
+ protected int modifications = 0;
+
+ protected void increaseModification(IPath path) {
+ if(pathCheck.isThisProject(path)) modifications++;
+ }
+
+ }
+
+ class NamespaceStorage extends Storage {
Map<IPath, Set<ISeamNamespace>> namespacesBySource = new HashMap<IPath,
Set<ISeamNamespace>>();
Map<String, Set<ISeamNamespace>> namespacesByURI = new HashMap<String,
Set<ISeamNamespace>>();
-
+
public void clear() {
namespacesBySource.clear();
namespacesByURI.clear();
@@ -1877,7 +1923,7 @@
s = new HashSet<ISeamNamespace>();
namespacesByURI.put(n.getURI(), s);
}
- s.add(n);
+ if(s.add(n)) increaseModification(n.getSourcePath());
}
IPath path = n.getSourcePath();
if(path != null) {
@@ -1886,7 +1932,9 @@
fs = new HashSet<ISeamNamespace>();
namespacesBySource.put(path, fs);
}
- fs.add(n);
+ if(fs.add(n)) {
+ increaseModification(n.getSourcePath());
+ }
}
}
@@ -1894,19 +1942,24 @@
Set<ISeamNamespace> sd = namespacesBySource.get(path);
if(sd == null) return;
for (ISeamNamespace d: sd) {
- if(d.getURI() != null)
- namespacesByURI.remove(d.getURI());
+ if(d.getURI() != null) {
+ if(namespacesByURI.remove(d.getURI()) != null) {
+ increaseModification(d.getSourcePath());
+ }
+ }
}
namespacesBySource.remove(path);
}
public void removeNamespace(ISeamNamespace n) {
- namespacesByURI.remove(n.getURI());
+ if(namespacesByURI.remove(n.getURI()) != null) {
+ increaseModification(n.getSourcePath());
+ }
IPath path = n.getSourcePath();
if(path != null) {
Set<ISeamNamespace> fs = namespacesBySource.get(path);
if(fs != null) {
- fs.remove(n);
+ if(fs.remove(n)) increaseModification(n.getSourcePath());
}
if(fs.isEmpty()) {
namespacesBySource.remove(fs);
@@ -1916,16 +1969,15 @@
}
- class ComponentStorage {
+ class ComponentStorage extends Storage {
private Set<ISeamComponent> allComponentsSet = new
HashSet<ISeamComponent>();
Map<String, SeamComponent> allComponents = new HashMap<String,
SeamComponent>();
Map<String, SeamJavaComponentDeclaration> javaDeclarations = new
HashMap<String, SeamJavaComponentDeclaration>();
- ISeamJavaComponentDeclaration[] javaDeclarationsArray = null;
+ ISeamJavaComponentDeclaration[] javaDeclarationsArray = null;
-
Map<IPath, Set<SeamComponentDeclaration>> declarationsBySource = new
HashMap<IPath, Set<SeamComponentDeclaration>>();
Map<String, Set<SeamComponentDeclaration>> declarationsByClassName = new
HashMap<String, Set<SeamComponentDeclaration>>();
-
+
public void clear() {
synchronized(allComponentsSet) {
allComponentsSet.clear();
@@ -1937,6 +1989,7 @@
}
declarationsBySource.clear();
declarationsByClassName.clear();
+ modifications = 1;
}
public ISeamComponent[] getAllComponentsArray() {
@@ -1988,13 +2041,13 @@
declarationsBySource.put(path, sc);
}
synchronized(sc) {
- sc.add(d);
+ if(sc.add(d)) increaseModification(d.getSourcePath());
}
if(d instanceof ISeamJavaComponentDeclaration) {
SeamJavaComponentDeclaration jd = (SeamJavaComponentDeclaration)d;
for (ISeamContextVariable v: jd.getDeclaredVariables()) addVariable(v);
synchronized(javaDeclarations) {
- javaDeclarations.put(jd.getClassName(), jd);
+ if(javaDeclarations.put(jd.getClassName(), jd) != jd)
increaseModification(jd.getSourcePath());
javaDeclarationsArray = null;
}
addDeclaration(jd.getClassName(), jd);
@@ -2012,7 +2065,7 @@
Set<SeamComponentDeclaration> sc = declarationsBySource.get(path);
if(sc != null) {
synchronized(sc) {
- sc.remove(d);
+ if(sc.remove(d)) increaseModification(d.getSourcePath());
}
if(sc.isEmpty()) declarationsBySource.remove(path);
}
@@ -2049,14 +2102,14 @@
removeDeclarationWithClass(d);
}
}
- declarationsBySource.remove(path);
+ if(declarationsBySource.remove(path) != null) increaseModification(path);
}
private void removeDeclarationWithClass(SeamComponentDeclaration d) {
if(d instanceof ISeamJavaComponentDeclaration) {
SeamJavaComponentDeclaration jd = (SeamJavaComponentDeclaration)d;
synchronized(javaDeclarations) {
- javaDeclarations.remove(jd.getClassName());
+ if(javaDeclarations.remove(jd.getClassName()) != null)
increaseModification(jd.getSourcePath());
javaDeclarationsArray = null;
}
for (ISeamContextVariable v: jd.getDeclaredVariables()) removeVariable(v);
@@ -2085,13 +2138,13 @@
sc = new HashSet<SeamComponentDeclaration>();
declarationsByClassName.put(className, sc);
}
- sc.add(d);
+ if(sc.add(d)) increaseModification(d.getSourcePath());
}
private void removeDeclaration(String className, SeamComponentDeclaration d) {
Set<SeamComponentDeclaration> sc = declarationsByClassName.get(className);
if(sc != null) {
- sc.remove(d);
+ if(sc.remove(d)) increaseModification(d.getSourcePath());
if(sc.isEmpty()) {
declarationsByClassName.remove(className);
}
@@ -2100,12 +2153,12 @@
}
- class FactoryStorage {
+ class FactoryStorage extends Storage {
private Set<ISeamFactory> allFactories = new HashSet<ISeamFactory>();
private ISeamFactory[] allFactoriesArray = null;
Map<IPath, Set<ISeamFactory>> factoriesBySource = new HashMap<IPath,
Set<ISeamFactory>>();
SeamMessages messages = null;
-
+
public void clear() {
synchronized(allFactories) {
allFactories.clear();
@@ -2113,6 +2166,7 @@
}
factoriesBySource.clear();
messages = null;
+ modifications = 1;
}
public ISeamFactory[] getAllFactoriesArray() {
@@ -2132,7 +2186,7 @@
public void addFactory(ISeamFactory f) {
synchronized(allFactories) {
- allFactories.add(f);
+ if(allFactories.add(f)) increaseModification(f.getSourcePath());
allFactoriesArray = null;
}
IPath path = f.getSourcePath();
@@ -2142,32 +2196,34 @@
fs = new HashSet<ISeamFactory>();
factoriesBySource.put(path, fs);
}
- fs.add(f);
+ if(fs.add(f)) increaseModification(f.getSourcePath());
}
addVariable(f);
- if(f instanceof SeamMessages) {
+ if(f instanceof SeamMessages && f != messages) {
messages = (SeamMessages)f;
+ modifications++;
}
}
public void removeFactory(ISeamFactory f) {
synchronized(allFactories) {
- allFactories.remove(f);
+ if(allFactories.remove(f)) increaseModification(f.getSourcePath());
allFactoriesArray = null;
}
IPath path = f.getSourcePath();
if(path != null) {
Set<ISeamFactory> fs = factoriesBySource.get(path);
if(fs != null) {
- fs.remove(f);
+ if(fs.remove(f)) increaseModification(f.getSourcePath());
}
if(fs.isEmpty()) {
factoriesBySource.remove(fs);
}
}
removeVariable(f);
- if(f == messages) {
+ if(f == messages && f != null) {
messages = null;
+ increaseModification(f.getSourcePath());
}
}
@@ -2176,13 +2232,16 @@
if(fs == null) return null;
for (ISeamFactory f: fs) {
synchronized(allFactories) {
- allFactories.remove(f);
+ if(allFactories.remove(f)) increaseModification(f.getSourcePath());
allFactoriesArray = null;
}
removeVariable(f);
- if(f == messages) messages = null;
+ if(f == messages) {
+ messages = null;
+ modifications++;
+ }
}
- factoriesBySource.remove(path);
+ if(factoriesBySource.remove(path) != null) increaseModification(path);
return fs;
}
@@ -2198,6 +2257,7 @@
public void clear() {
allVariables.clear();
clearCopies();
+ modifications = 1;
}
synchronized void clearCopies() {
@@ -2310,4 +2370,29 @@
}
}
+ PathCheck pathCheck = new PathCheck();
+
+ class PathCheck {
+ Map<IPath, Boolean> paths = new HashMap<IPath, Boolean>();
+
+ public boolean isThisProject(IPath path) {
+ if(path.toString().equals("/seam77")) {
+ System.out.println("hh");
+ }
+ Boolean b = paths.get(path);
+ if(b == null) {
+ IFile f = null;
+ try {
+ f = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ } catch (Exception e) {
+ System.out.println("Bad path=" + path);
+ }
+ b = !(f != null && f.exists() && f.getProject() != project);
+ paths.put(path, b);
+ }
+ return b.booleanValue();
+ }
+
+ }
+
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamScope.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamScope.java 2010-10-12
15:34:12 UTC (rev 25751)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamScope.java 2010-10-12
15:37:25 UTC (rev 25752)
@@ -74,7 +74,7 @@
void revalidatePackages() {
List<Change> changes = SeamPackageUtil.revalidatePackages(this, componentMap,
getComponents(), packages);
- ((SeamProject)getSeamProject()).fireChanges(changes);
+ ((SeamProject)getSeamProject()).fireChanges(changes, false);
}
public void validatePackage(SeamComponent c) {