Author: akazakov
Date: 2009-06-09 16:55:12 -0400 (Tue, 09 Jun 2009)
New Revision: 15829
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/WEB-INF/duplicateComponents.test
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/DuplicateComponent.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.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-4393
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-06-09
16:39:22 UTC (rev 15828)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2009-06-09
20:55:12 UTC (rev 15829)
@@ -497,10 +497,11 @@
validationContext.addLinkedCoreResource(componentName, declaration.getSourcePath());
+ String precedence = declaration.getPrecedence();
if(firstNamedDeclaration == null && declaration.getName()!=null) {
- firstNamedDeclaration = declaration;
+ firstNamedDeclaration = declaration;
+ usedPrecedences.put(precedence, declaration);
}
- String precedence = declaration.getPrecedence();
if(declaration.getName()!=null && firstNamedDeclaration!=declaration) {
// Check precedence
ISeamXmlComponentDeclaration checkedDeclaration = usedPrecedences.get(precedence);
@@ -527,25 +528,31 @@
}
// Check Java declarations with the same name
- Set<ISeamComponentDeclaration> decls = component.getAllDeclarations();
- for (ISeamComponentDeclaration dec : decls) {
- if(dec instanceof ISeamJavaComponentDeclaration) {
- ISeamJavaComponentDeclaration javaDec = (ISeamJavaComponentDeclaration)dec;
- // Check names
- if(javaDec.getName()!=null &&
javaDec.getName().equals(declaration.getName())) {
- // Check precedences
- String javaPrecedence = "" + javaDec.getPrecedence();
- if(javaPrecedence.equals(precedence)) {
- if(!markedJavaDeclarations.contains(javaDec)) {
- markedJavaDeclarations.add(javaDec);
- ITextSourceReference location =
((SeamComponentDeclaration)javaDec).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
- addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID,
SeamPreferences.NONUNIQUE_COMPONENT_NAME, new String[]{componentName}, location,
declaration.getResource());
+ Set<ISeamContextVariable> vars =
seamProject.getVariablesByName(componentName);
+ for (ISeamContextVariable variable : vars) {
+ if(variable instanceof ISeamComponent) {
+ ISeamComponent c = (ISeamComponent)variable;
+ Set<ISeamComponentDeclaration> decls = c.getAllDeclarations();
+ for (ISeamComponentDeclaration dec : decls) {
+ if(dec instanceof ISeamJavaComponentDeclaration) {
+ ISeamJavaComponentDeclaration javaDec = (ISeamJavaComponentDeclaration)dec;
+ // Check names
+ if(javaDec.getName()!=null &&
javaDec.getName().equals(declaration.getName())) {
+ // Check precedences
+ String javaPrecedence = "" + javaDec.getPrecedence();
+ if(javaPrecedence.equals(precedence)) {
+ if(!markedJavaDeclarations.contains(javaDec)) {
+ markedJavaDeclarations.add(javaDec);
+ ITextSourceReference location =
((SeamComponentDeclaration)javaDec).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
+ addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID,
SeamPreferences.NONUNIQUE_COMPONENT_NAME, new String[]{componentName}, location,
javaDec.getResource());
+ }
+ if(!markedDeclarations.contains(declaration)) {
+ markedDeclarations.add(declaration);
+ ITextSourceReference location =
((SeamComponentDeclaration)declaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
+ addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID,
SeamPreferences.NONUNIQUE_COMPONENT_NAME, new String[]{componentName}, location,
declaration.getResource());
+ }
+ }
}
- if(!markedJavaDeclarations.contains(javaDec)) {
- markedDeclarations.add(declaration);
- ITextSourceReference location =
((SeamComponentDeclaration)declaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
- addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID,
SeamPreferences.NONUNIQUE_COMPONENT_NAME, new String[]{componentName}, location,
declaration.getResource());
- }
}
}
}
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/WEB-INF/duplicateComponents.test
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/WEB-INF/duplicateComponents.test
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/WEB-INF/duplicateComponents.test 2009-06-09
20:55:12 UTC (rev 15829)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components
xmlns="http://jboss.com/products/seam/components"
+
xmlns:core="http://jboss.com/products/seam/core"
+ xsi:schemaLocation=
+ "http://jboss.com/products/seam/core
http://jboss.com/products/seam/core-1.2.xsd
+
http://jboss.com/products/seam/components
http://jboss.com/products/seam/components-1.2.xsd">
+
+ <component
class="org.domain.SeamWebWarTestProject.session.DuplicateComponent"
name="duplicateJavaAndXmlComponentName" precedence="20" />
+ <component
class="org.domain.SeamWebWarTestProject.session.DuplicateComponent"
name="duplicateJavaAndXmlComponentName" precedence="20" />
+
+</components>
\ No newline at end of file
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/DuplicateComponent.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/DuplicateComponent.java
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/DuplicateComponent.java 2009-06-09
20:55:12 UTC (rev 15829)
@@ -0,0 +1,7 @@
+package org.domain.SeamWebWarTestProject.session;
+
+import org.jboss.seam.annotations.Name;
+
+@Name("duplicateJavaAndXmlComponentName")
+public class DuplicateComponent {
+}
\ 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/session/DuplicateComponent.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-09
16:39:22 UTC (rev 15828)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2009-06-09
20:55:12 UTC (rev 15829)
@@ -100,7 +100,7 @@
// Test for
http://jira.jboss.com/jira/browse/JBIDE-999
IFile file = project.getFile("WebContent/varAttributes.xhtml");
int number = getMarkersNumber(file);
- assertTrue("Problem marker was found in varAttributes.xhtml file. Validator did
not recognize 'var' attribute.", number == 0);
+ assertEquals("Problem marker was found in varAttributes.xhtml file. Validator did
not recognize 'var' attribute.", 0, number);
}
public void testJiraJbide1696() throws CoreException {
@@ -305,7 +305,7 @@
"'BbcComponent.3'", ex);
}
}
-
+
public void testEntitiesValidator() {
IFile abcEntityFile =
project.getFile("src/action/org/domain/SeamWebWarTestProject/entity/abcEntity.java");
@@ -828,6 +828,29 @@
assertEquals("Seam tools validator does not see annotated methods declared in
super class", 0, errorsCount);
}
+ // See
https://jira.jboss.org/jira/browse/JBIDE-4393
+ public void testDuplicateComponents() {
+ JobUtils.waitForIdle();
+ IFile duplicateJavaComponentFile =
project.getFile("src/action/org/domain/SeamWebWarTestProject/session/DuplicateComponent.java");
+ IFile componentsXmlFile =
project.getFile("WebContent/WEB-INF/components.xml");
+
+ IFile duplicateComponentsXmlFile =
project.getFile("WebContent/WEB-INF/duplicateComponents.test");
+ try{
+ componentsXmlFile.setContents(duplicateComponentsXmlFile.getContents(), true, false,
null);
+ }catch(Exception ex){
+ JUnitUtils.fail("Error in changing 'components.xml' content to
'duplicateComponents.test'", ex);
+ }
+ JobUtils.waitForIdle();
+ int[] lineNumbers = getMarkersNumbersOfLine(duplicateJavaComponentFile);
+ assertEquals("There shuold be the only one error marker in
DuplicateComponent.java.", 1, lineNumbers.length);
+ assertEquals("Problem marker has wrong line number", 5, lineNumbers[0]);
+
+ lineNumbers = getMarkersNumbersOfLine(componentsXmlFile);
+ assertEquals("There shuold be two error marker in components.xml.", 2,
lineNumbers.length);
+ assertEquals("Problem marker has wrong line number", 8, lineNumbers[0]);
+ assertEquals("Problem marker has wrong line number", 9, lineNumbers[1]);
+ }
+
private void modifyPreferences(){
IPreferenceStore store = SeamCorePlugin.getDefault().getPreferenceStore();
store.putValue(SeamPreferences.UNKNOWN_EL_VARIABLE_NAME, SeamPreferences.ERROR);