Author: akazakov
Date: 2007-07-12 13:17:08 -0400 (Thu, 12 Jul 2007)
New Revision: 2411
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaValidator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/messages.properties
Log:
http://jira.jboss.com/jira/browse/EXIN-327 Ignore duplicate @Name in jars
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaValidator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaValidator.java 2007-07-12
16:33:22 UTC (rev 2410)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaValidator.java 2007-07-12
17:17:08 UTC (rev 2411)
@@ -23,6 +23,7 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
import org.eclipse.wst.validation.internal.core.ValidationException;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
@@ -180,38 +181,43 @@
usedPrecedences.put(firstJavaDeclarationPrecedence, firstJavaDeclaration);
Set<ISeamComponentDeclaration> declarations = component.getAllDeclarations();
for (ISeamComponentDeclaration declaration : declarations) {
- if(declaration instanceof ISeamJavaComponentDeclaration &&
declaration.getResource() instanceof IFile) {
- // Save link between component name and java source file.
- validationContext.addLinkedResource(declaration.getName(),
declaration.getSourcePath());
- // Validate all elements in declaration but @Name.
- validateJavaDeclaration(project, firstJavaDeclaration, helper, reporter);
- }
- if(declaration instanceof ISeamJavaComponentDeclaration &&
declaration!=firstJavaDeclaration) {
- // Validate @Name
- // Component class with the same component name. Check precedence.
- ISeamJavaComponentDeclaration javaDeclaration =
(ISeamJavaComponentDeclaration)declaration;
- int javaDeclarationPrecedence = javaDeclaration.getPrecedence();
- ISeamJavaComponentDeclaration checkedDeclaration =
usedPrecedences.get(javaDeclarationPrecedence);
- if(checkedDeclaration==null) {
- usedPrecedences.put(javaDeclarationPrecedence, javaDeclaration);
- } else {
- IResource javaDeclarationResource = javaDeclaration.getResource();
- // Mark nonunique name.
- if(!markedDeclarations.contains(checkedDeclaration)) {
- // Mark first wrong declaration with that name
- IResource checkedDeclarationResource = checkedDeclaration.getResource();
- ISeamTextSourceReference location =
((SeamComponentDeclaration)checkedDeclaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
+ if(declaration instanceof ISeamJavaComponentDeclaration) {
+ ISeamJavaComponentDeclaration jd = (ISeamJavaComponentDeclaration)declaration;
+ boolean sourceJavaDeclaration = !((IType)jd.getSourceMember()).isBinary();
+ if(sourceJavaDeclaration) {
+ // Save link between component name and java source file.
+ validationContext.addLinkedResource(declaration.getName(),
declaration.getSourcePath());
+ // Validate all elements in declaration but @Name.
+ validateJavaDeclaration(project, firstJavaDeclaration, helper, reporter);
+ }
+ if(declaration!=firstJavaDeclaration) {
+ // Validate @Name
+ // Component class with the same component name. Check precedence.
+ ISeamJavaComponentDeclaration javaDeclaration =
(ISeamJavaComponentDeclaration)declaration;
+ int javaDeclarationPrecedence = javaDeclaration.getPrecedence();
+ ISeamJavaComponentDeclaration checkedDeclaration =
usedPrecedences.get(javaDeclarationPrecedence);
+ boolean sourceCheckedDeclaration =
!((IType)checkedDeclaration.getSourceMember()).isBinary();
+ if(checkedDeclaration==null) {
+ usedPrecedences.put(javaDeclarationPrecedence, javaDeclaration);
+ } else if(sourceJavaDeclaration) {
+ IResource javaDeclarationResource = javaDeclaration.getResource();
+ // Mark nonunique name.
+ if(!markedDeclarations.contains(checkedDeclaration) &&
sourceCheckedDeclaration) {
+ // Mark first wrong declaration with that name
+ IResource checkedDeclarationResource = checkedDeclaration.getResource();
+ ISeamTextSourceReference location =
((SeamComponentDeclaration)checkedDeclaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
+ if(location!=null) {
+ addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID, new String[]{component.getName()},
location, checkedDeclarationResource, MARKED_COMPONENT_MESSAGE_GROUP);
+ }
+ markedDeclarations.add(checkedDeclaration);
+ }
+ // Mark next wrong declaration with that name
+ markedDeclarations.add(javaDeclaration);
+ ISeamTextSourceReference location =
((SeamComponentDeclaration)javaDeclaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
if(location!=null) {
- addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID, new String[]{component.getName()},
location, checkedDeclarationResource, MARKED_COMPONENT_MESSAGE_GROUP);
+ addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID, new String[]{component.getName()},
location, javaDeclarationResource, MARKED_COMPONENT_MESSAGE_GROUP);
}
- markedDeclarations.add(checkedDeclaration);
}
- // Mark next wrong declaration with that name
- markedDeclarations.add(javaDeclaration);
- ISeamTextSourceReference location =
((SeamComponentDeclaration)javaDeclaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
- if(location!=null) {
- addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID, new String[]{component.getName()},
location, javaDeclarationResource, MARKED_COMPONENT_MESSAGE_GROUP);
- }
}
}
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/messages.properties
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/messages.properties 2007-07-12
16:33:22 UTC (rev 2410)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/messages.properties 2007-07-12
17:17:08 UTC (rev 2411)
@@ -8,10 +8,10 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
-NONUNIQUE_COMPONENT_NAME_MESSAGE=Duplicate component name {0}
+NONUNIQUE_COMPONENT_NAME_MESSAGE=Duplicate component name: {0}
UNKNOWN_INJECTION_NAME=Unknown context variable name: {0}
-STATEFUL_COMPONENT_DOES_NOT_CONTENT_REMOVE=Stateful component {0} must have a method
marked @Remove
-STATEFUL_COMPONENT_DOES_NOT_CONTENT_DESTROY=Stateful component {0} must have a method
marked @Destroy
-STATEFUL_COMPONENT_WRONG_SCOPE=Stateful component {0} should not have
org.jboss.seam.ScopeType.PAGE, nor org.jboss.seam.ScopeType.STATELESS
-STATEFUL_COMPONENT_DUPLICATE_REMOVE=Duplicate @Remove method {0}
-STATEFUL_COMPONENT_DUPLICATE_DESTROY=Duplicate @Destroy method {0}
\ No newline at end of file
+STATEFUL_COMPONENT_DOES_NOT_CONTENT_REMOVE=Stateful component '{0}' must have a
method marked @Remove
+STATEFUL_COMPONENT_DOES_NOT_CONTENT_DESTROY=Stateful component '{0}' must have a
method marked @Destroy
+STATEFUL_COMPONENT_WRONG_SCOPE=Stateful component '{0}' should not have
org.jboss.seam.ScopeType.PAGE, nor org.jboss.seam.ScopeType.STATELESS
+STATEFUL_COMPONENT_DUPLICATE_REMOVE=Duplicate @Remove method '{0}'
+STATEFUL_COMPONENT_DUPLICATE_DESTROY=Duplicate @Destroy method '{0}'
\ No newline at end of file