Author: akazakov
Date: 2009-07-03 16:54:55 -0400 (Fri, 03 Jul 2009)
New Revision: 16379
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ELReference.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ELValidatorContext.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ISeamValidationContext.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/LinkCollection.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ProjectValidationContext.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationContext.java
Removed:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationContext.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.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/validation/IValidationErrorManager.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamContextValidationHelper.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidatorManager.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ValidationErrorManager.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4545 Fixed
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2009-07-03 10:34:22 UTC (rev
16378)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2009-07-03 20:54:55 UTC (rev
16379)
@@ -331,9 +331,6 @@
incremental="true"
fullBuild="true"
/>
- <dependentValidator
- depValValue="true">
- </dependentValidator>
</validator>
</extension>
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java 2009-07-03
10:34:22 UTC (rev 16378)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java 2009-07-03
20:54:55 UTC (rev 16379)
@@ -18,6 +18,7 @@
import org.eclipse.core.runtime.IPath;
import org.jboss.tools.seam.core.event.ISeamProjectChangeListener;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
+import org.jboss.tools.seam.internal.core.validation.ISeamValidationContext;
public interface ISeamProject extends ISeamElement {
@@ -143,6 +144,11 @@
public ISeamComponent[] getComponents();
/**
+ * @return validation context
+ */
+ public ISeamValidationContext getValidationContext();
+
+ /**
* Adds component into project
* @param component
*/
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 2009-07-03
10:34:22 UTC (rev 16378)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2009-07-03
20:54:55 UTC (rev 16379)
@@ -62,7 +62,7 @@
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
import org.jboss.tools.seam.internal.core.scanner.lib.ClassPath;
-import org.jboss.tools.seam.internal.core.validation.SeamValidationContext;
+import org.jboss.tools.seam.internal.core.validation.ProjectValidationContext;
import org.osgi.service.prefs.BackingStoreException;
import org.w3c.dom.Element;
@@ -106,7 +106,7 @@
List<ISeamProjectChangeListener> listeners = new
ArrayList<ISeamProjectChangeListener>();
- SeamValidationContext validationContext;
+ ProjectValidationContext validationContext;
/**
*
@@ -743,13 +743,14 @@
File f = getStorageFile();
return f == null || !f.isFile();
}
- /**
- *
- * @return
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.core.ISeamProject#getValidationContext()
*/
- public SeamValidationContext getValidationContext() {
+ public ProjectValidationContext getValidationContext() {
if(validationContext==null) {
- validationContext = new SeamValidationContext();
+ validationContext = new ProjectValidationContext();
}
return validationContext;
}
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ELReference.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ELReference.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ELReference.java 2009-07-03
20:54:55 UTC (rev 16379)
@@ -0,0 +1,313 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core.validation;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.jboss.tools.common.el.core.model.ELExpression;
+import org.jboss.tools.common.el.core.model.ELInstance;
+import org.jboss.tools.common.el.core.model.ELModel;
+import org.jboss.tools.common.el.core.parser.ELParser;
+import org.jboss.tools.common.el.core.parser.ELParserUtil;
+import org.jboss.tools.common.el.core.parser.SyntaxError;
+import org.jboss.tools.common.el.core.resolver.ElVarSearcher;
+import org.jboss.tools.common.model.project.ext.ITextSourceReference;
+import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.internal.core.el.SeamELCompletionEngine;
+import org.w3c.dom.Element;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class ELReference implements ITextSourceReference {
+
+ private static SeamELCompletionEngine elEngine = new SeamELCompletionEngine();
+
+ private IFile resource;
+ private IPath path;
+ private int length;
+ private int startPosition;
+ private ELExpression[] el;
+ private ElVarSearcher varSearcher;
+ private Set<IMarker> markers;
+ private IMarker[] markerArray;
+ private boolean needToInitMarkers = false;
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.core.ISeamTextSourceReference#getLength()
+ */
+ public int getLength() {
+ return length;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.core.ISeamTextSourceReference#getStartPosition()
+ */
+ public int getStartPosition() {
+ return startPosition;
+ }
+
+ /**
+ * @param length
+ */
+ public void setLength(int length) {
+ this.length = length;
+ }
+
+ /**
+ * @param startPosition
+ */
+ public void setStartPosition(int startPosition) {
+ this.startPosition = startPosition;
+ }
+
+ /**
+ * @return the resource
+ */
+ public IFile getResource() {
+ if(resource==null) {
+ IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
+ resource = wsRoot.getFile(path);
+ }
+ return resource;
+ }
+
+ /**
+ * @param resource the resource to set
+ */
+ public void setResource(IFile resource) {
+ this.resource = resource;
+ if(resource!=null) {
+ this.path = resource.getFullPath();
+ }
+ }
+
+ /**
+ * @return the path
+ */
+ public IPath getPath() {
+ return path;
+ }
+
+ /**
+ * @param path the path to set
+ */
+ public void setPath(IPath path) {
+ this.path = path;
+ }
+
+ /**
+ * @return the el
+ */
+ public ELExpression[] getEl() {
+ if(el==null) {
+ Set<ELExpression> exps = new HashSet<ELExpression>();
+ try {
+ String content = FileUtil.readStream(getResource().getContents());
+ String elText = content.substring(startPosition, startPosition + length);
+ int startEl = elText.indexOf("#{"); //$NON-NLS-1$
+ if(startEl>-1) {
+ ELParser parser = ELParserUtil.getJbossFactory().createParser();
+ ELModel model = parser.parse(elText);
+ List<SyntaxError> errors = model.getSyntaxErrors();
+ if(!errors.isEmpty()) {
+ SeamCorePlugin.getDefault().logWarning("ELObject hold incorrect information.
Maybe resource " + getResource() + " has been changed.");
+ return null;
+ }
+ List<ELInstance> is = model.getInstances();
+ for (ELInstance i : is) {
+ if(!i.getErrors().isEmpty()) {
+ SeamCorePlugin.getDefault().logWarning("ELObject hold incorrect information.
Maybe resource " + getResource() + " has been changed.");
+ continue;
+ }
+ exps.add(i.getExpression());
+ }
+ }
+ } catch (CoreException e) {
+ SeamCorePlugin.getDefault().logError(e);
+ }
+ el = exps.toArray(new ELExpression[0]);
+ }
+ return el;
+ }
+
+ /**
+ * @param el the el to set
+ */
+ public void setEl(ELExpression[] el) {
+ this.el = el;
+ }
+
+ /**
+ * @param insts
+ */
+ public void setEl(List<ELInstance> insts) {
+ Set<ELExpression> exps = new HashSet<ELExpression>();
+ for (ELInstance el : insts) {
+ exps.add(el.getExpression());
+ }
+ el = exps.toArray(new ELExpression[0]);
+ }
+
+ /**
+ * @return the varSearcher
+ */
+ public ElVarSearcher getVarSearcher() {
+ if(varSearcher == null) {
+ varSearcher = new ElVarSearcher(getResource(), elEngine);
+ }
+ return varSearcher;
+ }
+
+ /**
+ * @param varSearcher the varSearcher to set
+ */
+ public void setVarSearcher(ElVarSearcher varSearcher) {
+ this.varSearcher = varSearcher;
+ }
+
+ private IMarker[] EMPTY_MARKER_ARRAY = new IMarker[0];
+
+ private void initMarkers() {
+ if(markers==null) {
+ markers = new HashSet<IMarker>();
+ if(needToInitMarkers) {
+ IFile file = getResource();
+ if(file!=null) {
+ IMarker[] markers = null;
+ try {
+ markers = file.findMarkers(null, true, IResource.DEPTH_INFINITE);
+ } catch (CoreException e) {
+ SeamCorePlugin.getDefault().logError(e);
+ }
+ for(int i=0; i<markers.length; i++){
+ String groupName = markers[i].getAttribute("groupName", null);
//$NON-NLS-1$
+ if(groupName!=null &&
(groupName.equals(groupName.equals(ISeamValidator.MARKED_SEAM_RESOURCE_MESSAGE_GROUP))))
{
+ int start = markers[i].getAttribute(IMarker.CHAR_START, -1);
+ int end = markers[i].getAttribute(IMarker.CHAR_END, -1);
+ if(start>=startPosition && end<=startPosition+length) {
+ addMarker(markers[i]);
+ }
+ }
+ }
+ }
+ }
+ needToInitMarkers = false;
+ }
+ }
+
+ /**
+ * @param needToInitMarkers the needToInitMarkers to set
+ */
+ public synchronized void setNeedToInitMarkers(boolean needToInitMarkers) {
+ this.needToInitMarkers = needToInitMarkers;
+ }
+
+ public synchronized void setMarkers(Set<IMarker> markers) {
+ this.markers = markers;
+ }
+
+ /**
+ * @return the markers
+ */
+ public synchronized IMarker[] getMarkers() {
+ initMarkers();
+ if(markerArray==null) {
+ if(markers.isEmpty()) {
+ markerArray = EMPTY_MARKER_ARRAY;
+ } else {
+ markerArray = markers.toArray(new IMarker[0]);
+ }
+ }
+ return markerArray;
+ }
+
+ /**
+ * @param markers the markers to set
+ */
+ public synchronized void addMarker(IMarker marker) {
+ if(marker==null) {
+ return;
+ }
+ markerArray = null;
+ if(markers==null) {
+ markers = new HashSet<IMarker>();
+ }
+ markers.add(marker);
+ }
+
+ /**
+ * Removes all markers from this EL.
+ */
+ public synchronized void deleteMarkers() {
+ initMarkers();
+ for (IMarker marker : markers) {
+ try {
+ marker.delete();
+ } catch (CoreException e) {
+ SeamCorePlugin.getDefault().logError(e);
+ }
+ }
+ markers.clear();
+ markerArray = null;
+ }
+
+ /**
+ * Store this EL into XML element.
+ * @param element
+ */
+ public synchronized void store(Element element) {
+ element.setAttribute("path", path.toString()); //$NON-NLS-1$
+ element.setAttribute("offset", "" + startPosition); //$NON-NLS-1$
//$NON-NLS-2$
+ element.setAttribute("length", "" + length); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+ /**
+ * Load this EL from XML element.
+ * @param element
+ */
+ public synchronized void load(Element element) {
+ path = new Path(element.getAttribute("path")); //$NON-NLS-1$
+ startPosition = new Integer(element.getAttribute("offset")); //$NON-NLS-1$
+ length = new Integer(element.getAttribute("length")); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if(this == obj) {
+ return true;
+ }
+ ELReference el = (ELReference)obj;
+ return this.path.equals(el.path) && this.startPosition == el.startPosition;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return path.hashCode() + startPosition;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ELReference.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ELValidatorContext.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ELValidatorContext.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ELValidatorContext.java 2009-07-03
20:54:55 UTC (rev 16379)
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core.validation;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.jboss.tools.common.xml.XMLUtilities;
+import org.w3c.dom.Element;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class ELValidatorContext extends LinkCollection {
+
+ private Map<String, Set<ELReference>> elsByVariableName = new
HashMap<String, Set<ELReference>>();
+ private Map<ELReference, Set<String>> variableNamesByEl = new
HashMap<ELReference, Set<String>>();
+ private Map<IPath, Set<ELReference>> elsByResource = new HashMap<IPath,
Set<ELReference>>();
+
+ /**
+ * Save link between EL and variable name.
+ * @param variableName
+ * @param el
+ */
+ public synchronized void addLinkedEl(String variableName, ELReference el) {
+ Set<ELReference> linkedEls = elsByVariableName.get(variableName);
+ if(linkedEls==null) {
+ // create set of linked ELs with variable name.
+ linkedEls = new HashSet<ELReference>();
+ elsByVariableName.put(variableName, linkedEls);
+ }
+ // save linked ELs.
+ linkedEls.add(el);
+
+ // 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);
+
+ // Save link between EL and resource.
+ Set<ELReference> els = elsByResource.get(el.getPath());
+ if(els==null) {
+ els = new HashSet<ELReference>();
+ elsByResource.put(el.getPath(), els);
+ }
+ els.add(el);
+ }
+
+ public synchronized void removeLinkedEls(Set<IFile> resorces) {
+ for (IFile file : resorces) {
+ removeLinkedEls(file);
+ }
+ }
+
+ public synchronized void removeLinkedEls(IFile resource) {
+ Set<ELReference> els = elsByResource.get(resource.getFullPath());
+ if(els!=null) {
+ elsByResource.remove(resource.getFullPath());
+ for (ELReference el : els) {
+ Set<String> names = variableNamesByEl.get(el);
+ if(names!=null) {
+ String[] nameStrins = names.toArray(new String[0]);
+ for (int i = 0; i < nameStrins.length; i++) {
+ removeLinkedEl(nameStrins[i], el);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Removes link between EL and variable name.
+ * @param name
+ * @param el
+ */
+ public synchronized void removeLinkedEl(String name, ELReference el) {
+ Set<ELReference> linkedEls = elsByVariableName.get(name);
+ if(linkedEls!=null) {
+ linkedEls.remove(el);
+ }
+ if(linkedEls.isEmpty()) {
+ elsByVariableName.remove(name);
+ }
+
+ // Remove link between EL and variable names.
+ Set<String> variableNames = variableNamesByEl.get(el);
+ if(variableNames!=null) {
+ variableNames.remove(name);
+ }
+ if(variableNames.isEmpty()) {
+ variableNamesByEl.remove(el);
+ }
+ }
+
+ /**
+ * Return ELs with given variable name
+ * @param variableName
+ * @return
+ */
+ public synchronized Set<ELReference> getElsByVariableName(String variableName) {
+ return elsByVariableName.get(variableName);
+ }
+
+ /**
+ * @param names
+ * @return
+ */
+ public synchronized Set<ELReference> getElsByVariableNames(Set<String>
names) {
+ Set<ELReference> result = new HashSet<ELReference>();
+ for(String name : names) {
+ Set<ELReference> els = getElsByVariableName(name);
+ if(els!=null) {
+ result.addAll(els);
+ }
+ }
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.internal.core.validation.LinkCollection#clearAll()
+ */
+ @Override
+ public synchronized void clearAll() {
+ super.clearAll();
+ elsByVariableName.clear();
+ variableNamesByEl.clear();
+ elsByResource.clear();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.LinkCollection#store(org.w3c.dom.Element)
+ */
+ @Override
+ public synchronized void store(Element root) {
+ super.store(root);
+ Set<String> variables = elsByVariableName.keySet();
+ for (String name: variables) {
+ Set<ELReference> els = elsByVariableName.get(name);
+ if(els == null) {
+ continue;
+ }
+ for (ELReference el: els) {
+ Element linkedEl = XMLUtilities.createElement(root, "linked-el");
//$NON-NLS-1$
+ linkedEl.setAttribute("name", name); //$NON-NLS-1$
+ el.store(linkedEl);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.LinkCollection#load(org.w3c.dom.Element)
+ */
+ @Override
+ public synchronized void load(Element root) {
+ super.load(root);
+ if(root == null) {
+ return;
+ }
+ Element[] linkedEls = XMLUtilities.getChildren(root, "linked-el");
//$NON-NLS-1$
+ if(linkedEls != null) {
+ for (int i = 0; i < linkedEls.length; i++) {
+ String name = linkedEls[i].getAttribute("name"); //$NON-NLS-1$
+ if(name == null || name.trim().length() == 0) {
+ continue;
+ }
+ ELReference el = new ELReference();
+ el.load(linkedEls[i]);
+ el.setNeedToInitMarkers(true);
+ addLinkedEl(name, el);
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ELValidatorContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ISeamValidationContext.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ISeamValidationContext.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ISeamValidationContext.java 2009-07-03
20:54:55 UTC (rev 16379)
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core.validation;
+
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.w3c.dom.Element;
+
+/**
+ * Contains information for seam validators that must be saved between
+ * validation invoking.
+ * @author Alexey Kazakov
+ */
+public interface ISeamValidationContext {
+
+ /**
+ * Save link between core resource and variable name.
+ * It's needed for incremental validation because we must save all linked resources
of changed java file.
+ */
+ void addLinkedCoreResource(String variableName, IPath linkedResourcePath, boolean
declaration);
+
+ /**
+ * Removes link between core resource and variable name.
+ * @param oldVariableName
+ * @param linkedResourcePath
+ */
+ void removeLinkedCoreResource(String name, IPath linkedResourcePath);
+
+ /**
+ * Removes link between core resources and variable names.
+ * @param linkedResources
+ */
+ void removeLinkedCoreResources(Set<IPath> resources);
+
+ /**
+ * Removes link between core resource and variable names.
+ * @param linkedResource
+ */
+ void removeLinkedCoreResource(IPath resource);
+
+ Set<IPath> getCoreResourcesByVariableName(String variableName, boolean
declaration);
+
+ Set<String> getVariableNamesByCoreResource(IPath fullPath, boolean declaration);
+
+ /**
+ * Adds core resource without any link to any context variable name.
+ * @param fullPath
+ */
+ void addUnnamedCoreResource(IPath fullPath);
+
+ /**
+ * @return Set of coreresources without any link to any context variable name.
+ * @param fullPath
+ */
+ Set<IPath> getUnnamedCoreResources();
+
+ /**
+ * Removes unnamed EL resource.
+ * @param fullPath
+ */
+ void removeUnnamedCoreResource(IPath fullPath);
+
+ /**
+ * Adds EL resource without any link to any context variable name.
+ * @param fullPath
+ */
+ void addUnnamedElResource(IPath fullPath);
+
+ /**
+ * @return Set of EL resources without any link to any context variable name.
+ * @param fullPath
+ */
+ Set<IPath> getUnnamedElResources();
+
+ /**
+ * Removes unnamed EL resource.
+ * @param fullPath
+ */
+ void removeUnnamedElResource(IPath fullPath);
+
+ /**
+ * We should validate all EL resources which use these names.
+ * @param name
+ */
+ void addVariableNameForELValidation(String name);
+
+ void removeLinkedEls(Set<IFile> resorces);
+
+ /**
+ * Get ELs which should be validated
+ * @param changedFiles
+ * @param onlyChangedVariables
+ * @return
+ */
+ Set<ELReference> getElsForValidation(Set<IFile> changedFiles, boolean
onlyChangedVariables);
+
+ void clearAll();
+
+ void clearAllResourceLinks();
+
+ void clearRegisteredFiles();
+
+ void clearElResourceLinks();
+
+ void clearOldVariableNameForElValidation();
+
+ /**
+ * Save link between EL and variable name.
+ * @param variableName
+ * @param el
+ */
+ void addLinkedEl(String variableName, ELReference el);
+
+ /**
+ * Removes link between EL and variable name.
+ * @param name
+ * @param el
+ */
+ void removeLinkedEl(String name, ELReference el);
+
+ /**
+ * Return ELs with given variable name
+ * @param variableName
+ * @return
+ */
+ Set<ELReference> getElsByVariableName(String variableName);
+
+ /**
+ * Stores context to XML element
+ * @param root
+ */
+ void store(Element root);
+
+ /**
+ * Loads context from XML element
+ * @param root
+ */
+ void load(Element root);
+
+ Set<IFile> getRemovedFiles();
+
+ void addRemovedFile(IFile file);
+
+ Set<IFile> getRegisteredFiles();
+
+ void registerFile(IFile file);
+}
\ No newline at end of file
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ISeamValidationContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/IValidationErrorManager.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/IValidationErrorManager.java 2009-07-03
10:34:22 UTC (rev 16378)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/IValidationErrorManager.java 2009-07-03
20:54:55 UTC (rev 16379)
@@ -12,8 +12,8 @@
import java.util.Set;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
-import org.eclipse.wst.validation.internal.operations.WorkbenchReporter;
import org.jboss.tools.common.model.project.ext.ITextSourceReference;
import org.jboss.tools.seam.core.ISeamProject;
@@ -30,7 +30,7 @@
* @param location
* @param target
*/
- void addError(String messageId, String preferenceKey,
+ IMarker addError(String messageId, String preferenceKey,
String[] messageArguments, ITextSourceReference location,
IResource target);
@@ -41,7 +41,7 @@
* @param messageArguments
* @param target
*/
- void addError(String messageId, String preferenceKey,
+ IMarker addError(String messageId, String preferenceKey,
String[] messageArguments,
IResource target);
@@ -52,7 +52,7 @@
* @param location
* @param target
*/
- void addError(String messageId, String preferenceKey,
+ IMarker addError(String messageId, String preferenceKey,
ITextSourceReference location, IResource target);
/**
@@ -64,7 +64,7 @@
* @param offset
* @param target
*/
- void addError(String messageId, String preferenceKey,
+ IMarker addError(String messageId, String preferenceKey,
String[] messageArguments, int length, int offset, IResource target);
/**
@@ -76,7 +76,7 @@
* @param offset
* @param target
*/
- void addError(String messageId, int severity, String[] messageArguments, int length, int
offset, IResource target);
+ IMarker addError(String messageId, int severity, String[] messageArguments, int length,
int offset, IResource target);
/**
* Displays a subtask in the progress view.
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/LinkCollection.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/LinkCollection.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/LinkCollection.java 2009-07-03
20:54:55 UTC (rev 16379)
@@ -0,0 +1,277 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core.validation;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.jboss.tools.common.xml.XMLUtilities;
+import org.jboss.tools.seam.core.SeamCoreMessages;
+import org.w3c.dom.Element;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class LinkCollection {
+ protected Map<String, Set<IPath>> resourcesByVariableName = new
HashMap<String, Set<IPath>>();
+ protected Map<IPath, Set<String>> variableNamesByResource = new
HashMap<IPath, Set<String>>();
+ protected Map<String, Set<IPath>> resourcesByDeclaringVariableName = new
HashMap<String, Set<IPath>>();
+ protected Map<IPath, Set<String>> declaringVariableNamesByResource = new
HashMap<IPath, Set<String>>();
+ protected Set<IPath> unnamedResources = new HashSet<IPath>();
+
+ /**
+ * Save link between resource and variable name.
+ * It's needed for incremental validation because we must save all linked resources
of changed java file.
+ */
+ public void addLinkedResource(String variableName, IPath linkedResourcePath, boolean
declaration) {
+ if(linkedResourcePath==null) {
+ throw new
IllegalArgumentException(SeamCoreMessages.SEAM_VALIDATION_CONTEXT_LINKED_RESOURCE_PATH_MUST_NOT_BE_NULL);
+ }
+ if(variableName==null) {
+ throw new
IllegalArgumentException(SeamCoreMessages.SEAM_VALIDATION_CONTEXT_VARIABLE_NAME_MUST_NOT_BE_NULL);
+ }
+
+ synchronized(this) {
+ Set<IPath> linkedResources = resourcesByVariableName.get(variableName);
+ if(linkedResources==null) {
+ // create set of linked resources with variable name.
+ linkedResources = new HashSet<IPath>();
+ resourcesByVariableName.put(variableName, linkedResources);
+ }
+ // save linked resources.
+ linkedResources.add(linkedResourcePath);
+ }
+
+ // Save link between resource and variable names. It's needed if variable name
changes in resource file.
+ Set<String> variableNames = variableNamesByResource.get(linkedResourcePath);
+ if(variableNames==null) {
+ variableNames = new HashSet<String>();
+ variableNamesByResource.put(linkedResourcePath, variableNames);
+ }
+ variableNames.add(variableName);
+
+ if(declaration) {
+ synchronized(this) {
+ Set<IPath> linkedResources =
resourcesByDeclaringVariableName.get(variableName);
+ if(linkedResources==null) {
+ // create set of linked resources with declaring variable name.
+ linkedResources = new HashSet<IPath>();
+ resourcesByDeclaringVariableName.put(variableName, linkedResources);
+ }
+ // save linked resources.
+ linkedResources.add(linkedResourcePath);
+ }
+
+ // Save link between resource and declaring variable names. It's needed if
variable name changes in resource file.
+ variableNames = declaringVariableNamesByResource.get(linkedResourcePath);
+ if(variableNames==null) {
+ variableNames = new HashSet<String>();
+ declaringVariableNamesByResource.put(linkedResourcePath, variableNames);
+ }
+ variableNames.add(variableName);
+ }
+ }
+
+ /**
+ * Removes link between resource and variable name.
+ * @param oldVariableName
+ * @param linkedResourcePath
+ */
+ public void removeLinkedResource(String name, IPath linkedResourcePath) {
+ synchronized(this) {
+ Set<IPath> linkedResources = resourcesByVariableName.get(name);
+ if(linkedResources!=null) {
+ // remove linked resource.
+ linkedResources.remove(linkedResourcePath);
+ }
+ if(linkedResources.isEmpty()) {
+ resourcesByVariableName.remove(name);
+ }
+ }
+ // Remove link between resource and declaring variable names.
+ Set<String> variableNames = variableNamesByResource.get(linkedResourcePath);
+ if(variableNames!=null) {
+ variableNames.remove(name);
+ }
+ if(variableNames.isEmpty()) {
+ variableNamesByResource.remove(linkedResourcePath);
+ }
+ synchronized(this) {
+ Set<IPath> linkedResources = resourcesByDeclaringVariableName.get(name);
+ if(linkedResources!=null) {
+ // remove linked resource.
+ linkedResources.remove(linkedResourcePath);
+ }
+ if(linkedResources.isEmpty()) {
+ resourcesByDeclaringVariableName.remove(name);
+ }
+ }
+ // Remove link between resource and declaring variable names.
+ variableNames = declaringVariableNamesByResource.get(linkedResourcePath);
+ if(variableNames!=null) {
+ variableNames.remove(name);
+ }
+ if(variableNames.isEmpty()) {
+ declaringVariableNamesByResource.remove(linkedResourcePath);
+ }
+ }
+
+ /**
+ * Removes link between resources and variable names.
+ * @param linkedResources
+ */
+ public void removeLinkedResources(Set<IPath> resources) {
+ for (IPath resource : resources) {
+ removeLinkedResource(resource);
+ }
+ }
+
+ /**
+ * Removes link between resource and variable names.
+ * @param linkedResources
+ */
+ public synchronized void removeLinkedResource(IPath resource) {
+ Set<String> resourceNames = variableNamesByResource.get(resource);
+ if(resourceNames!=null) {
+ for (String name : resourceNames) {
+ Set<IPath> linkedResources = resourcesByVariableName.get(name);
+ if(linkedResources!=null) {
+ linkedResources.remove(resource);
+ if(linkedResources.isEmpty()) {
+ resourcesByVariableName.remove(name);
+ }
+ }
+ }
+ }
+ variableNamesByResource.remove(resource);
+
+ 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.isEmpty()) {
+ resourcesByDeclaringVariableName.remove(name);
+ }
+ }
+ }
+ }
+ declaringVariableNamesByResource.remove(resource);
+ }
+
+ public Set<IPath> getResourcesByVariableName(String variableName, boolean
declaration) {
+ return
declaration?resourcesByDeclaringVariableName.get(variableName):resourcesByVariableName.get(variableName);
+ }
+
+ public synchronized Set<String> getVariableNamesByResource(IPath fullPath, boolean
declaration) {
+ return
declaration?declaringVariableNamesByResource.get(fullPath):variableNamesByResource.get(fullPath);
+ }
+
+ /**
+ * Adds resource without any link to any context variable name.
+ * @param fullPath
+ */
+ public void addUnnamedResource(IPath fullPath) {
+ unnamedResources.add(fullPath);
+ }
+
+ /**
+ * @return Set of resources without any link to any context variable name.
+ * @param fullPath
+ */
+ public Set<IPath> getUnnamedResources() {
+ return unnamedResources;
+ }
+
+ /**
+ * Removes unnamed resource.
+ * @param fullPath
+ */
+ public void removeUnnamedResource(IPath fullPath) {
+ unnamedResources.remove(fullPath);
+ }
+
+ /**
+ * Clear all references
+ */
+ public synchronized void clearAll() {
+ resourcesByVariableName.clear();
+ variableNamesByResource.clear();
+ declaringVariableNamesByResource.clear();
+ resourcesByDeclaringVariableName.clear();
+ unnamedResources.clear();
+ }
+
+ /**
+ * Store the collection to XML
+ * @param root
+ */
+ public synchronized void store(Element root) {
+ Set<String> variables = resourcesByVariableName.keySet();
+ for (String name: variables) {
+ Set<IPath> paths = resourcesByVariableName.get(name);
+ if(paths == null) continue;
+ for (IPath path: paths) {
+ Element linkedResource = XMLUtilities.createElement(root,
"linked-resource"); //$NON-NLS-1$
+ linkedResource.setAttribute("name", name); //$NON-NLS-1$
+ linkedResource.setAttribute("path", path.toString()); //$NON-NLS-1$
+ if(checkDeclaration(path, name)) {
+ linkedResource.setAttribute("declaration", "true");
//$NON-NLS-1$ $NON-NLS-2$
+ }
+ }
+ }
+ for (IPath unnamedPath: unnamedResources) {
+ Element unnamedPathElement = XMLUtilities.createElement(root,
"unnamed-path"); //$NON-NLS-1$
+ unnamedPathElement.setAttribute("path", unnamedPath.toString());
//$NON-NLS-1$
+ }
+ }
+
+ private boolean checkDeclaration(IPath resource, String variableName) {
+ Set<IPath> paths = resourcesByDeclaringVariableName.get(variableName);
+ if(paths!=null) {
+ for (IPath path : paths) {
+ if(path.equals(resource)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ /**
+ * Load the collection from XML
+ * @param root
+ */
+ public void load(Element root) {
+ if(root == null) return;
+ Element[] linkedResources = XMLUtilities.getChildren(root,
"linked-resource"); //$NON-NLS-1$
+ if(linkedResources != null) for (int i = 0; i < linkedResources.length; i++) {
+ String name = linkedResources[i].getAttribute("name"); //$NON-NLS-1$
+ if(name == null || name.trim().length() == 0) continue;
+ String path = linkedResources[i].getAttribute("path"); //$NON-NLS-1$
+ if(path == null || path.trim().length() == 0) continue;
+ String declaration = linkedResources[i].getAttribute("declaration");
+ boolean declarationFlag = "true".equals(declaration);
+ IPath pathObject = new Path(path);
+ addLinkedResource(name, pathObject, declarationFlag);
+ }
+ Element[] unnamedPathElement = XMLUtilities.getChildren(root,
"unnamed-path"); //$NON-NLS-1$
+ if(unnamedPathElement != null) for (int i = 0; i < unnamedPathElement.length; i++)
{
+ String path = unnamedPathElement[i].getAttribute("path"); //$NON-NLS-1$
+ IPath pathObject = new Path(path);
+ addUnnamedResource(pathObject);
+ }
+ }
+}
\ No newline at end of file
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/LinkCollection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ProjectValidationContext.java
(from rev 16312,
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationContext.java)
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ProjectValidationContext.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ProjectValidationContext.java 2009-07-03
20:54:55 UTC (rev 16379)
@@ -0,0 +1,322 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core.validation;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.jboss.tools.common.xml.XMLUtilities;
+import org.w3c.dom.Element;
+
+/**
+ * Contains information for seam validators that must be saved between
+ * validation invoking.
+ * @author Alexey Kazakov
+ */
+public class ProjectValidationContext implements ISeamValidationContext {
+
+ // We should load/save these collections between eclipse sessions.
+ private LinkCollection coreLinks = new LinkCollection();
+ private ELValidatorContext elLinks = new ELValidatorContext();
+
+ private Set<IFile> removedFiles = new HashSet<IFile>();
+ private Set<IFile> registeredResources = new HashSet<IFile>();
+ private Set<String> oldVariableNamesForELValidation = new
HashSet<String>();
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#addLinkedCoreResource(java.lang.String,
org.eclipse.core.runtime.IPath, boolean)
+ */
+ public void addLinkedCoreResource(String variableName, IPath linkedResourcePath, boolean
declaration) {
+ coreLinks.addLinkedResource(variableName, linkedResourcePath, declaration);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeLinkedCoreResource(java.lang.String,
org.eclipse.core.runtime.IPath)
+ */
+ public void removeLinkedCoreResource(String name, IPath linkedResourcePath) {
+ coreLinks.removeLinkedResource(name, linkedResourcePath);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeLinkedCoreResources(java.util.Set)
+ */
+ public void removeLinkedCoreResources(Set<IPath> resources) {
+ coreLinks.removeLinkedResources(resources);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeLinkedCoreResource(org.eclipse.core.runtime.IPath)
+ */
+ public void removeLinkedCoreResource(IPath resource) {
+ coreLinks.removeLinkedResource(resource);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getCoreResourcesByVariableName(java.lang.String,
boolean)
+ */
+ public Set<IPath> getCoreResourcesByVariableName(String variableName, boolean
declaration) {
+ return coreLinks.getResourcesByVariableName(variableName, declaration);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getVariableNamesByCoreResource(org.eclipse.core.runtime.IPath,
boolean)
+ */
+ public Set<String> getVariableNamesByCoreResource(IPath fullPath, boolean
declaration) {
+ return coreLinks.getVariableNamesByResource(fullPath, declaration);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#addUnnamedCoreResource(org.eclipse.core.runtime.IPath)
+ */
+ public void addUnnamedCoreResource(IPath fullPath) {
+ coreLinks.addUnnamedResource(fullPath);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getUnnamedCoreResources()
+ */
+ public Set<IPath> getUnnamedCoreResources() {
+ return coreLinks.getUnnamedResources();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeUnnamedCoreResource(org.eclipse.core.runtime.IPath)
+ */
+ public void removeUnnamedCoreResource(IPath fullPath) {
+ coreLinks.removeUnnamedResource(fullPath);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#addUnnamedElResource(org.eclipse.core.runtime.IPath)
+ */
+ public void addUnnamedElResource(IPath fullPath) {
+ elLinks.addUnnamedResource(fullPath);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getUnnamedElResources()
+ */
+ public Set<IPath> getUnnamedElResources() {
+ return elLinks.getUnnamedResources();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeUnnamedElResource(org.eclipse.core.runtime.IPath)
+ */
+ public void removeUnnamedElResource(IPath fullPath) {
+ elLinks.removeUnnamedResource(fullPath);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#addVariableNameForELValidation(java.lang.String)
+ */
+ public void addVariableNameForELValidation(String name) {
+ oldVariableNamesForELValidation.add(name);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeLinkedEls(java.util.Set)
+ */
+ public void removeLinkedEls(Set<IFile> resorces) {
+ elLinks.removeLinkedEls(resorces);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getElsForValidation(java.util.Set,
boolean)
+ */
+ public Set<ELReference> getElsForValidation(Set<IFile> changedFiles, boolean
onlyChangedVariables) {
+ Set<ELReference> result = new HashSet<ELReference>();
+ // Collect all ELs which use new variables names
+ for(IResource resource : changedFiles) {
+ Set<String> newNames = getVariableNamesByCoreResource(resource.getFullPath(),
true);
+ if(newNames!=null) {
+ for (String newName : newNames) {
+ if(!onlyChangedVariables || !oldVariableNamesForELValidation.contains(newName)) {
+ Set<ELReference> els = elLinks.getElsByVariableName(newName);
+ if(els!=null) {
+ result.addAll(els);
+ }
+ }
+ }
+ }
+ for (String oldName : oldVariableNamesForELValidation) {
+ if(!onlyChangedVariables || newNames==null || !newNames.contains(oldName)) {
+ Set<ELReference> els = elLinks.getElsByVariableName(oldName);
+ if(els!=null) {
+ result.addAll(els);
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#clearAll()
+ */
+ public void clearAll() {
+ removedFiles.clear();
+ synchronized (registeredResources) {
+ registeredResources.clear();
+ }
+ oldVariableNamesForELValidation.clear();
+ coreLinks.clearAll();
+ elLinks.clearAll();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#clearAllResourceLinks()
+ */
+ public void clearAllResourceLinks() {
+ oldVariableNamesForELValidation.clear();
+ coreLinks.clearAll();
+ elLinks.clearAll();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#clearRegisteredFiles()
+ */
+ public void clearRegisteredFiles() {
+ removedFiles.clear();
+ synchronized (registeredResources) {
+ registeredResources.clear();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#clearElResourceLinks()
+ */
+ public void clearElResourceLinks() {
+ oldVariableNamesForELValidation.clear();
+ elLinks.clearAll();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#clearOldVariableNameForElValidation()
+ */
+ public void clearOldVariableNameForElValidation() {
+ oldVariableNamesForELValidation.clear();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#addLinkedEl(java.lang.String,
org.jboss.tools.seam.internal.core.validation.ELReference)
+ */
+ public void addLinkedEl(String variableName, ELReference el) {
+ elLinks.addLinkedEl(variableName, el);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeLinkedEl(java.lang.String,
org.jboss.tools.seam.internal.core.validation.ELReference)
+ */
+ public void removeLinkedEl(String name, ELReference el) {
+ elLinks.removeLinkedEl(name, el);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getElsByVariableName(java.lang.String)
+ */
+ public Set<ELReference> getElsByVariableName(String variableName) {
+ return elLinks.getElsByVariableName(variableName);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#store(org.w3c.dom.Element)
+ */
+ public void store(Element root) {
+ Element validation = XMLUtilities.createElement(root, "validation");
//$NON-NLS-1$
+ Element core = XMLUtilities.createElement(validation, "core"); //$NON-NLS-1$
+ coreLinks.store(core);
+ Element el = XMLUtilities.createElement(validation, "el"); //$NON-NLS-1$
+ elLinks.store(el);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#load(org.w3c.dom.Element)
+ */
+ public void load(Element root) {
+ Element validation = XMLUtilities.getUniqueChild(root, "validation");
//$NON-NLS-1$
+ if(validation == null) return;
+ Element core = XMLUtilities.getUniqueChild(validation, "core");
//$NON-NLS-1$
+ if(core != null) {
+ coreLinks.load(core);
+ }
+ Element el = XMLUtilities.getUniqueChild(validation, "el"); //$NON-NLS-1$
+ if(el != null) {
+ elLinks.load(el);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getRemovedFiles()
+ */
+ public Set<IFile> getRemovedFiles() {
+ return removedFiles;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#addRemovedFile(org.eclipse.core.resources.IFile)
+ */
+ public void addRemovedFile(IFile file) {
+ removedFiles.add(file);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getRegisteredFiles()
+ */
+ public Set<IFile> getRegisteredFiles() {
+ Set<IFile> copy = new HashSet<IFile>();
+ synchronized (registeredResources) {
+ copy.addAll(registeredResources);
+ }
+ return copy;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#registerFile(org.eclipse.core.resources.IFile)
+ */
+ public void registerFile(IFile file) {
+ synchronized (registeredResources) {
+ registeredResources.add(file);
+ }
+ }
+}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamContextValidationHelper.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamContextValidationHelper.java 2009-07-03
10:34:22 UTC (rev 16378)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamContextValidationHelper.java 2009-07-03
20:54:55 UTC (rev 16379)
@@ -19,7 +19,6 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path;
import org.eclipse.ui.editors.text.TextFileDocumentProvider;
-import org.jboss.tools.seam.internal.core.SeamProject;
/**
* Helper for Seam Validators that use Seam Validator Context.
@@ -27,7 +26,7 @@
*/
public class SeamContextValidationHelper extends SeamValidationHelper {
- protected SeamValidationContext validationContext;
+ protected ISeamValidationContext validationContext;
protected TextFileDocumentProvider documentProvider = new TextFileDocumentProvider();
/*
@@ -61,13 +60,17 @@
return result;
}
- public SeamValidationContext getValidationContext() {
+ public ISeamValidationContext getValidationContext() {
if(validationContext==null) {
- validationContext = ((SeamProject)getSeamProject()).getValidationContext();
+ validationContext = new SeamValidationContext(getProject());
}
return validationContext;
}
-
+
+ public void setValidationContext(ISeamValidationContext context) {
+ validationContext = context;
+ }
+
public TextFileDocumentProvider getDocumentProvider(){
return documentProvider;
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2009-07-03
10:34:22 UTC (rev 16378)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2009-07-03
20:54:55 UTC (rev 16379)
@@ -95,7 +95,7 @@
public SeamCoreValidator(SeamValidatorManager validatorManager,
SeamContextValidationHelper coreHelper, IReporter reporter,
- SeamValidationContext validationContext, ISeamProject project) {
+ ISeamValidationContext validationContext, ISeamProject project) {
super(validatorManager, coreHelper, reporter, validationContext, project);
}
@@ -130,36 +130,33 @@
validateUnnamedResources = fileName.endsWith(".java") ||
fileName.endsWith(".properties") || fileName.equals("components.xml");
//$NON-NLS-1$ $NON-NLS-2$
}
if (checkFileExtension(currentFile)) {
- // Get all variable names which were linked with this resource.
- Set<String> oldVariablesNamesOfChangedFile =
validationContext.getVariableNamesByCoreResource(currentFile.getFullPath());
- if(oldVariablesNamesOfChangedFile!=null) {
- // Check if variable name was changed in source file
- Set<String> newVariableNamesOfChangedFile =
getVariablesNameByResource(currentFile.getFullPath());
- for (String newVariableName : newVariableNamesOfChangedFile) {
- if(!oldVariablesNamesOfChangedFile.contains(newVariableName)) {
- // Name was changed.
- // Collect resources with new component name.
- Set<IPath> linkedResources =
validationContext.getCoreResourcesByVariableName(newVariableName);
- if(linkedResources!=null) {
- resources.addAll(linkedResources);
- }
- resources.addAll(getAllResourceOfComponent(currentFile.getFullPath()));
- }
+ resources.add(currentFile.getFullPath());
+ // Get new variable names from model
+ Set<String> newVariableNamesOfChangedFile =
getVariablesNameByResource(currentFile.getFullPath());
+ Set<String> oldDeclarationsOfChangedFile =
validationContext.getVariableNamesByCoreResource(currentFile.getFullPath(), true);
+ for (String newVariableName : newVariableNamesOfChangedFile) {
+ // Collect resources with new variable name.
+ Set<IPath> linkedResources =
validationContext.getCoreResourcesByVariableName(newVariableName, false);
+ if(linkedResources!=null) {
+ resources.addAll(linkedResources);
}
- resources.add(currentFile.getFullPath());
-
- // Collect all linked resources with old variable names.
+ resources.addAll(getAllResourceOfComponent(currentFile.getFullPath()));
+ }
+ // Get old variable names which were linked with this resource.
+ Set<String> oldVariablesNamesOfChangedFile =
validationContext.getVariableNamesByCoreResource(currentFile.getFullPath(), false);
+ if(oldVariablesNamesOfChangedFile!=null) {
for (String name : oldVariablesNamesOfChangedFile) {
- Set<IPath> linkedResources =
validationContext.getCoreResourcesByVariableName(name);
+ Set<IPath> linkedResources =
validationContext.getCoreResourcesByVariableName(name, false);
if(linkedResources!=null) {
resources.addAll(linkedResources);
}
- // Save old names for EL validation. We need to validate all EL resources which use
this variable name.
+ }
+ }
+ // Save old declarations for EL validation. We need to validate all EL resources
which use this variable name but only if the variable has been changed.
+ if(oldDeclarationsOfChangedFile!=null) {
+ for (String name : oldDeclarationsOfChangedFile) {
validationContext.addVariableNameForELValidation(name);
}
- } else {
- // Validate new (unlinked) source file.
- resources.add(currentFile.getFullPath());
}
newResources.add(currentFile.getFullPath());
}
@@ -218,10 +215,8 @@
}
Set<ISeamComponentDeclaration> declarations = component.getAllDeclarations();
for (ISeamComponentDeclaration seamComponentDeclaration : declarations) {
- if(project == seamComponentDeclaration.getResource().getProject()) {
- validateComponent(component);
- break;
- }
+ validateComponent(component);
+ break;
}
}
ISeamFactory[] factories = seamProject.getFactories();
@@ -230,9 +225,7 @@
if(reporter.isCancelled()) {
return OK_STATUS;
}
- if(project == factory.getResource().getProject()) {
- validateFactory(factory, markedDuplicateFactoryNames);
- }
+ validateFactory(factory, markedDuplicateFactoryNames);
}
ISeamJavaComponentDeclaration[] values =
((SeamProject)seamProject).getAllJavaComponentDeclarations();
@@ -241,9 +234,7 @@
return OK_STATUS;
}
displaySubtask(VALIDATING_CLASS_MESSAGE_ID, new String[]{projectName,
d.getClassName()});
- if(project == d.getResource().getProject()) {
- validateMethodsOfUnknownComponent(d);
- }
+ validateMethodsOfUnknownComponent(d);
}
return OK_STATUS;
@@ -311,14 +302,14 @@
if(!firstDuplicateVariableWasMarked) {
firstDuplicateVariableWasMarked = true;
// mark original factory
- validationContext.addLinkedCoreResource(factoryName, factory.getSourcePath());
+ validationContext.addLinkedCoreResource(factoryName, factory.getSourcePath(),
true);
location = coreHelper.getLocationOfName(factory);
this.addError(DUPLICATE_VARIABLE_NAME_MESSAGE_ID,
SeamPreferences.DUPLICATE_VARIABLE_NAME, new String[]{factoryName}, location,
factory.getResource());
}
// Mark duplicate variable.
if(!coreHelper.isJar(variable.getSourcePath())) {
IResource resource = coreHelper.getComponentResourceWithName(variable);
- validationContext.addLinkedCoreResource(factoryName, resource.getFullPath());
+ validationContext.addLinkedCoreResource(factoryName, resource.getFullPath(),
true);
location = coreHelper.getLocationOfName(variable);
this.addError(DUPLICATE_VARIABLE_NAME_MESSAGE_ID,
SeamPreferences.DUPLICATE_VARIABLE_NAME, new String[]{factoryName}, location, resource);
}
@@ -350,7 +341,7 @@
if(unknownVariable && validateUnknownName && voidReturnType) {
// mark unknown factory name
// save link to factory resource
- validationContext.addLinkedCoreResource(factoryName, factory.getSourcePath());
+ validationContext.addLinkedCoreResource(factoryName, factory.getSourcePath(), true);
this.addError(UNKNOWN_FACTORY_NAME_MESSAGE_ID, SeamPreferences.UNKNOWN_FACTORY_NAME,
new String[]{factoryName}, coreHelper.getLocationOfName(factory), factory.getResource());
}
}
@@ -420,20 +411,20 @@
ISeamJavaComponentDeclaration jd = (ISeamJavaComponentDeclaration)declaration;
//do not check files declared in another project
- if(jd.getSeamProject() != seamProject) continue;
+// if(jd.getSeamProject() != seamProject) continue;
IType type = (IType)jd.getSourceMember();
boolean sourceJavaDeclaration = !type.isBinary();
if(sourceJavaDeclaration) {
// Save link between component name and java source file.
- validationContext.addLinkedCoreResource(componentName,
declaration.getSourcePath());
+ validationContext.addLinkedCoreResource(componentName, declaration.getSourcePath(),
true);
// Save link between component name and all supers of java declaration.
try {
IType[] superTypes = TypeInfoCollector.getSuperTypes(type).getSuperTypes();
for (int i = 0; superTypes != null && i < superTypes.length; i++) {
if(!superTypes[i].isBinary()) {
IPath path = superTypes[i].getResource().getFullPath();
- validationContext.addLinkedCoreResource(componentName, path);
+ validationContext.addLinkedCoreResource(componentName, path, true);
}
}
} catch (JavaModelException e) {
@@ -493,9 +484,9 @@
return;
}
//do not check files declared in another project
- if(declaration.getSeamProject() != seamProject) continue;
+// if(declaration.getSeamProject() != seamProject) continue;
- validationContext.addLinkedCoreResource(componentName, declaration.getSourcePath());
+ validationContext.addLinkedCoreResource(componentName, declaration.getSourcePath(),
true);
String precedence = declaration.getPrecedence();
if(firstNamedDeclaration == null && declaration.getName()!=null) {
@@ -582,7 +573,7 @@
}
return;
} else if(!type.isBinary()) {
- validationContext.addLinkedCoreResource(componentName,
type.getResource().getFullPath());
+ validationContext.addLinkedCoreResource(componentName,
type.getResource().getFullPath(), true);
}
} catch (JavaModelException e) {
SeamCorePlugin.getDefault().logError(SeamCoreMessages.SEAM_CORE_VALIDATOR_ERROR_VALIDATING_SEAM_CORE,
e);
@@ -719,11 +710,11 @@
if(name==null || name.startsWith("#{") || name.startsWith("${")) {
//$NON-NLS-1$ //$NON-NLS-2$
return;
}
- // save link between java source and variable name
- validationContext.addLinkedCoreResource(name, declaration.getSourcePath());
-
// Validate @In
if(bijection.isOfType(BijectedAttributeType.IN)) {
+ // save link between java source and variable name
+ validationContext.addLinkedCoreResource(name, declaration.getSourcePath(), false);
+
Set<ISeamContextVariable> variables = seamProject.getVariablesByName(name);
if(variables==null || variables.size()<1) {
ISeamProject parentProject = seamProject.getParentProject();
@@ -740,6 +731,9 @@
}
addError(UNKNOWN_VARIABLE_NAME_MESSAGE_ID, SeamPreferences.UNKNOWN_VARIABLE_NAME, new
String[]{name}, nameRef, declarationResource);
}
+ } else {
+ // save link between java source and variable name
+ validationContext.addLinkedCoreResource(name, declaration.getSourcePath(), true);
}
}
@@ -747,7 +741,7 @@
String dataModelName = bijection.getValue();
String selectionName = bijection.getName();
// save link between java source and variable name
- validationContext.addLinkedCoreResource(selectionName, declaration.getSourcePath());
+ validationContext.addLinkedCoreResource(selectionName, declaration.getSourcePath(),
false);
if(dataModelName==null) {
// here must be the only one @DataModel in the component
Set<IBijectedAttribute> dataBinders =
declaration.getBijectedAttributesByType(BijectedAttributeType.DATA_BINDER);
@@ -758,7 +752,7 @@
}
} else {
// save link between java source and Data Model name
- validationContext.addLinkedCoreResource(dataModelName, declaration.getSourcePath());
+ validationContext.addLinkedCoreResource(dataModelName, declaration.getSourcePath(),
true);
Set<IBijectedAttribute> dataBinders =
declaration.getBijectedAttributesByName(dataModelName);
if(dataBinders!=null) {
for (IBijectedAttribute dataBinder : dataBinders) {
@@ -801,7 +795,7 @@
IMethod javaMethod = (IMethod)method.getSourceMember();
String methodName = javaMethod.getElementName();
if(javaDeclaration.getSourcePath().equals(javaMethod.getPath())) {
- validationContext.addLinkedCoreResource(component.getName(),
javaDeclaration.getSourcePath());
+ validationContext.addLinkedCoreResource(component.getName(),
javaDeclaration.getSourcePath(), true);
ITextSourceReference methodNameLocation = getNameLocation(method);
addError(DESTROY_METHOD_BELONGS_TO_STATELESS_SESSION_BEAN_ID,
SeamPreferences.DESTROY_METHOD_BELONGS_TO_STATELESS_SESSION_BEAN, new
String[]{methodName}, methodNameLocation, method.getResource());
}
@@ -898,5 +892,4 @@
}
return false;
}
-
}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java 2009-07-03
10:34:22 UTC (rev 16378)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java 2009-07-03
20:54:55 UTC (rev 16379)
@@ -18,6 +18,7 @@
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
@@ -45,7 +46,6 @@
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.operations.WorkbenchReporter;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
@@ -97,7 +97,7 @@
public SeamELValidator(SeamValidatorManager validatorManager,
SeamContextValidationHelper coreHelper, IReporter reporter,
- SeamValidationContext validationContext, ISeamProject project) {
+ ISeamValidationContext validationContext, ISeamProject project) {
super(validatorManager, coreHelper, reporter, validationContext, project);
engine = new SeamELCompletionEngine();
elVarSearcher = new ElVarSearcher(engine);
@@ -115,21 +115,17 @@
* @see
org.jboss.tools.seam.internal.core.validation.ISeamValidator#validate(java.util.Set)
*/
public IStatus validate(Set<IFile> changedFiles) throws ValidationException {
+ webRootFolder = null;
initRevalidationFlag();
IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
- Set<IPath> files = validationContext.getElResourcesForValidation(changedFiles);
- validationContext.removeLinkedElResources(files);
Set<IFile> filesToValidate = new HashSet<IFile>();
boolean containsJavaOrComponentsXml = false;
- for (IPath path : files) {
- IFile file = wsRoot.getFile(path);
- if(file.exists()) {
- filesToValidate.add(file);
- if(!containsJavaOrComponentsXml) {
- String fileName = file.getName().toLowerCase();
- containsJavaOrComponentsXml = fileName.endsWith(".java") ||
fileName.endsWith(".properties") || fileName.equals("components.xml");
//$NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
- }
+ for (IFile file : changedFiles) {
+ filesToValidate.add(file);
+ if(!containsJavaOrComponentsXml) {
+ String fileName = file.getName().toLowerCase();
+ containsJavaOrComponentsXml = fileName.endsWith(".java") ||
fileName.endsWith(".properties") || fileName.equals("components.xml");
//$NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
}
}
@@ -144,18 +140,29 @@
}
}
}
+
+ Set<ELReference> elsToValidate =
validationContext.getElsForValidation(changedFiles, false);
+ validationContext.removeLinkedEls(filesToValidate);
for (IFile file : filesToValidate) {
if(!reporter.isCancelled()) {
validateFile(file);
}
}
+ if(revalidateUnresolvedELs) {
+ for (ELReference el : elsToValidate) {
+ if(!filesToValidate.contains(el.getResource())) {
+ validateEL(el);
+ }
+ }
+ }
+
validationContext.clearOldVariableNameForElValidation();
return OK_STATUS;
}
private void initRevalidationFlag() {
- String revalidateUnresolvedEls = SeamPreferences.getProjectPreference(project,
SeamPreferences.RE_VALIDATE_UNRESOLVED_EL);
- revalidateUnresolvedELs = SeamPreferences.ENABLE.equals(revalidateUnresolvedEls);
+ String revalidateUnresolvedELsString = SeamPreferences.getProjectPreference(project,
SeamPreferences.RE_VALIDATE_UNRESOLVED_EL);
+ revalidateUnresolvedELs =
SeamPreferences.ENABLE.equals(revalidateUnresolvedELsString);
}
/*
@@ -163,8 +170,8 @@
* @see org.jboss.tools.seam.internal.core.validation.ISeamValidator#validateAll()
*/
public IStatus validateAll() throws ValidationException {
+ webRootFolder = null;
initRevalidationFlag();
- validationContext.clearElResourceLinks();
Set<IFile> files = validationContext.getRegisteredFiles();
for (IFile file : files) {
if(!reporter.isCancelled()) {
@@ -188,19 +195,23 @@
}
IProject project = file.getProject();
if(!project.equals(currentProject)) {
- IFacetedProject facetedProject = null;
- try {
- facetedProject = ProjectFacetsManager.create(project);
- } catch (CoreException e) {
- SeamCorePlugin.getDefault().logError(SeamCoreMessages.SEAM_EL_VALIDATOR_ERROR_VALIDATING_SEAM_EL,
e);
+ if(webRootFolder!=null && !project.equals(webRootFolder.getProject())) {
+ webRootFolder = null;
}
- webRootFolder = null;
- if(facetedProject!=null &&
facetedProject.getProjectFacetVersion(IJ2EEFacetConstants.DYNAMIC_WEB_FACET)!=null) {
- IVirtualComponent component = ComponentCore.createComponent(project);
- if(component!=null) {
- IVirtualFolder webRootVirtFolder = component.getRootFolder().getFolder(new
Path("/")); //$NON-NLS-1$
- webRootFolder = webRootVirtFolder.getUnderlyingFolder();
+ if(webRootFolder==null) {
+ IFacetedProject facetedProject = null;
+ try {
+ facetedProject = ProjectFacetsManager.create(project);
+ } catch (CoreException e) {
+ SeamCorePlugin.getDefault().logError(SeamCoreMessages.SEAM_EL_VALIDATOR_ERROR_VALIDATING_SEAM_EL,
e);
}
+ if(facetedProject!=null &&
facetedProject.getProjectFacetVersion(IJ2EEFacetConstants.DYNAMIC_WEB_FACET)!=null) {
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ if(component!=null) {
+ IVirtualFolder webRootVirtFolder = component.getRootFolder().getFolder(new
Path("/")); //$NON-NLS-1$
+ webRootFolder = webRootVirtFolder.getUnderlyingFolder();
+ }
+ }
}
currentProject = project;
currentSources = EclipseResourceUtil.getJavaSourceRoots(project);
@@ -226,7 +237,7 @@
if(!shouldFileBeValidated(file)) {
return;
}
- WorkbenchReporter.removeAllMessages(file, new String[]{this.getClass().getName()},
null);
+ removeAllMessagesFromResource(file);
displaySubtask(VALIDATING_EL_FILE_MESSAGE_ID, new String[]{projectName,
file.getName()});
elVarSearcher.setFile(file);
String ext = file.getFileExtension();
@@ -244,6 +255,13 @@
}
}
+ private void validateEL(ELReference el) {
+ el.deleteMarkers();
+ for (ELExpression expresion : el.getEl()) {
+ validateELExpression(el, expresion);
+ }
+ }
+
private void validateJava(IFile file, String content) {
try {
FastJavaPartitionScanner scaner = new FastJavaPartitionScanner();
@@ -342,15 +360,24 @@
if(startEl>-1) {
ELParser parser = ELParserUtil.getJbossFactory().createParser();
ELModel model = parser.parse(string);
+ List<ELInstance> is = model.getInstances();
+
+ ELReference elReference = new ELReference();
+ elReference.setResource(file);
+ elReference.setEl(is);
+ elReference.setLength(string.length());
+ elReference.setStartPosition(offset);
+ elReference.setVarSearcher(new ElVarSearcher(file, engine));
+
List<SyntaxError> errors = model.getSyntaxErrors();
if(!errors.isEmpty()) {
for (SyntaxError error: errors) {
//TODO 1) make message more informative
// 2) create other preference
- addError(SYNTAX_ERROR_MESSAGE_ID, SeamPreferences.EL_SYNTAX_ERROR, new
String[]{"" + error.getProblem()}, 1, offset + error.getPosition(), file);
+ IMarker marker = addError(SYNTAX_ERROR_MESSAGE_ID, SeamPreferences.EL_SYNTAX_ERROR,
new String[]{"" + error.getProblem()}, 1, offset + error.getPosition(), file);
+ elReference.addMarker(marker);
}
}
- List<ELInstance> is = model.getInstances();
for (ELInstance i : is) {
if (reporter.isCancelled()) {
return;
@@ -359,45 +386,42 @@
//Already reported syntax problem in this piece of EL.
continue;
}
- validateEl(file, i.getExpression(), offset);
+ validateELExpression(elReference, i.getExpression());
}
}
}
- private void validateEl(IFile file, ELExpression el, int offset) {
+ private void validateELExpression(ELReference elReference, ELExpression el) {
if(el == null) return;
List<ELInvocationExpression> es = el.getInvocations();
for (ELInvocationExpression token: es) {
- validateElOperand(file, token, offset);
+ validateElOperand(elReference, token);
}
}
- private void validateElOperand(IFile file, ELInvocationExpression operandToken, int
documnetOffset) {
+ private void validateElOperand(ELReference elReference, ELInvocationExpression
operandToken) {
+ IFile file = elReference.getResource();
+ int documnetOffset = elReference.getStartPosition();
String operand = operandToken.getText();
String varName = operand;
int offsetOfVarName = documnetOffset + operandToken.getFirstToken().getStart();
int lengthOfVarName = varName.length();
boolean unresolvedTokenIsVariable = false;
try {
- int offset = operand.length();
if (!operand.endsWith(".")) { //$NON-NLS-1$
SeamELOperandResolveStatus status =
(SeamELOperandResolveStatus)engine.resolveELOperand(file, operandToken, true,
varListForCurentValidatedNode, elVarSearcher);
if(status.isError()) {
- if(revalidateUnresolvedELs) {
- Set<String> names = findVariableNames(operandToken);
- for (String name : names) {
- validationContext.addLinkedElResource(name, file.getFullPath());
- }
+ Set<String> names = findVariableNames(operandToken);
+ for (String name : names) {
+ validationContext.addLinkedEl(name, elReference);
}
- // Save resources with unknown variables names
-// validationContext.addUnnamedElResource(file.getFullPath());
}
// Save links between resource and used variables names
for(ISeamContextVariable variable: status.getUsedVariables()) {
- validationContext.addLinkedElResource(variable.getName(), file.getFullPath());
+ validationContext.addLinkedEl(variable.getName(), elReference);
}
// Check pair for getter/setter
@@ -411,7 +435,15 @@
missingMethodName = existedMethodName;
existedMethodName = SeamCoreMessages.SEAM_EL_VALIDATOR_SETTER;
}
- addError(UNPAIRED_GETTER_OR_SETTER_MESSAGE_ID,
SeamPreferences.UNPAIRED_GETTER_OR_SETTER, new String[]{propertyName, existedMethodName,
missingMethodName}, operand.length(), documnetOffset, file);
+ int startPosition = documnetOffset + operandToken.getStartPosition();
+ int length = operandToken.getLength();
+ int startPr = operand.indexOf(propertyName);
+ if(startPr>-1) {
+ startPosition = startPosition + startPr;
+ length = propertyName.length();
+ }
+ IMarker marker = addError(UNPAIRED_GETTER_OR_SETTER_MESSAGE_ID,
SeamPreferences.UNPAIRED_GETTER_OR_SETTER, new String[]{propertyName, existedMethodName,
missingMethodName}, length, startPosition, file);
+ elReference.addMarker(marker);
}
if (status.isOK()) {
@@ -439,9 +471,11 @@
}
// Mark invalid EL
if(unresolvedTokenIsVariable) {
- addError(UNKNOWN_EL_VARIABLE_NAME_MESSAGE_ID,
SeamPreferences.UNKNOWN_EL_VARIABLE_NAME, new String[]{varName}, lengthOfVarName,
offsetOfVarName, file);
+ IMarker marker = addError(UNKNOWN_EL_VARIABLE_NAME_MESSAGE_ID,
SeamPreferences.UNKNOWN_EL_VARIABLE_NAME, new String[]{varName}, lengthOfVarName,
offsetOfVarName, file);
+ elReference.addMarker(marker);
} else {
- addError(UNKNOWN_EL_VARIABLE_PROPERTY_NAME_MESSAGE_ID,
SeamPreferences.UNKNOWN_EL_VARIABLE_PROPERTY_NAME, new String[]{varName}, lengthOfVarName,
offsetOfVarName, file);
+ IMarker marker = addError(UNKNOWN_EL_VARIABLE_PROPERTY_NAME_MESSAGE_ID,
SeamPreferences.UNKNOWN_EL_VARIABLE_PROPERTY_NAME, new String[]{varName}, lengthOfVarName,
offsetOfVarName, file);
+ elReference.addMarker(marker);
}
}
Deleted:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationContext.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationContext.java 2009-07-03
10:34:22 UTC (rev 16378)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationContext.java 2009-07-03
20:54:55 UTC (rev 16379)
@@ -1,428 +0,0 @@
- /*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.seam.internal.core.validation;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.jboss.tools.common.xml.XMLUtilities;
-import org.jboss.tools.seam.core.SeamCoreMessages;
-import org.w3c.dom.Element;
-
-/**
- * Contains information for seam validators that must be saved between
- * validation invoking.
- * @author Alexey Kazakov
- */
-public class SeamValidationContext {
-
- // We should load/save these collections between eclipse sessions.
- private LinkCollection coreLinks = new LinkCollection();
- private LinkCollection elLinks = new LinkCollection();
-
- private Set<IFile> removedFiles = new HashSet<IFile>();
- private Set<IFile> registeredResources = new HashSet<IFile>();
- private Set<String> oldVariableNamesForELValidation = new
HashSet<String>();
-
- /**
- * Save link between core resource and variable name.
- * It's needed for incremental validation because we must save all linked resources
of changed java file.
- */
- public void addLinkedCoreResource(String variableName, IPath linkedResourcePath) {
- coreLinks.addLinkedResource(variableName, linkedResourcePath);
- }
-
- /**
- * Removes link between core resource and variable name.
- * @param oldVariableName
- * @param linkedResourcePath
- */
- public void removeLinkedCoreResource(String name, IPath linkedResourcePath) {
- coreLinks.removeLinkedResource(name, linkedResourcePath);
- }
-
- /**
- * Removes link between core resources and variable names.
- * @param linkedResources
- */
- public void removeLinkedCoreResources(Set<IPath> resources) {
- coreLinks.removeLinkedResources(resources);
- }
-
- /**
- * Removes link between core resource and variable names.
- * @param linkedResource
- */
- public void removeLinkedCoreResource(IPath resource) {
- coreLinks.removeLinkedResource(resource);
- }
-
- public Set<IPath> getCoreResourcesByVariableName(String variableName) {
- return coreLinks.getResourcesByVariableName(variableName);
- }
-
- public Set<String> getVariableNamesByCoreResource(IPath fullPath) {
- return coreLinks.getVariableNamesByResource(fullPath);
- }
-
- /**
- * Adds core resource without any link to any context variable name.
- * @param fullPath
- */
- public void addUnnamedCoreResource(IPath fullPath) {
- coreLinks.addUnnamedResource(fullPath);
- }
-
- /**
- * @return Set of coreresources without any link to any context variable name.
- * @param fullPath
- */
- public Set<IPath> getUnnamedCoreResources() {
- return coreLinks.getUnnamedResources();
- }
-
- /**
- * Removes unnamed EL resource.
- * @param fullPath
- */
- public void removeUnnamedCoreResource(IPath fullPath) {
- coreLinks.removeUnnamedResource(fullPath);
- }
-
- /**
- * Adds EL resource without any link to any context variable name.
- * @param fullPath
- */
- public void addUnnamedElResource(IPath fullPath) {
- elLinks.addUnnamedResource(fullPath);
- }
-
- /**
- * @return Set of EL resources without any link to any context variable name.
- * @param fullPath
- */
- public Set<IPath> getUnnamedElResources() {
- return elLinks.getUnnamedResources();
- }
-
- /**
- * Removes unnamed EL resource.
- * @param fullPath
- */
- public void removeUnnamedElResource(IPath fullPath) {
- elLinks.removeUnnamedResource(fullPath);
- }
-
- /**
- * We should validate all EL resources which use these names.
- * @param name
- */
- public void addVariableNameForELValidation(String name) {
- oldVariableNamesForELValidation.add(name);
- }
-
- /**
- * Save link between EL resource and variable name.
- * It's needed for incremental validation because we must save all linked resources
of changed java file.
- */
- public void addLinkedElResource(String variableName, IPath linkedResourcePath) {
- elLinks.addLinkedResource(variableName, linkedResourcePath);
- }
-
- /**
- * Removes link between resources and variable names.
- * @param linkedResources
- */
- public void removeLinkedElResources(Set<IPath> resources) {
- elLinks.removeLinkedResources(resources);
- }
-
- /**
- * Removes link between resource and variable names.
- * @param linkedResource
- */
- public void removeLinkedElResource(IPath resource) {
- elLinks.removeLinkedResource(resource);
- }
-
- /**
- * @param changedFiles - files which were changed.
- * @return Set of resources which we should validate during incremental EL validation.
- */
- public Set<IPath> getElResourcesForValidation(Set<IFile> changedFiles) {
- Set<IPath> result = new HashSet<IPath>();
- // Collect all resources which use old variables names.
- for(String name : oldVariableNamesForELValidation) {
- Set<IPath> oldResources = elLinks.getResourcesByVariableName(name);
- if(oldResources!=null) {
- result.addAll(oldResources);
- }
- }
- // Collect all resources which use new variables names
- for(IResource resource : changedFiles) {
- result.add(resource.getFullPath());
- Set<String> names = getVariableNamesByCoreResource(resource.getFullPath());
- if(names!=null) {
- for (String name : names) {
- Set<IPath> newResources = elLinks.getResourcesByVariableName(name);
- if(newResources!=null) {
- result.addAll(newResources);
- }
- }
- }
- }
-// result.addAll(elLinks.getUnnamedResources());
- return result;
- }
-
- public void clearAll() {
- removedFiles.clear();
- synchronized (registeredResources) {
- registeredResources.clear();
- }
- oldVariableNamesForELValidation.clear();
- coreLinks.clearAll();
- elLinks.clearAll();
- }
-
- public void clearAllResourceLinks() {
- oldVariableNamesForELValidation.clear();
- coreLinks.clearAll();
- elLinks.clearAll();
- }
-
- public void clearRegisteredFiles() {
- removedFiles.clear();
- synchronized (registeredResources) {
- registeredResources.clear();
- }
- }
-
- public void clearElResourceLinks() {
- oldVariableNamesForELValidation.clear();
- elLinks.clearAll();
- }
-
- public void clearOldVariableNameForElValidation() {
- oldVariableNamesForELValidation.clear();
- }
-
- public void store(Element root) {
- Element validation = XMLUtilities.createElement(root, "validation");
//$NON-NLS-1$
- Element core = XMLUtilities.createElement(validation, "core"); //$NON-NLS-1$
- coreLinks.store(core);
- Element el = XMLUtilities.createElement(validation, "el"); //$NON-NLS-1$
- elLinks.store(el);
- }
-
- public void load(Element root) {
- Element validation = XMLUtilities.getUniqueChild(root, "validation");
//$NON-NLS-1$
- if(validation == null) return;
- Element core = XMLUtilities.getUniqueChild(validation, "core");
//$NON-NLS-1$
- if(core != null) {
- coreLinks.load(core);
- }
- Element el = XMLUtilities.getUniqueChild(validation, "el"); //$NON-NLS-1$
- if(el != null) {
- elLinks.load(el);
- }
- }
-
- public Set<IFile> getRemovedFiles() {
- return removedFiles;
- }
-
- public void addRemovedFile(IFile file) {
- removedFiles.add(file);
- }
-
- public Set<IFile> getRegisteredFiles() {
- Set<IFile> copy = new HashSet<IFile>();
- synchronized (registeredResources) {
- copy.addAll(registeredResources);
- }
- return copy;
- }
-
- public void registerFile(IFile file) {
- synchronized (registeredResources) {
- registeredResources.add(file);
- }
- }
-
- public static class LinkCollection {
- private Map<String, Set<IPath>> resourcesByVariableName = new
HashMap<String, Set<IPath>>();
- private Map<IPath, Set<String>> variableNamesByResource = new
HashMap<IPath, Set<String>>();
- private Set<IPath> unnamedResources = new HashSet<IPath>();
-
- /**
- * Save link between resource and variable name.
- * It's needed for incremental validation because we must save all linked resources
of changed java file.
- */
- public void addLinkedResource(String variableName, IPath linkedResourcePath) {
- if(linkedResourcePath==null) {
- throw new
IllegalArgumentException(SeamCoreMessages.SEAM_VALIDATION_CONTEXT_LINKED_RESOURCE_PATH_MUST_NOT_BE_NULL);
- }
- if(variableName==null) {
- throw new
IllegalArgumentException(SeamCoreMessages.SEAM_VALIDATION_CONTEXT_VARIABLE_NAME_MUST_NOT_BE_NULL);
- }
-
- synchronized(this) {
- Set<IPath> linkedResources = resourcesByVariableName.get(variableName);
- if(linkedResources==null) {
- // create set of linked resources with variable name.
- linkedResources = new HashSet<IPath>();
- resourcesByVariableName.put(variableName, linkedResources);
- }
- // save linked resources.
- linkedResources.add(linkedResourcePath);
- }
-
- // Save link between resource and variable names. It's needed if variable name
changes in resource file.
- Set<String> variableNames = variableNamesByResource.get(linkedResourcePath);
- if(variableNames==null) {
- variableNames = new HashSet<String>();
- variableNamesByResource.put(linkedResourcePath, variableNames);
- }
- variableNames.add(variableName);
- }
-
- /**
- * Removes link between resource and variable name.
- * @param oldVariableName
- * @param linkedResourcePath
- */
- public void removeLinkedResource(String name, IPath linkedResourcePath) {
- synchronized(this) {
- Set<IPath> linkedResources = resourcesByVariableName.get(name);
- if(linkedResources!=null) {
- // remove linked resource.
- linkedResources.remove(linkedResourcePath);
- }
- }
- // Remove link between resource and variable names.
- Set<String> variableNames = variableNamesByResource.get(linkedResourcePath);
- if(variableNames!=null) {
- variableNames.remove(name);
- }
- }
-
- /**
- * Removes link between resources and variable names.
- * @param linkedResources
- */
- public void removeLinkedResources(Set<IPath> resources) {
- for (IPath resource : resources) {
- removeLinkedResource(resource);
- }
- }
-
- /**
- * Removes link between resource and variable names.
- * @param linkedResources
- */
- public synchronized void removeLinkedResource(IPath resource) {
- Set<String> resourceNames = variableNamesByResource.get(resource);
- if(resourceNames!=null) {
- for (String name : resourceNames) {
- Set<IPath> linkedResources = resourcesByVariableName.get(name);
- if(linkedResources!=null) {
- linkedResources.remove(resource);
- if(linkedResources.isEmpty()) {
- resourcesByVariableName.remove(name);
- }
- }
- }
- }
- variableNamesByResource.remove(resource);
- }
-
- public Set<IPath> getResourcesByVariableName(String variableName) {
- return resourcesByVariableName.get(variableName);
- }
-
- public synchronized Set<String> getVariableNamesByResource(IPath fullPath) {
- return variableNamesByResource.get(fullPath);
- }
-
- /**
- * Adds resource without any link to any context variable name.
- * @param fullPath
- */
- public void addUnnamedResource(IPath fullPath) {
- unnamedResources.add(fullPath);
- }
-
- /**
- * @return Set of resources without any link to any context variable name.
- * @param fullPath
- */
- public Set<IPath> getUnnamedResources() {
- return unnamedResources;
- }
-
- /**
- * Removes unnamed resource.
- * @param fullPath
- */
- public void removeUnnamedResource(IPath fullPath) {
- unnamedResources.remove(fullPath);
- }
-
- public synchronized void clearAll() {
- resourcesByVariableName.clear();
- variableNamesByResource.clear();
- unnamedResources.clear();
- }
-
- public synchronized void store(Element root) {
- Set<String> variables = resourcesByVariableName.keySet();
- for (String name: variables) {
- Set<IPath> paths = resourcesByVariableName.get(name);
- if(paths == null) continue;
- for (IPath path: paths) {
- Element linkedResource = XMLUtilities.createElement(root,
"linked-resource"); //$NON-NLS-1$
- linkedResource.setAttribute("name", name); //$NON-NLS-1$
- linkedResource.setAttribute("path", path.toString()); //$NON-NLS-1$
- }
- }
- for (IPath unnamedPath: unnamedResources) {
- Element unnamedPathElement = XMLUtilities.createElement(root,
"unnamed-path"); //$NON-NLS-1$
- unnamedPathElement.setAttribute("path", unnamedPath.toString());
//$NON-NLS-1$
- }
- }
-
- public void load(Element root) {
- if(root == null) return;
- Element[] linkedResources = XMLUtilities.getChildren(root,
"linked-resource"); //$NON-NLS-1$
- if(linkedResources != null) for (int i = 0; i < linkedResources.length; i++) {
- String name = linkedResources[i].getAttribute("name"); //$NON-NLS-1$
- if(name == null || name.trim().length() == 0) continue;
- String path = linkedResources[i].getAttribute("path"); //$NON-NLS-1$
- if(path == null || path.trim().length() == 0) continue;
- IPath pathObject = new Path(path);
- addLinkedResource(name, pathObject);
- }
- Element[] unnamedPathElement = XMLUtilities.getChildren(root,
"unnamed-path"); //$NON-NLS-1$
- if(unnamedPathElement != null) for (int i = 0; i < unnamedPathElement.length; i++)
{
- String path = unnamedPathElement[i].getAttribute("path"); //$NON-NLS-1$
- IPath pathObject = new Path(path);
- addUnnamedResource(pathObject);
- }
- }
- }
-}
\ No newline at end of file
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationContext.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationContext.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationContext.java 2009-07-03
20:54:55 UTC (rev 16379)
@@ -0,0 +1,253 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core.validation;
+
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.jboss.tools.seam.core.ISeamProject;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.core.SeamProjectsSet;
+import org.w3c.dom.Element;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class SeamValidationContext implements ISeamValidationContext {
+
+ private ISeamValidationContext rootContext;
+
+ public SeamValidationContext(IProject project) {
+ SeamProjectsSet set = new SeamProjectsSet(project);
+ IProject war = set.getWarProject();
+ if(war!=null) {
+ ISeamProject seamProject = SeamCorePlugin.getSeamProject(war, false);
+ if(seamProject!=null) {
+ rootContext = seamProject.getValidationContext();
+ }
+ }
+ if(rootContext==null) {
+ ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, false);
+ if(seamProject!=null) {
+ rootContext = seamProject.getValidationContext();
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#addLinkedCoreResource(java.lang.String,
org.eclipse.core.runtime.IPath, boolean)
+ */
+ public void addLinkedCoreResource(String variableName, IPath linkedResourcePath, boolean
declaration) {
+ rootContext.addLinkedCoreResource(variableName, linkedResourcePath, declaration);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#addLinkedEl(java.lang.String,
org.jboss.tools.seam.internal.core.validation.ELReference)
+ */
+ public void addLinkedEl(String variableName, ELReference el) {
+ rootContext.addLinkedEl(variableName, el);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#addRemovedFile(org.eclipse.core.resources.IFile)
+ */
+ public void addRemovedFile(IFile file) {
+ rootContext.addRemovedFile(file);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#addUnnamedCoreResource(org.eclipse.core.runtime.IPath)
+ */
+ public void addUnnamedCoreResource(IPath fullPath) {
+ rootContext.addUnnamedCoreResource(fullPath);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#addUnnamedElResource(org.eclipse.core.runtime.IPath)
+ */
+ public void addUnnamedElResource(IPath fullPath) {
+ rootContext.addUnnamedElResource(fullPath);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#addVariableNameForELValidation(java.lang.String)
+ */
+ public void addVariableNameForELValidation(String name) {
+ rootContext.addVariableNameForELValidation(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#clearAll()
+ */
+ public void clearAll() {
+ rootContext.clearAll();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#clearAllResourceLinks()
+ */
+ public void clearAllResourceLinks() {
+ rootContext.clearAllResourceLinks();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#clearElResourceLinks()
+ */
+ public void clearElResourceLinks() {
+ rootContext.clearElResourceLinks();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#clearOldVariableNameForElValidation()
+ */
+ public void clearOldVariableNameForElValidation() {
+ rootContext.clearOldVariableNameForElValidation();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#clearRegisteredFiles()
+ */
+ public void clearRegisteredFiles() {
+ rootContext.clearRegisteredFiles();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getCoreResourcesByVariableName(java.lang.String,
boolean)
+ */
+ public Set<IPath> getCoreResourcesByVariableName(String variableName, boolean
declaration) {
+ return rootContext.getCoreResourcesByVariableName(variableName, declaration);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getElsByVariableName(java.lang.String)
+ */
+ public Set<ELReference> getElsByVariableName(String variableName) {
+ return rootContext.getElsByVariableName(variableName);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getElsForValidation(java.util.Set,
boolean)
+ */
+ public Set<ELReference> getElsForValidation(Set<IFile> changedFiles, boolean
onlyChangedVariables) {
+ return rootContext.getElsForValidation(changedFiles, onlyChangedVariables);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getRegisteredFiles()
+ */
+ public Set<IFile> getRegisteredFiles() {
+ return rootContext.getRegisteredFiles();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getRemovedFiles()
+ */
+ public Set<IFile> getRemovedFiles() {
+ return rootContext.getRemovedFiles();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getUnnamedCoreResources()
+ */
+ public Set<IPath> getUnnamedCoreResources() {
+ return rootContext.getUnnamedCoreResources();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getUnnamedElResources()
+ */
+ public Set<IPath> getUnnamedElResources() {
+ return rootContext.getUnnamedElResources();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#getVariableNamesByCoreResource(org.eclipse.core.runtime.IPath,
boolean)
+ */
+ public Set<String> getVariableNamesByCoreResource(IPath fullPath, boolean
declaration) {
+ return rootContext.getVariableNamesByCoreResource(fullPath, declaration);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#load(org.w3c.dom.Element)
+ */
+ public void load(Element root) {
+ rootContext.load(root);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#registerFile(org.eclipse.core.resources.IFile)
+ */
+ public void registerFile(IFile file) {
+ rootContext.registerFile(file);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeLinkedCoreResource(org.eclipse.core.runtime.IPath)
+ */
+ public void removeLinkedCoreResource(IPath resource) {
+ rootContext.removeLinkedCoreResource(resource);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeLinkedCoreResource(java.lang.String,
org.eclipse.core.runtime.IPath)
+ */
+ public void removeLinkedCoreResource(String name, IPath linkedResourcePath) {
+ rootContext.removeLinkedCoreResource(name, linkedResourcePath);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeLinkedCoreResources(java.util.Set)
+ */
+ public void removeLinkedCoreResources(Set<IPath> resources) {
+ rootContext.removeLinkedCoreResources(resources);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeLinkedEl(java.lang.String,
org.jboss.tools.seam.internal.core.validation.ELReference)
+ */
+ public void removeLinkedEl(String name, ELReference el) {
+ rootContext.removeLinkedEl(name, el);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeLinkedEls(java.util.Set)
+ */
+ public void removeLinkedEls(Set<IFile> resorces) {
+ rootContext.removeLinkedEls(resorces);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeUnnamedCoreResource(org.eclipse.core.runtime.IPath)
+ */
+ public void removeUnnamedCoreResource(IPath fullPath) {
+ rootContext.removeUnnamedCoreResource(fullPath);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#removeUnnamedElResource(org.eclipse.core.runtime.IPath)
+ */
+ public void removeUnnamedElResource(IPath fullPath) {
+ rootContext.removeUnnamedElResource(fullPath);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.internal.core.validation.ISeamValidationContext#store(org.w3c.dom.Element)
+ */
+ public void store(Element root) {
+ rootContext.store(root);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java 2009-07-03
10:34:22 UTC (rev 16378)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java 2009-07-03
20:54:55 UTC (rev 16379)
@@ -41,15 +41,23 @@
*/
public class SeamValidationHelper extends WorkbenchContext {
+ protected ISeamProject seamProject;
+
/**
* @return Seam project
*/
public ISeamProject getSeamProject() {
- ISeamProject project = null;
- project = SeamCorePlugin.getSeamProject(getProject(), true);
- return project;
+ if(seamProject==null) {
+ ISeamProject project = null;
+ seamProject = SeamCorePlugin.getSeamProject(getProject(), true);
+ }
+ return seamProject;
}
+ public void setSeamProject(ISeamProject project) {
+ seamProject = project;
+ }
+
/**
* @return Java project
*/
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java 2009-07-03
10:34:22 UTC (rev 16378)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java 2009-07-03
20:54:55 UTC (rev 16379)
@@ -21,7 +21,7 @@
*/
public abstract class SeamValidator extends ValidationErrorManager implements
ISeamValidator {
- protected SeamValidationContext validationContext;
+ protected ISeamValidationContext validationContext;
protected String projectName;
/**
@@ -34,7 +34,7 @@
*/
public SeamValidator(IValidator validatorManager,
SeamContextValidationHelper coreHelper, IReporter reporter,
- SeamValidationContext validationContext, ISeamProject project) {
+ ISeamValidationContext validationContext, ISeamProject project) {
super(validatorManager, coreHelper, reporter, project, coreHelper.getProject(),
ISeamValidator.MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
this.validationContext = validationContext;
this.projectName = project.getProject().getName();
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidatorManager.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidatorManager.java 2009-07-03
10:34:22 UTC (rev 16378)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidatorManager.java 2009-07-03
20:54:55 UTC (rev 16379)
@@ -10,9 +10,11 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core.validation;
+import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.wst.validation.internal.core.ValidationException;
@@ -20,7 +22,8 @@
import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
import org.eclipse.wst.validation.internal.provisional.core.IValidatorJob;
import org.jboss.tools.seam.core.ISeamProject;
-import org.jboss.tools.seam.internal.core.SeamProject;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.core.SeamProjectsSet;
/**
* This Manager invokes all dependent seam validators that should be invoked in one job.
@@ -30,6 +33,8 @@
*/
public class SeamValidatorManager implements IValidatorJob {
+ private static Set<ISeamProject> validatingProjects = new
HashSet<ISeamProject>();
+
public SeamValidatorManager() {
super();
}
@@ -47,27 +52,43 @@
*/
public IStatus validateInJob(IValidationContext helper, IReporter reporter) throws
ValidationException {
SeamContextValidationHelper coreHelper = (SeamContextValidationHelper)helper;
- ISeamProject project = coreHelper.getSeamProject();
+ IProject project = coreHelper.getProject();
if(project==null) {
return OK_STATUS;
}
- SeamValidationContext validationContext =
((SeamProject)project).getValidationContext();
- IStatus status = null;
- try {
- ISeamValidator coreValidator = new SeamCoreValidator(this, coreHelper, reporter,
validationContext, project);
- ISeamValidator elValidator = new SeamELValidator(this, coreHelper, reporter,
validationContext, project);
- ISeamValidator[] validators = new ISeamValidator[]{coreValidator, elValidator};
+ SeamProjectsSet set = new SeamProjectsSet(project);
+ IProject warProject = set.getWarProject();
+ ISeamProject seamWarProject = SeamCorePlugin.getSeamProject(warProject, false);
+ IStatus status = OK_STATUS;
+ synchronized (validatingProjects) {
+ if(validatingProjects.contains(seamWarProject)) {
+ return OK_STATUS;
+ }
+ validatingProjects.add(seamWarProject);
+ }
+ synchronized (validatingProjects) {
+ ISeamValidationContext validationContext = null;
+ try {
+ coreHelper.setSeamProject(seamWarProject);
+ validationContext = new SeamValidationContext(project);
+ coreHelper.setValidationContext(validationContext);
+ ISeamValidator coreValidator = new SeamCoreValidator(this, coreHelper, reporter,
validationContext, seamWarProject);
+ ISeamValidator elValidator = new SeamELValidator(this, coreHelper, reporter,
validationContext, seamWarProject);
+ ISeamValidator[] validators = new ISeamValidator[]{coreValidator, elValidator};
- Set<IFile> changedFiles = coreHelper.getChangedFiles();
- if(!changedFiles.isEmpty()) {
- status = validate(validators, changedFiles);
- } else {
-// reporter.removeAllMessages(this);
- validationContext.clearAllResourceLinks();
- status = validateAll(validators);
+ Set<IFile> changedFiles = coreHelper.getChangedFiles();
+ if(!changedFiles.isEmpty()) {
+ status = validate(validators, changedFiles);
+ } else if(!validationContext.getRegisteredFiles().isEmpty()) {
+ validationContext.clearAllResourceLinks();
+ status = validateAll(validators);
+ }
+ } finally {
+ if(validationContext!=null) {
+ validationContext.clearRegisteredFiles();
+ }
+ validatingProjects.remove(seamWarProject);
}
- } finally {
- validationContext.clearRegisteredFiles();
}
return status;
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ValidationErrorManager.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ValidationErrorManager.java 2009-07-03
10:34:22 UTC (rev 16378)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/ValidationErrorManager.java 2009-07-03
20:54:55 UTC (rev 16379)
@@ -12,12 +12,14 @@
import java.util.Set;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.wst.validation.internal.TaskListUtility;
import org.eclipse.wst.validation.internal.core.Message;
import org.eclipse.wst.validation.internal.operations.WorkbenchReporter;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
@@ -75,10 +77,10 @@
* org.jboss.tools.seam.core.ISeamTextSourceReference,
* org.eclipse.core.resources.IResource)
*/
- public void addError(String messageId, String preferenceKey,
+ public IMarker addError(String messageId, String preferenceKey,
String[] messageArguments, ITextSourceReference location,
IResource target) {
- addError(messageId, preferenceKey, messageArguments, location
+ return addError(messageId, preferenceKey, messageArguments, location
.getLength(), location.getStartPosition(), target);
}
@@ -90,17 +92,17 @@
* org.jboss.tools.seam.core.ISeamTextSourceReference,
* org.eclipse.core.resources.IResource)
*/
- public void addError(String messageId, String preferenceKey,
+ public IMarker addError(String messageId, String preferenceKey,
ITextSourceReference location, IResource target) {
- addError(messageId, preferenceKey, new String[0], location, target);
+ return addError(messageId, preferenceKey, new String[0], location, target);
}
/* (non-Javadoc)
* @see
org.jboss.tools.seam.internal.core.validation.IValidationErrorManager#addError(java.lang.String,
java.lang.String, java.lang.String[], org.eclipse.core.resources.IResource)
*/
- public void addError(String messageId, String preferenceKey,
+ public IMarker addError(String messageId, String preferenceKey,
String[] messageArguments, IResource target) {
- addError(messageId, preferenceKey, messageArguments, 0, 0, target);
+ return addError(messageId, preferenceKey, messageArguments, 0, 0, target);
}
private String getMarkerId() {
@@ -109,12 +111,9 @@
/*
* (non-Javadoc)
- *
- * @see
org.jboss.tools.seam.internal.core.validation.IValidationErrorManager#addError(java.lang.String,
- * java.lang.String, java.lang.String[], int, int,
- * org.eclipse.core.resources.IResource)
+ * @see
org.jboss.tools.seam.internal.core.validation.IValidationErrorManager#addError(java.lang.String,
java.lang.String, java.lang.String[], int, int, org.eclipse.core.resources.IResource)
*/
- public void addError(String messageId, String preferenceKey,
+ public IMarker addError(String messageId, String preferenceKey,
String[] messageArguments, int length, int offset, IResource target) {
String preferenceValue = SeamPreferences.getProjectPreference(target.getProject(),
preferenceKey);
if(preferenceValue==null && seamProject!=null) {
@@ -129,7 +128,7 @@
}
if (ignore) {
- return;
+ return null;
}
IMessage message = new Message(getBaseName(), messageSeverity,
@@ -147,27 +146,33 @@
SeamCorePlugin.getPluginLog().logError(
"Exception occurred during error line number calculation",
e);
- return;
+ return null;
} catch (CoreException e) {
SeamCorePlugin.getPluginLog().logError(
"Exception occurred during error line number calculation",
e);
- return;
+ return null;
} finally {
if(coreHelper!=null) {
coreHelper.getDocumentProvider().disconnect(target);
}
}
- WorkbenchReporter.addMessage(target, this.getClass(), message, null,
""+message.getLineNumber());
-// reporter.addMessage(validationManager, message);
+ int severity = message.getSeverity();
+ try {
+ return TaskListUtility.addTask(this.getClass().getName().intern(), target,
""+message.getLineNumber(), message.getId(),
+ message.getText(this.getClass().getClassLoader()), severity, null,
message.getGroupName(), message.getOffset(), message.getLength());
+ } catch (CoreException e) {
+ SeamCorePlugin.getDefault().logError(e);
+ }
+ return null;
}
/*
* (non-Javadoc)
* @see
org.jboss.tools.seam.internal.core.validation.IValidationErrorManager#addError(java.lang.String,
int, java.lang.String[], int, int, org.eclipse.core.resources.IResource)
*/
- public void addError(String messageId, int severity, String[] messageArguments, int
length, int offset, IResource target) {
+ public IMarker addError(String messageId, int severity, String[] messageArguments, int
length, int offset, IResource target) {
IMessage message = new Message(getBaseName(), severity,
messageId, messageArguments, target,
getMarkerId());
@@ -183,15 +188,21 @@
SeamCorePlugin.getPluginLog().logError(
"Exception occurred during error line number calculation",
e);
- return;
+ return null;
} catch (CoreException e) {
SeamCorePlugin.getPluginLog().logError(
"Exception occurred during error line number calculation",
e);
- return;
+ return null;
}
- WorkbenchReporter.addMessage(target, this.getClass(), message, null,
""+message.getLineNumber());
-// reporter.addMessage(validationManager, message);
+
+ try {
+ return TaskListUtility.addTask(this.getClass().getName().intern(), target,
""+message.getLineNumber(), message.getId(),
+ message.getText(this.getClass().getClassLoader()), severity, null,
message.getGroupName(), message.getOffset(), message.getLength());
+ } catch (CoreException e) {
+ SeamCorePlugin.getDefault().logError(e);
+ }
+ return null;
}
/*