[jbosstools-commits] JBoss Tools SVN: r30621 - in branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb: validation and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Fri Apr 15 20:50:34 EDT 2011


Author: akazakov
Date: 2011-04-15 20:50:33 -0400 (Fri, 15 Apr 2011)
New Revision: 30621

Modified:
   branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ContextValidationHelper.java
   branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java
   branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/SimpleValidatingProjectTree.java
   branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidationContext.java
   branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidationResourceRegister.java
   branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatorManager.java
   branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidationContextManager.java
Log:
https://issues.jboss.org/browse/JBIDE-8726

Modified: branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ContextValidationHelper.java
===================================================================
--- branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ContextValidationHelper.java	2011-04-16 00:31:01 UTC (rev 30620)
+++ branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ContextValidationHelper.java	2011-04-16 00:50:33 UTC (rev 30621)
@@ -22,6 +22,7 @@
 import org.eclipse.core.runtime.Path;
 import org.eclipse.ui.editors.text.TextFileDocumentProvider;
 import org.eclipse.wst.validation.internal.operations.WorkbenchContext;
+import org.eclipse.wst.validation.internal.operations.WorkbenchReporter;
 import org.jboss.tools.jst.web.kb.validation.IValidatingProjectTree;
 import org.jboss.tools.jst.web.kb.validation.IValidationContextManager;
 import org.jboss.tools.jst.web.kb.validation.IValidator;
