Author: scabanovich
Date: 2010-10-12 11:34:12 -0400 (Tue, 12 Oct 2010)
New Revision: 25751
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidatorContext.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/LinkCollection.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ProjectValidationContext.java
Log:
JBIDE-7319
https://jira.jboss.org/browse/JBIDE-7319
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidatorContext.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidatorContext.java 2010-10-12
15:29:08 UTC (rev 25750)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidatorContext.java 2010-10-12
15:34:12 UTC (rev 25751)
@@ -46,14 +46,18 @@
// save linked ELs.
// don't save links if there are more than 500 ELs for the var name.
if(linkedEls.size()<500) {
- linkedEls.add(el);
+ if(linkedEls.add(el)) {
+ modifications++;
+ }
// Save link between EL and variable names.
Set<String> variableNames = variableNamesByEl.get(el);
if(variableNames==null) {
variableNames = new HashSet<String>();
variableNamesByEl.put(el, variableNames);
}
- variableNames.add(variableName);
+ if(variableNames.add(variableName)) {
+ modifications++;
+ }
}
// Save link between EL and resource.
@@ -62,7 +66,9 @@
els = new HashSet<ELReference>();
elsByResource.put(el.getPath(), els);
}
- els.add(el);
+ if(els.add(el)) {
+ modifications++;
+ }
}
public synchronized void removeLinkedEls(Set<IFile> resorces) {
@@ -74,7 +80,9 @@
public synchronized void removeLinkedEls(IFile resource) {
Set<ELReference> els = elsByResource.get(resource.getFullPath());
if(els!=null) {
- elsByResource.remove(resource.getFullPath());
+ if(elsByResource.remove(resource.getFullPath()) != null) {
+ modifications++;
+ }
for (ELReference el : els) {
Set<String> names = variableNamesByEl.get(el);
if(names!=null) {
@@ -95,7 +103,9 @@
public synchronized void removeLinkedEl(String name, ELReference el) {
Set<ELReference> linkedEls = elsByVariableName.get(name);
if(linkedEls!=null) {
- linkedEls.remove(el);
+ if(linkedEls.remove(el)) {
+ modifications++;
+ }
}
if(linkedEls.isEmpty()) {
elsByVariableName.remove(name);
@@ -104,7 +114,9 @@
// Remove link between EL and variable names.
Set<String> variableNames = variableNamesByEl.get(el);
if(variableNames!=null) {
- variableNames.remove(name);
+ if(variableNames.remove(name)) {
+ modifications++;
+ }
}
if(variableNames.isEmpty()) {
variableNamesByEl.remove(el);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/LinkCollection.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/LinkCollection.java 2010-10-12
15:29:08 UTC (rev 25750)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/LinkCollection.java 2010-10-12
15:34:12 UTC (rev 25751)
@@ -31,6 +31,8 @@
protected Map<IPath, Set<String>> declaringVariableNamesByResource = new
HashMap<IPath, Set<String>>();
protected Set<IPath> unnamedResources = new HashSet<IPath>();
+ protected int modifications = 0;
+
/**
* Save link between resource and variable name.
* It's needed for incremental validation because we must save all linked resources
of changed java file.
@@ -51,7 +53,9 @@
resourcesByVariableName.put(variableName, linkedResources);
}
// save linked resources.
- linkedResources.add(linkedResourcePath);
+ if(linkedResources.add(linkedResourcePath)) {
+ modifications++;
+ }
}
// Save link between resource and variable names. It's needed if variable name
changes in resource file.
@@ -60,7 +64,9 @@
variableNames = new HashSet<String>();
variableNamesByResource.put(linkedResourcePath, variableNames);
}
- variableNames.add(variableName);
+ if(variableNames.add(variableName)) {
+ modifications++;
+ }
if(declaration) {
synchronized(this) {
@@ -71,7 +77,9 @@
resourcesByDeclaringVariableName.put(variableName, linkedResources);
}
// save linked resources.
- linkedResources.add(linkedResourcePath);
+ if(linkedResources.add(linkedResourcePath)) {
+ modifications++;
+ }
}
// Save link between resource and declaring variable names. It's needed if
variable name changes in resource file.
@@ -80,7 +88,9 @@
variableNames = new HashSet<String>();
declaringVariableNamesByResource.put(linkedResourcePath, variableNames);
}
- variableNames.add(variableName);
+ if(variableNames.add(variableName)) {
+ modifications++;
+ }
}
}
@@ -94,7 +104,9 @@
Set<IPath> linkedResources = resourcesByVariableName.get(name);
if(linkedResources!=null) {
// remove linked resource.
- linkedResources.remove(linkedResourcePath);
+ if(linkedResources.remove(linkedResourcePath)) {
+ modifications++;
+ }
}
if(linkedResources.isEmpty()) {
resourcesByVariableName.remove(name);
@@ -103,7 +115,9 @@
// Remove link between resource and declaring variable names.
Set<String> variableNames = variableNamesByResource.get(linkedResourcePath);
if(variableNames!=null) {
- variableNames.remove(name);
+ if(variableNames.remove(name)) {
+ modifications++;
+ }
}
if(variableNames.isEmpty()) {
variableNamesByResource.remove(linkedResourcePath);
@@ -112,7 +126,9 @@
Set<IPath> linkedResources = resourcesByDeclaringVariableName.get(name);
if(linkedResources!=null) {
// remove linked resource.
- linkedResources.remove(linkedResourcePath);
+ if(linkedResources.remove(linkedResourcePath)) {
+ modifications++;
+ }
}
if(linkedResources.isEmpty()) {
resourcesByDeclaringVariableName.remove(name);
@@ -121,7 +137,9 @@
// Remove link between resource and declaring variable names.
variableNames = declaringVariableNamesByResource.get(linkedResourcePath);
if(variableNames!=null) {
- variableNames.remove(name);
+ if(variableNames.remove(name)) {
+ modifications++;
+ }
}
if(variableNames.isEmpty()) {
declaringVariableNamesByResource.remove(linkedResourcePath);
@@ -148,28 +166,36 @@
for (String name : resourceNames) {
Set<IPath> linkedResources = resourcesByVariableName.get(name);
if(linkedResources!=null) {
- linkedResources.remove(resource);
+ if(linkedResources.remove(resource)) {
+ modifications++;
+ }
if(linkedResources.isEmpty()) {
resourcesByVariableName.remove(name);
}
}
}
}
- variableNamesByResource.remove(resource);
+ if(variableNamesByResource.remove(resource) != null) {
+ modifications++;
+ }
resourceNames = declaringVariableNamesByResource.get(resource);
if(resourceNames!=null) {
for (String name : resourceNames) {
Set<IPath> linkedResources = resourcesByDeclaringVariableName.get(name);
if(linkedResources!=null) {
- linkedResources.remove(resource);
+ if(linkedResources.remove(resource)) {
+ modifications++;
+ }
if(linkedResources.isEmpty()) {
resourcesByDeclaringVariableName.remove(name);
}
}
}
}
- declaringVariableNamesByResource.remove(resource);
+ if(declaringVariableNamesByResource.remove(resource) != null) {
+ modifications++;
+ }
}
public Set<IPath> getResourcesByVariableName(String variableName, boolean
declaration) {
@@ -185,7 +211,9 @@
* @param fullPath
*/
public void addUnnamedResource(IPath fullPath) {
- unnamedResources.add(fullPath);
+ if(unnamedResources.add(fullPath)) {
+ modifications++;
+ }
}
/**
@@ -201,7 +229,9 @@
* @param fullPath
*/
public void removeUnnamedResource(IPath fullPath) {
- unnamedResources.remove(fullPath);
+ if(unnamedResources.remove(fullPath)) {
+ modifications++;
+ }
}
/**
@@ -213,6 +243,7 @@
declaringVariableNamesByResource.clear();
resourcesByDeclaringVariableName.clear();
unnamedResources.clear();
+ modifications = 0;
}
/**
@@ -237,6 +268,7 @@
Element unnamedPathElement = XMLUtilities.createElement(root,
"unnamed-path"); //$NON-NLS-1$
unnamedPathElement.setAttribute("path", unnamedPath.toString());
//$NON-NLS-1$
}
+ modifications = 0;
}
private boolean checkDeclaration(IPath resource, String variableName) {
@@ -273,5 +305,10 @@
IPath pathObject = new Path(path);
addUnnamedResource(pathObject);
}
+ modifications = 0;
}
+
+ public int getModificationsSinceLastStore() {
+ return modifications;
+ }
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ProjectValidationContext.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ProjectValidationContext.java 2010-10-12
15:29:08 UTC (rev 25750)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ProjectValidationContext.java 2010-10-12
15:34:12 UTC (rev 25751)
@@ -39,6 +39,8 @@
private Set<IFile> registeredResources = new HashSet<IFile>();
private Set<String> oldVariableNamesForELValidation = new
HashSet<String>();
+ int modifications = 0;
+
/*
* (non-Javadoc)
* @see
org.jboss.tools.jst.web.kb.validation.IValidationContext#addLinkedCoreResource(java.lang.String,
org.eclipse.core.runtime.IPath, boolean)
@@ -268,6 +270,7 @@
coreLinks.store(core);
Element el = XMLUtilities.createElement(validation, "el"); //$NON-NLS-1$
elLinks.store(el);
+ modifications = 0;
}
/*
@@ -285,6 +288,7 @@
if(el != null) {
elLinks.load(el);
}
+ modifications = 0;
}
/*
@@ -321,7 +325,10 @@
*/
public void registerFile(IFile file) {
synchronized (registeredResources) {
- registeredResources.add(file);
+ if(!registeredResources.contains(file)) {
+ registeredResources.add(file);
+ modifications++;
+ }
}
}
@@ -340,4 +347,8 @@
public List<IValidator> getValidators() {
return null;
}
+
+ public int getModificationsSinceLastStore() {
+ return modifications + coreLinks.getModificationsSinceLastStore() +
elLinks.getModificationsSinceLastStore();
+ }
}
\ No newline at end of file