Author: akazakov
Date: 2008-06-16 07:24:47 -0400 (Mon, 16 Jun 2008)
New Revision: 8785
Modified:
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/messages.properties
Log:
http://jira.jboss.com/jira/browse/JBIDE-2328 Fixed in trunk and brunch 2.1.*
Modified:
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
===================================================================
---
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2008-06-16
11:15:03 UTC (rev 8784)
+++
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2008-06-16
11:24:47 UTC (rev 8785)
@@ -23,12 +23,10 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.validation.internal.core.ValidationException;
@@ -465,7 +463,7 @@
if(name==null) {
return;
}
- boolean ok = type.isBinary() || coreHelper.findSetter(type, name)!=null;
+ boolean ok = type.isBinary() || coreHelper.findProperty(type, name)!=null;
if(!ok) {
addError(UNKNOWN_COMPONENT_PROPERTY_MESSAGE_ID,
SeamPreferences.UNKNOWN_COMPONENT_PROPERTY, new String[]{type.getElementName(),
componentName, name}, property, declaration.getResource());
}
Modified:
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java
===================================================================
---
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java 2008-06-16
11:15:03 UTC (rev 8784)
+++
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationHelper.java 2008-06-16
11:24:47 UTC (rev 8785)
@@ -16,7 +16,9 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
@@ -168,7 +170,7 @@
return null;
}
String className = fileName.substring(0, firstDot);
- IProject p = getProject().getProject();
+ IProject p = getProject();
try {
IJavaProject jp = EclipseResourceUtil.getJavaProject(p);
IPackageFragment packageFragment =
jp.findPackageFragment(componentXmlFile.getFullPath().removeLastSegments(1));
@@ -183,33 +185,41 @@
}
/**
- * Find setter for property
+ * Find a setter or a field for a property.
* @param type
* @param propertyName
- * @return
+ * @return IMethod (setter) or IFiled (field)
*/
- public IMethod findSetter(IType type, String propertyName) {
+ public IMember findProperty(IType type, String propertyName) {
if(propertyName == null || propertyName.length()==0) {
return null;
}
- String firstLetter = propertyName.substring(0, 1).toUpperCase();
- String nameWithoutFirstLetter = propertyName.substring(1);
- String setterName = "set" + firstLetter + nameWithoutFirstLetter;
//$NON-NLS-1$
try {
- return findSetterInHierarchy(type, setterName);
+ return findPropertyInHierarchy(type, propertyName);
} catch (JavaModelException e) {
SeamCorePlugin.getDefault().logError(e);
}
return null;
}
- private IMethod findSetterInHierarchy(IType type, String setterName) throws
JavaModelException {
+ private IMember findPropertyInHierarchy(IType type, String propertyName) throws
JavaModelException {
+ String firstLetter = propertyName.substring(0, 1).toUpperCase();
+ String nameWithoutFirstLetter = propertyName.substring(1);
+ String setterName = "set" + firstLetter + nameWithoutFirstLetter;
//$NON-NLS-1$
+
IMethod[] methods = type.getMethods();
for (int i = 0; i < methods.length; i++) {
if(methods[i].getElementName().equals(setterName) &&
methods[i].getParameterNames().length==1) {
return methods[i];
}
}
+ IField[] fields = type.getFields();
+ for (int i = 0; i < fields.length; i++) {
+ if(fields[i].getElementName().equals(propertyName)) {
+ return fields[i];
+ }
+ }
+
String superclassName = type.getSuperclassName();
if(superclassName!=null) {
String[][] packages = type.resolveType(superclassName);
@@ -224,9 +234,9 @@
String qName = packageName + packages[i][1];
IType superclass = type.getJavaProject().findType(qName);
if(superclass!=null) {
- IMethod method = findSetterInHierarchy(superclass, setterName);
- if(method!=null) {
- return method;
+ IMember property = findPropertyInHierarchy(superclass, propertyName);
+ if(property!=null) {
+ return property;
}
}
}
Modified:
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/messages.properties
===================================================================
---
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/messages.properties 2008-06-16
11:15:03 UTC (rev 8784)
+++
branches/jbosstools-2.1.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/messages.properties 2008-06-16
11:24:47 UTC (rev 8785)
@@ -14,7 +14,7 @@
STATEFUL_COMPONENT_DOES_NOT_CONTAIN_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
UNKNOWN_COMPONENT_CLASS_NAME="{0}" cannot be resolved to a type
-UNKNOWN_COMPONENT_PROPERTY=Class "{0}" of component "{1}" does not
contain setter for property "{2}"
+UNKNOWN_COMPONENT_PROPERTY=Class "{0}" of component "{1}" does not
have a setter or a field for the property "{2}"
#Entities
ENTITY_COMPONENT_WRONG_SCOPE=Entity component "{0}" should not have
org.jboss.seam.ScopeType.STATELESS