Author: scabanovich
Date: 2008-04-17 10:46:29 -0400 (Thu, 17 Apr 2008)
New Revision: 7578
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/SeamValidationHelper.java
Log:
JBIDE-2080
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 2008-04-17
14:21:34 UTC (rev 7577)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2008-04-17
14:46:29 UTC (rev 7578)
@@ -359,6 +359,10 @@
for (ISeamComponentDeclaration declaration : declarations) {
if(declaration instanceof ISeamJavaComponentDeclaration) {
ISeamJavaComponentDeclaration jd = (ISeamJavaComponentDeclaration)declaration;
+
+ //do not check files declared in another project
+ if(jd.getSeamProject() != project) continue;
+
IType type = (IType)jd.getSourceMember();
boolean sourceJavaDeclaration = !type.isBinary();
if(sourceJavaDeclaration) {
@@ -393,7 +397,7 @@
// Mark first wrong declaration with that name
IResource checkedDeclarationResource = checkedDeclaration.getResource();
ISeamTextSourceReference location =
((SeamComponentDeclaration)checkedDeclaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
- if(location!=null) {
+ if(!isEmptyLocation(location)) {
addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID,
SeamPreferences.NONUNIQUE_COMPONENT_NAME, new String[]{componentName}, location,
checkedDeclarationResource);
}
markedDeclarations.add(checkedDeclaration);
@@ -401,7 +405,7 @@
// Mark next wrong declaration with that name
markedDeclarations.add(javaDeclaration);
ISeamTextSourceReference location =
((SeamComponentDeclaration)javaDeclaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
- if(location!=null) {
+ if(!isEmptyLocation(location)) {
addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID,
SeamPreferences.NONUNIQUE_COMPONENT_NAME, new String[]{componentName}, location,
javaDeclarationResource);
}
}
@@ -437,10 +441,10 @@
if(type==null) {
// Mark wrong class name
ISeamTextSourceReference location =
((SeamComponentDeclaration)declaration).getLocationFor(ISeamXmlComponentDeclaration.CLASS);
- if(location==null) {
+ if(isEmptyLocation(location)) {
location =
((SeamComponentDeclaration)declaration).getLocationFor(ISeamXmlComponentDeclaration.NAME);
}
- if(location==null) {
+ if(isEmptyLocation(location)) {
location = declaration;
}
addError(UNKNOWN_COMPONENT_CLASS_NAME_MESSAGE_ID,
SeamPreferences.UNKNOWN_COMPONENT_CLASS_NAME, new String[]{className}, location,
declaration.getResource());
@@ -470,6 +474,15 @@
}
}
}
+
+ static boolean isEmptyLocation(ISeamTextSourceReference location) {
+ return (location == null
+ //is dead location, we cannot now change provider to return null
+ //because it may give rise to other errors.
+ //In the future, null should be returned instead of 'dead' location
+ //and correctly processed
+ || location.getStartPosition() == 0 && location.getLength() == 0);
+ }
private void validateEntityComponent(ISeamComponent component) {
if(component.isEntity()) {
@@ -485,7 +498,7 @@
private ISeamTextSourceReference getScopeLocation(ISeamComponent component) {
ISeamJavaComponentDeclaration javaDeclaration = component.getJavaDeclaration();
ISeamTextSourceReference location =
((SeamComponentDeclaration)javaDeclaration).getLocationFor(SeamComponentDeclaration.PATH_OF_SCOPE);
- if(location==null) {
+ if(isEmptyLocation(location)) {
location = getNameLocation(javaDeclaration);
}
return location;
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 2008-04-17
14:21:34 UTC (rev 7577)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java 2008-04-17
14:46:29 UTC (rev 7578)
@@ -68,7 +68,8 @@
Set<ISeamComponentDeclaration> declarations =
((ISeamComponent)element).getAllDeclarations();
for (Object o : declarations) {
SeamComponentDeclaration d = (SeamComponentDeclaration)o;
- if(d.getLocationFor(SeamComponentDeclaration.PATH_OF_NAME)!=null) {
+ ISeamTextSourceReference location =
d.getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
+ if(!SeamCoreValidator.isEmptyLocation(location)) {
return d.getResource();
}
}
@@ -96,14 +97,14 @@
Set<ISeamComponentDeclaration> declarations =
((ISeamComponent)element).getAllDeclarations();
for (ISeamComponentDeclaration d : declarations) {
location = ((SeamComponentDeclaration)d).getLocationFor(attributeName);
- if(location!=null) {
+ if(!SeamCoreValidator.isEmptyLocation(location)) {
break;
}
}
} else if(element instanceof SeamComponentDeclaration) {
location = ((SeamComponentDeclaration)element).getLocationFor(attributeName);
}
- if(location==null && element instanceof ISeamTextSourceReference) {
+ if(SeamCoreValidator.isEmptyLocation(location) && element instanceof
ISeamTextSourceReference) {
location = (ISeamTextSourceReference)element;
}
return location;
Show replies by date