@@ -41,6 +42,34 @@
 	 */
 	@Override
 	public void initialize() {
+		super.initialize();
+		cleanup();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.wst.validation.internal.operations.WorkbenchContext#deleting()
+	 */
+	@Override
+	public void deleting() {
+		super.deleting();
+		cleanup();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.wst.validation.internal.operations.WorkbenchContext#cleanup(org.eclipse.wst.validation.internal.operations.WorkbenchReporter)
+	 */
+	@Override
+	public void cleanup(WorkbenchReporter reporter) {
+		super.cleanup(reporter);
+		cleanup();
+	}
+
+	public void cleanup() {
+		if(validationContextManager!=null) {
+			validationContextManager.setValidationResourceRegister(null);
+		}
 		validationContextManager = null;
 	}
 
@@ -54,6 +83,8 @@
 			IFile file = (IFile)resource;
 			if(validationContextManager == null) {
 				validationContextManager = new ValidationContext(file.getProject());
+			} else if(validationContextManager.isObsolete()) {
+				validationContextManager.init(file.getProject()); // https://issues.jboss.org/browse/JBIDE-8726
 			}
 			validationContextManager.addProject(file.getProject());
 			if(!file.exists()) {
@@ -89,7 +120,7 @@
 
 	public Set<IFile> getProjectSetRegisteredFiles() {
 		Set<IFile> result = new HashSet<IFile>();
-		Set<IFile> files = validationContextManager.getRegisteredFiles();
+		Set<IFile> files = getValidationContextManager().getRegisteredFiles();
 		Set<IProject> projects = getAllProjects();
 		for (IFile file : files) {
 			if(projects.contains(file.getProject())) {
@@ -110,6 +141,13 @@
 	}
 
 	public IValidationContextManager getValidationContextManager() {
+		return getValidationContextManager(true);
+	}
+
+	public IValidationContextManager getValidationContextManager(boolean initialize) {
+		if(!initialize) {
+			return validationContextManager;
+		}
 		if(validationContextManager==null) {
 			validationContextManager = new ValidationContext(getProject());
 		}

Modified: branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java
===================================================================
--- branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java	2011-04-16 00:31:01 UTC (rev 30620)
+++ branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java	2011-04-16 00:50:33 UTC (rev 30621)
@@ -396,6 +396,9 @@
 				c.setAllVars(vars);
 			}
 
+			if(resolution==null) {
+				return;
+			}
 			if(!resolution.isResolved()) {
 				Set<String> names = findVariableNames(operandToken);
 				for (String name : names) {

Modified: branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/SimpleValidatingProjectTree.java
===================================================================
--- branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/SimpleValidatingProjectTree.java	2011-04-16 00:31:01 UTC (rev 30620)
+++ branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/SimpleValidatingProjectTree.java	2011-04-16 00:50:33 UTC (rev 30621)
@@ -79,7 +79,7 @@
 		if(project!=null && !validatingProjects.contains(project)) {
 			Set<IProject> allProjects = new HashSet<IProject>();
 			allProjects.add(project);
-			IValidatingProjectSet brunch = new ValidatingProjectSet(project, allProjects, new ProjectValidationContext());
+			brunch = new ValidatingProjectSet(project, allProjects, new ProjectValidationContext());
 			brunches.put(brunch.getRootProject(), brunch);
 			validatingProjects.add(project);
 		}

Modified: branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidationContext.java
===================================================================
--- branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidationContext.java	2011-04-16 00:31:01 UTC (rev 30620)
+++ branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidationContext.java	2011-04-16 00:50:33 UTC (rev 30621)
@@ -44,6 +44,13 @@
 	private Map<IValidator, Set<IProject>> validatedProjects = new HashMap<IValidator, Set<IProject>>();
 
 	public ValidationContext(IProject project) {
+		init(project);
+	}
+
+	public void init(IProject project) {
+		projectTree.clear();
+		validators.clear();
+		validationResourceRegister = null;
 		if(ALL_VALIDATORS == null) {
 			// Load all the validators
 			ALL_VALIDATORS = new ArrayList<IValidator>();
@@ -84,6 +91,14 @@
 		}
 	}
 
+	/*
+	 * (non-Javadoc)
+	 * @see org.jboss.tools.jst.web.kb.validation.IValidationContextManager#isObsolete()
+	 */
+	public boolean isObsolete() {
+		return validationResourceRegister!=null && validationResourceRegister.isObsolete();
+	}
+
 	private ValidationResourceRegister getValidationResourceRegister() {
 		if(validationResourceRegister==null && !projectTree.isEmpty()) {
 			// Initialize the register
@@ -118,6 +133,15 @@
 
 	/*
 	 * (non-Javadoc)
+	 * @see org.jboss.tools.jst.web.kb.validation.IValidationContextManager#setValidationResourceRegister(org.jboss.tools.jst.web.kb.internal.validation.ValidationResourceRegister)
+	 */
+	public void setValidationResourceRegister(
+			ValidationResourceRegister validationResourceRegister) {
+		this.validationResourceRegister = validationResourceRegister;
+	}
+
+	/*
+	 * (non-Javadoc)
 	 * @see org.jboss.tools.jst.web.kb.validation.IValidationContext#getValidators()
 	 */
 	public List<IValidator> getValidators() {

Modified: branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidationResourceRegister.java
===================================================================
--- branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidationResourceRegister.java	2011-04-16 00:31:01 UTC (rev 30620)
+++ branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidationResourceRegister.java	2011-04-16 00:50:33 UTC (rev 30621)
@@ -21,6 +21,7 @@
 public class ValidationResourceRegister {
 	private Set<IFile> removedFiles = new HashSet<IFile>();
 	private Set<IFile> registeredResources = new HashSet<IFile>();
+	private boolean obsolete = false;
 
 	public void clear() {
 		synchronized (removedFiles) {
@@ -29,6 +30,7 @@
 		synchronized (registeredResources) {
 			registeredResources.clear();
 		}
+		obsolete = true;
 	}
 
 	public Set<IFile> getRemovedFiles() {
@@ -48,8 +50,16 @@
 	}
 
 	public void registerFile(IFile file) {
+		obsolete = false;
 		synchronized (registeredResources) {
 			registeredResources.add(file);
 		}
 	}
+
+	/**
+	 * @return the obsolete
+	 */
+	public boolean isObsolete() {
+		return obsolete;
+	}
 }
\ No newline at end of file

Modified: branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatorManager.java
===================================================================
--- branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatorManager.java	2011-04-16 00:31:01 UTC (rev 30620)
+++ branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ValidatorManager.java	2011-04-16 00:50:33 UTC (rev 30621)
@@ -90,6 +90,7 @@
 					if(validationContextManager!=null) {
 						validationContextManager.clearRegisteredFiles();
 					}
+					validationHelper.cleanup(); // See https://issues.jboss.org/browse/JBIDE-8726
 					for (IProject rootProject : rootProjects) {
 						validatingProjects.remove(rootProject);
 					}

Modified: branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidationContextManager.java
===================================================================
--- branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidationContextManager.java	2011-04-16 00:31:01 UTC (rev 30620)
+++ branches/jbosstools-3.2.x/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/validation/IValidationContextManager.java	2011-04-16 00:50:33 UTC (rev 30621)
@@ -15,6 +15,7 @@
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
+import org.jboss.tools.jst.web.kb.internal.validation.ValidationResourceRegister;
 
 /**
  * @author Alexey Kazakov
@@ -39,7 +40,16 @@
 
 	void registerFile(IFile file);
 
+	void init(IProject project);
+
 	/**
+	 * If the context is obsolete then it should be re-initialized.
+	 * See https://issues.jboss.org/browse/JBIDE-8726
+	 * @return
+	 */
+	boolean isObsolete();
+
+	/**
 	 * @return a list of validators which are associated with this context.
 	 */
 	List<IValidator> getValidators();
@@ -51,4 +61,6 @@
 	boolean projectHasBeenValidated(IValidator validator, IProject project);
 
 	void clearValidatedProjectsList();
+
+	void setValidationResourceRegister(ValidationResourceRegister validationResourceRegister);
 }
\ No newline at end of file



More information about the jbosstools-commits mailing list