Author: vrubezhny
Date: 2007-09-27 10:25:26 -0400 (Thu, 27 Sep 2007)
New Revision: 3865
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-949 seam validator reports
Fixed
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2007-09-27
14:06:55 UTC (rev 3864)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2007-09-27
14:25:26 UTC (rev 3865)
@@ -503,6 +503,7 @@
releaseChar();
return readMethodToken();
}
+ releaseChar();
return ELToken.EOF;
}
case STATE_VAR: // Variable name is read - expecting a separator
@@ -515,6 +516,7 @@
releaseChar();
return readSeparatorToken();
}
+ releaseChar();
return ELToken.EOF;
}
case STATE_METHOD: // Method name and parameters are read - expecting a separator
@@ -527,6 +529,7 @@
releaseChar();
return readSeparatorToken();
}
+ releaseChar();
return ELToken.EOF;
}
case STATE_SEPARATOR: // Separator is read - expecting a var or method
@@ -543,6 +546,7 @@
releaseChar();
return readMethodToken();
}
+ releaseChar();
return ELToken.EOF;
}
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java 2007-09-27
14:06:55 UTC (rev 3864)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java 2007-09-27
14:25:26 UTC (rev 3865)
@@ -172,14 +172,13 @@
Set<IMember> methods = new HashSet<IMember>();
if (type != null) {
try {
- IMethod[] mthds = type.getMethods();
+ IMethod[] mthds = getAllMethods(type);
for (int i = 0; mthds != null && i < mthds.length; i++) {
- IMethod m = mthds[i];
- if (Modifier.isPublic(m.getFlags()) &&
- !m.isConstructor() &&
- (!m.getElementName().startsWith("get") &&
!m.getElementName().startsWith("set")) ||
- "get".equals(m.getElementName()) ||
"set".equals(m.getElementName())) {
- methods.add(m);
+ if (Modifier.isPublic(mthds[i].getFlags()) &&
+ !mthds[i].isConstructor() &&
+ (!mthds[i].getElementName().startsWith("get") &&
!mthds[i].getElementName().startsWith("set")) ||
+ "get".equals(mthds[i].getElementName()) ||
"set".equals(mthds[i].getElementName())) {
+ methods.add(mthds[i]);
}
}
} catch (JavaModelException e) {
@@ -257,7 +256,34 @@
}
return result.toArray(new IMethod[result.size()]);
}
+
+ /**
+ * @param type
+ * @return fields of type and fields of all super classes
+ */
+ private static IField[] getAllFields(IType type) {
+ ArrayList<IField> result = new ArrayList<IField>();
+ try {
+ IField[] fields = type.getFields();
+ for(int i=0; i<fields.length; i++) {
+ result.add(fields[i]);
+ }
+ IType superType = getSuperclass(type);
+ while(superType!=null) {
+ fields = superType.getFields();
+ for(int i=0; i<fields.length; i++) {
+ result.add(fields[i]);
+ }
+ superType = getSuperclass(superType);
+ }
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ return result.toArray(new IField[result.size()]);
+ }
+
+
private static IType getSuperclass(IType type) throws JavaModelException {
String superclassName = type.getSuperclassName();
if(superclassName!=null) {
@@ -280,13 +306,12 @@
Set<IMember> properties = new HashSet<IMember>();
if (type != null) {
try {
- IMethod[] props = type.getMethods();
- for (int i = 0; props != null && i < props.length; i++) {
- IMethod m = props[i];
- if (Modifier.isPublic(m.getFlags()) &&
- (m.getElementName().startsWith("get") &&
!"get".equals(m.getElementName())) ||
- (m.getElementName().startsWith("set") &&
!"set".equals(m.getElementName()))) {
- properties.add(m);
+ IMethod[] mthds = getAllMethods(type);
+ for (int i = 0; mthds != null && i < mthds.length; i++) {
+ if (Modifier.isPublic(mthds[i].getFlags()) &&
+ (mthds[i].getElementName().startsWith("get") &&
!"get".equals(mthds[i].getElementName())) ||
+ (mthds[i].getElementName().startsWith("set") &&
!"set".equals(mthds[i].getElementName()))) {
+ properties.add(mthds[i]);
}
}
} catch (JavaModelException e) {
@@ -294,7 +319,7 @@
}
try {
- IField[] fields = type.getFields();
+ IField[] fields = getAllFields(type);
for (int i = 0; fields != null && i < fields.length; i++) {
IField f = fields[i];
if (Modifier.isPublic(f.getFlags())) {
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 2007-09-27
14:06:55 UTC (rev 3864)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java 2007-09-27
14:25:26 UTC (rev 3865)
@@ -242,8 +242,9 @@
String prefix = SeamELCompletionEngine.getPrefix(exp, offset);
if(prefix!=null) {
- int possition = 0;
-
+ int possition = exp.indexOf(prefix);
+ if (possition == -1) possition = 0;
+
Set<ISeamContextVariable> usedVariables = new
HashSet<ISeamContextVariable>();
Map<String, IMethod> unpairedGettersOrSetters = new HashMap<String,
IMethod>();