Author: akazakov
Date: 2009-06-19 17:05:45 -0400 (Fri, 19 Jun 2009)
New Revision: 16091
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/testElRevalidation.xhtml
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/entity/TestElRevalidation.java
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/entity/TestElRevalidation.new
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/entity/TestElRevalidation.original
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPreferenceInitializer.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4512 Fixed
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java 2009-06-19
21:05:09 UTC (rev 16090)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java 2009-06-19
21:05:45 UTC (rev 16091)
@@ -117,6 +117,8 @@
public static final String UNKNOWN_EL_VARIABLE_NAME =
createSeverityOption("unknownElVariableName"); //$NON-NLS-1$
// Check "var" attributes.
public static final String CHECK_VARS = createSeverityOption("checkVars");
//$NON-NLS-1$
+ // Re-validate unresolved ELs.
+ public static final String RE_VALIDATE_UNRESOLVED_EL =
createSeverityOption("revalidateUnresolvedEl"); //$NON-NLS-1$
// Mark EL Variable property name which we can't resolve.
public static final String UNKNOWN_EL_VARIABLE_PROPERTY_NAME =
createSeverityOption("unknownElVariablePropertyName"); //$NON-NLS-1$
// If Expression use property of component and this property has only setter(getter)
without getter(setter) then mark it.
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPreferenceInitializer.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPreferenceInitializer.java 2009-06-19
21:05:09 UTC (rev 16090)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPreferenceInitializer.java 2009-06-19
21:05:45 UTC (rev 16091)
@@ -39,6 +39,7 @@
defaultPreferences.put(SeamPreferences.EL_SYNTAX_ERROR, SeamPreferences.WARNING);
defaultPreferences.put(SeamPreferences.INVALID_XML_VERSION, SeamPreferences.WARNING);
defaultPreferences.put(SeamPreferences.CHECK_VARS, SeamPreferences.ENABLE);
+ defaultPreferences.put(SeamPreferences.RE_VALIDATE_UNRESOLVED_EL,
SeamPreferences.ENABLE);
//JBIDE-2958 temporary until JBIDE-2957 solved //TODO solve JBIDE-2957
defaultPreferences.put(SeamPreferences.UNKNOWN_COMPONENT_CLASS_NAME_GUESS,
SeamPreferences.WARNING);
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-06-19
21:05:09 UTC (rev 16090)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java 2009-06-19
21:05:45 UTC (rev 16091)
@@ -55,6 +55,7 @@
import org.jboss.tools.common.el.core.model.ELInstance;
import org.jboss.tools.common.el.core.model.ELInvocationExpression;
import org.jboss.tools.common.el.core.model.ELModel;
+import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
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;
@@ -92,6 +93,7 @@
private IProject currentProject;
private IResource[] currentSources;
private IContainer webRootFolder;
+ private boolean revalidateUnresolvedELs = false;
public SeamELValidator(SeamValidatorManager validatorManager,
SeamContextValidationHelper coreHelper, IReporter reporter,
@@ -113,6 +115,7 @@
* @see
org.jboss.tools.seam.internal.core.validation.ISeamValidator#validate(java.util.Set)
*/
public IStatus validate(Set<IFile> changedFiles) throws ValidationException {
+ initRevalidationFlag();
IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
Set<IPath> files = validationContext.getElResourcesForValidation(changedFiles);
validationContext.removeLinkedElResources(files);
@@ -131,11 +134,13 @@
}
if(containsJavaOrComponentsXml) {
- Set<IPath> unnamedResources = validationContext.getUnnamedElResources();
- for (IPath path : unnamedResources) {
- IFile file = wsRoot.getFile(path);
- if(file.exists()) {
- filesToValidate.add(file);
+ if(revalidateUnresolvedELs) {
+ Set<IPath> unnamedResources = validationContext.getUnnamedElResources();
+ for (IPath path : unnamedResources) {
+ IFile file = wsRoot.getFile(path);
+ if(file.exists()) {
+ filesToValidate.add(file);
+ }
}
}
}
@@ -148,11 +153,17 @@
return OK_STATUS;
}
+ private void initRevalidationFlag() {
+ String revalidateUnresolvedEls = SeamPreferences.getProjectPreference(project,
SeamPreferences.RE_VALIDATE_UNRESOLVED_EL);
+ revalidateUnresolvedELs = SeamPreferences.ENABLE.equals(revalidateUnresolvedEls);
+ }
+
/*
* (non-Javadoc)
* @see org.jboss.tools.seam.internal.core.validation.ISeamValidator#validateAll()
*/
public IStatus validateAll() throws ValidationException {
+ initRevalidationFlag();
validationContext.clearElResourceLinks();
Set<IFile> files = validationContext.getRegisteredFiles();
for (IFile file : files) {
@@ -338,7 +349,6 @@
// 2) create other preference
addError(SYNTAX_ERROR_MESSAGE_ID, SeamPreferences.EL_SYNTAX_ERROR, new
String[]{"" + error.getProblem()}, 1, offset + error.getPosition(), file);
}
-
}
List<ELInstance> is = model.getInstances();
for (ELInstance i : is) {
@@ -375,8 +385,14 @@
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());
+ }
+ }
// Save resources with unknown variables names
- validationContext.addUnnamedElResource(file.getFullPath());
+// validationContext.addUnnamedElResource(file.getFullPath());
}
// Save links between resource and used variables names
@@ -429,4 +445,17 @@
}
}
-}
+ private Set<String> findVariableNames(ELInvocationExpression
invocationExpression){
+ Set<String> names = new HashSet<String>();
+ while(invocationExpression != null) {
+ if(invocationExpression instanceof ELPropertyInvocation) {
+ String name = ((ELPropertyInvocation)invocationExpression).getQualifiedName();
+ if(name != null) {
+ names.add(name);
+ }
+ }
+ invocationExpression = invocationExpression.getLeft();
+ }
+ return names;
+ }
+}
\ No newline at end of file
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/testElRevalidation.xhtml
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/testElRevalidation.xhtml
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/testElRevalidation.xhtml 2009-06-19
21:05:45 UTC (rev 16091)
@@ -0,0 +1,8 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+<ui:define name="body">
+ #{testElRevalidation}
+ </ui:define>
+</ui:composition>
\ No newline at end of file
Property changes on:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/testElRevalidation.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/entity/TestElRevalidation.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/entity/TestElRevalidation.java
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/entity/TestElRevalidation.java 2009-06-19
21:05:45 UTC (rev 16091)
@@ -0,0 +1,7 @@
+package org.domain.SeamWebWarTestProject.entity;
+
+import org.jboss.seam.annotations.Name;
+
+@Name("testElRevalidation")
+public class TestElRevalidation {
+}
\ No newline at end of file
Property changes on:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/entity/TestElRevalidation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/entity/TestElRevalidation.new
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/entity/TestElRevalidation.new
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/entity/TestElRevalidation.new 2009-06-19
21:05:45 UTC (rev 16091)
@@ -0,0 +1,7 @@
+package org.domain.SeamWebWarTestProject.entity;
+
+import org.jboss.seam.annotations.Name;
+
+@Name("testElRevalidationNew")
+public class TestElRevalidation {
+}
\ No newline at end of file
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/entity/TestElRevalidation.original
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/entity/TestElRevalidation.original
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/entity/TestElRevalidation.original 2009-06-19
21:05:45 UTC (rev 16091)
@@ -0,0 +1,7 @@
+package org.domain.SeamWebWarTestProject.entity;
+
+import org.jboss.seam.annotations.Name;
+
+@Name("testElRevalidation")
+public class TestElRevalidation {
+}
\ No newline at end of file
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2009-06-19
21:05:09 UTC (rev 16090)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2009-06-19
21:05:45 UTC (rev 16091)
@@ -833,7 +833,7 @@
// See
https://jira.jboss.org/jira/browse/JBIDE-4393
public void testDuplicateComponents() {
- JobUtils.waitForIdle();
+ refreshProject(project);
IFile duplicateJavaComponentFile =
project.getFile("src/action/org/domain/SeamWebWarTestProject/session/DuplicateComponent.java");
IFile componentsXmlFile =
project.getFile("WebContent/WEB-INF/components.xml");
@@ -843,7 +843,7 @@
}catch(Exception ex){
JUnitUtils.fail("Error in changing 'components.xml' content to
'duplicateComponents.test'", ex);
}
- JobUtils.waitForIdle();
+ refreshProject(project);
Integer[] lineNumbers = getMarkersNumbersOfLine(duplicateJavaComponentFile,
SEAM_MARKER_FILTER);
assertEquals("There should be the only one error marker in
DuplicateComponent.java.", 1, lineNumbers.length);
assertEquals("Problem marker has wrong line number", 5,
lineNumbers[0].intValue());
@@ -854,6 +854,54 @@
assertTrue("Problem marker was not found on 9 line", findLine(lineNumbers,
9));
}
+ // See
https://jira.jboss.org/jira/browse/JBIDE-4515
+ public void testRevalidationUnresolvedELs() {
+ refreshProject(project);
+ SeamCorePlugin.getDefault().getPreferenceStore().setValue(SeamPreferences.RE_VALIDATE_UNRESOLVED_EL,
SeamPreferences.ENABLE);
+
+ IFile componentFile =
project.getFile("src/action/org/domain/SeamWebWarTestProject/entity/TestElRevalidation.java");
+ IFile newComponentFile =
project.getFile("src/action/org/domain/SeamWebWarTestProject/entity/TestElRevalidation.new");
+ IFile originalComponentFile =
project.getFile("src/action/org/domain/SeamWebWarTestProject/entity/TestElRevalidation.original");
+ IFile xhtmlFile = project.getFile("WebContent/testElRevalidation.xhtml");
+
+ try {
+ componentFile.setContents(newComponentFile.getContents(), true, false, null);
+ } catch(Exception ex) {
+ JUnitUtils.fail("Error in changing 'TestElRevalidation.new' content to
'TestElRevalidation.java'", ex);
+ }
+ refreshProject(project);
+
+ int n = getMarkersNumber(xhtmlFile, SEAM_MARKER_FILTER);
+ assertEquals("There should be an unresolved EL in testElRevalidation.xhtml.",
1, n);
+
+ // We have to change the java file twice to clean all relations between xhtml and java.
+ SeamCorePlugin.getDefault().getPreferenceStore().setValue(SeamPreferences.RE_VALIDATE_UNRESOLVED_EL,
SeamPreferences.DISABLE);
+ try {
+ componentFile.setContents(originalComponentFile.getContents(), true, false, null);
+ } catch(Exception ex) {
+ JUnitUtils.fail("Error in changing 'TestElRevalidation.original' content
to 'TestElRevalidation.java'", ex);
+ }
+ refreshProject(project);
+ try {
+ componentFile.setContents(newComponentFile.getContents(), true, false, null);
+ } catch(Exception ex) {
+ JUnitUtils.fail("Error in changing 'TestElRevalidation.new' content to
'TestElRevalidation.java'", ex);
+ }
+ // then we can check if validator was not invoked.
+ refreshProject(project);
+ try {
+ componentFile.setContents(originalComponentFile.getContents(), true, false, null);
+ } catch(Exception ex) {
+ JUnitUtils.fail("Error in changing 'TestElRevalidation.original' content
to 'TestElRevalidation.java'", ex);
+ }
+ refreshProject(project);
+
+ n = getMarkersNumber(xhtmlFile, SEAM_MARKER_FILTER);
+ assertEquals("There should be an unresolved EL in testElRevalidation.xhtml.",
1, n);
+
+ SeamCorePlugin.getDefault().getPreferenceStore().setValue(SeamPreferences.RE_VALIDATE_UNRESOLVED_EL,
SeamPreferences.ENABLE);
+ }
+
private static boolean findLine(Integer[] lines, int number) {
for (int i = 0; i < lines.length; i++) {
if(lines[i]==number) {