Author: akazakov
Date: 2007-11-16 08:31:37 -0500 (Fri, 16 Nov 2007)
New Revision: 4942
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbJsfValuesResource.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBeanPropertyResource.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPreferenceInitializer.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/ELOperandToken.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/ELToken.java
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/SeamELOperandTokenizer.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELTokenizer.java
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/messages.properties
Log:
http://jira.jboss.com/jira/browse/JBIDE-1308
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbJsfValuesResource.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbJsfValuesResource.java 2007-11-16
13:03:12 UTC (rev 4941)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbJsfValuesResource.java 2007-11-16
13:31:37 UTC (rev 4942)
@@ -32,7 +32,15 @@
}
protected void fillSortedProposalStrings(Set sorted, String beanName, boolean
hasProperty) {
- for (int i = 0; i < fixedJsfValues.length; i++) sorted.add(fixedJsfValues[i]);
+ if((query.indexOf("#{")>-1 || query.indexOf("${")>-1)
+ && (!query.trim().endsWith("."))
+ && (!query.endsWith(")"))
+ && (!query.endsWith("]"))
+ && (beanName == null || beanName.length() == 0 || !hasProperty)) {
+ for (int i = 0; i < fixedJsfValues.length; i++) {
+ sorted.add(fixedJsfValues[i]);
+ }
+ }
}
protected int getKbProposalRelevance() {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBeanPropertyResource.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBeanPropertyResource.java 2007-11-16
13:03:12 UTC (rev 4941)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBeanPropertyResource.java 2007-11-16
13:31:37 UTC (rev 4942)
@@ -38,6 +38,7 @@
public static String SUPPORTED_ID = WebPromptingProvider.JSF_BEAN_PROPERTIES;
public Properties type = new Properties();
+ protected String query;
public WTPKbdBeanPropertyResource(IEditorInput editorInput, WTPTextJspKbConnector
connector) {
super(editorInput);
@@ -48,6 +49,7 @@
}
public Collection<KbProposal> queryProposal(String query) {
+ this.query = query;
Collection<KbProposal> proposals = new ArrayList<KbProposal>();
proposals.clear();
try {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java 2007-11-16
13:03:12 UTC (rev 4941)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamPreferences.java 2007-11-16
13:31:37 UTC (rev 4942)
@@ -106,8 +106,10 @@
// Seam Expression language
- // Mark Expressions which we can't resolve.
- public static final String INVALID_EXPRESSION =
createSeverityOption("invalidExpression"); //$NON-NLS-1$
+ // Mark EL Variable name which we can't resolve.
+ public static final String UNKNOWN_EL_VARIABLE_NAME =
createSeverityOption("unknownElVariableName"); //$NON-NLS-1$
+ // Mark EL Variable property name which we can't resolve.
+ public static final String UNKNOWN_EL_VARIABLE_PROPERTY_NAME =
createSeverityOption("unknownElVariablePropertyName"); //$NON-NLS-1$
// If Expression use property of component and this property has only setter(getter)
without getter(setter) then mark it.
public static final String UNPAIRED_GETTER_OR_SETTER =
createSeverityOption("unpairedGetterOrSetter"); //$NON-NLS-1$
@@ -178,7 +180,8 @@
}
public static boolean isValidateEL(ISeamProject project) {
- return !(SeamPreferences.IGNORE.equals(getProjectPreference(project,
INVALID_EXPRESSION)) &&
+ return !(SeamPreferences.IGNORE.equals(getProjectPreference(project,
UNKNOWN_EL_VARIABLE_NAME)) &&
+ SeamPreferences.IGNORE.equals(getProjectPreference(project,
UNKNOWN_EL_VARIABLE_PROPERTY_NAME)) &&
SeamPreferences.IGNORE.equals(getProjectPreference(project,
UNPAIRED_GETTER_OR_SETTER)));
}
}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPreferenceInitializer.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPreferenceInitializer.java 2007-11-16
13:03:12 UTC (rev 4941)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPreferenceInitializer.java 2007-11-16
13:31:37 UTC (rev 4942)
@@ -31,7 +31,8 @@
for (String name : SeamPreferences.severityOptionNames) {
defaultPreferences.put(name, SeamPreferences.ERROR);
}
- defaultPreferences.put(SeamPreferences.INVALID_EXPRESSION, SeamPreferences.IGNORE);
+ defaultPreferences.put(SeamPreferences.UNKNOWN_EL_VARIABLE_NAME,
SeamPreferences.IGNORE);
+ defaultPreferences.put(SeamPreferences.UNKNOWN_EL_VARIABLE_PROPERTY_NAME,
SeamPreferences.WARNING);
defaultPreferences.put(SeamPreferences.UNKNOWN_VARIABLE_NAME,
SeamPreferences.WARNING);
defaultPreferences.put(SeamPreferences.UNPAIRED_GETTER_OR_SETTER,
SeamPreferences.IGNORE);
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/ELOperandToken.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/ELOperandToken.java 2007-11-16
13:03:12 UTC (rev 4941)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/ELOperandToken.java 2007-11-16
13:31:37 UTC (rev 4942)
@@ -19,9 +19,10 @@
*/
public class ELOperandToken implements IToken {
public static final ELOperandToken EOF = new ELOperandToken(-1, -1, null, -1);
- public static final int EL_NAME_TOKEN = 1;
- public static final int EL_METHOD_TOKEN = 2;
- public static final int EL_SEPARATOR_TOKEN = 3;
+ public static final int EL_VARIABLE_NAME_TOKEN = 1;
+ public static final int EL_PROPERTY_NAME_TOKEN = 2;
+ public static final int EL_METHOD_TOKEN = 3;
+ public static final int EL_SEPARATOR_TOKEN = 4;
int start;
int length;
@@ -93,6 +94,13 @@
}
/**
+ * Returns the token type
+ */
+ public boolean isNameToken(){
+ return EL_VARIABLE_NAME_TOKEN == type || EL_PROPERTY_NAME_TOKEN == type;
+ }
+
+ /**
* Returns the token text
*/
public String getText() {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/ELToken.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/ELToken.java 2007-11-16
13:03:12 UTC (rev 4941)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/ELToken.java 2007-11-16
13:31:37 UTC (rev 4942)
@@ -24,6 +24,10 @@
public static final int EL_SEPARATOR_TOKEN = 4;
public static final int EL_STRING_TOKEN = 5;
public static final int EL_NUMBER_TOKEN = 6;
+// public static final int EL_START_ROUND_BRACKET_TOKEN = 7;
+// public static final int EL_END_ROUND_BRACKET_TOKEN = 8;
+// public static final int EL_START_SQUARE_BRACKET_TOKEN = 9;
+// public static final int EL_END_SQUARE_BRACKET_TOKEN = 10;
private int start;
private int length;
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-11-16
13:03:12 UTC (rev 4941)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2007-11-16
13:31:37 UTC (rev 4942)
@@ -20,24 +20,16 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
-import org.jboss.tools.common.model.util.EclipseJavaUtil;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamContextVariable;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ScopeType;
-import org.jboss.tools.seam.core.SeamCoreMessages;
-import org.jboss.tools.seam.core.SeamCorePlugin;
/**
* Utility class used to find Seam Project content assist proposals
@@ -185,8 +177,8 @@
if (token.getType() == ELOperandToken.EL_SEPARATOR_TOKEN)
// proceed with next token
continue;
-
- if (token.getType() == ELOperandToken.EL_NAME_TOKEN) {
+
+ if (token.isNameToken()) {
// Find properties for the token
String name = token.getText();
List<TypeInfoCollector.MemberInfo> newMembers = new
ArrayList<TypeInfoCollector.MemberInfo>();
@@ -233,8 +225,9 @@
proposals.addAll(infos.getMethodPresentations());
proposals.addAll(infos.getPropertyPresentations(unpairedGettersOrSetters));
}
- } else if (token.getType() == ELOperandToken.EL_NAME_TOKEN ||
- token.getType() == ELOperandToken.EL_METHOD_TOKEN) {
+ } else if (token.getType() == ELOperandToken.EL_VARIABLE_NAME_TOKEN ||
+ token.getType() == ELOperandToken.EL_PROPERTY_NAME_TOKEN ||
+ token.getType() == ELOperandToken.EL_METHOD_TOKEN) {
// return filtered methods + properties
Set<String> proposalsToFilter = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
for (TypeInfoCollector.MemberInfo mbr : members) {
@@ -458,7 +451,7 @@
status.setLastResolvedToken(token);
continue;
}
- if (token.getType() == ELOperandToken.EL_NAME_TOKEN) {
+ if (token.isNameToken()) {
// Find properties for the token
String name = token.getText();
List<TypeInfoCollector.MemberInfo> newMembers = new
ArrayList<TypeInfoCollector.MemberInfo>();
@@ -521,8 +514,9 @@
proposals.addAll(infos.getMethodPresentations());
proposals.addAll(infos.getPropertyPresentations(status.getUnpairedGettersOrSetters()));
}
- } else if (token.getType() == ELOperandToken.EL_NAME_TOKEN ||
- token.getType() == ELOperandToken.EL_METHOD_TOKEN) {
+ } else if (token.getType() == ELOperandToken.EL_VARIABLE_NAME_TOKEN ||
+ token.getType() == ELOperandToken.EL_PROPERTY_NAME_TOKEN ||
+ token.getType() == ELOperandToken.EL_METHOD_TOKEN) {
// return filtered methods + properties
Set<String> proposalsToFilter = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
for (TypeInfoCollector.MemberInfo mbr : members) {
@@ -577,7 +571,8 @@
tokens = new ArrayList<ELOperandToken>();
StringBuffer sb = new StringBuffer();
for (ELOperandToken token : tokens) {
- if (token.getType() == ELOperandToken.EL_NAME_TOKEN ||
+ if (token.getType() == ELOperandToken.EL_VARIABLE_NAME_TOKEN ||
+ token.getType() == ELOperandToken.EL_PROPERTY_NAME_TOKEN ||
token.getType() == ELOperandToken.EL_METHOD_TOKEN ||
token.getType() == ELOperandToken.EL_SEPARATOR_TOKEN) {
sb.append(token.getText());
@@ -845,7 +840,7 @@
// proceed with next token
continue;
- if (token.getType() == ELOperandToken.EL_NAME_TOKEN) {
+ if (token.isNameToken()) {
// Find properties for the token
String name = token.getText();
List<TypeInfoCollector.MemberInfo> newMembers = new
ArrayList<TypeInfoCollector.MemberInfo>();
@@ -886,7 +881,8 @@
}
} else { // Last segment
Set<IJavaElement> javaElements = new HashSet<IJavaElement>();
- if (token.getType() == ELOperandToken.EL_NAME_TOKEN ||
+ if (token.getType() == ELOperandToken.EL_VARIABLE_NAME_TOKEN ||
+ token.getType() == ELOperandToken.EL_PROPERTY_NAME_TOKEN ||
token.getType() == ELOperandToken.EL_METHOD_TOKEN) {
// return filtered methods + properties
Set<TypeInfoCollector.MemberInfo> javaElementInfosToFilter = new
HashSet<TypeInfoCollector.MemberInfo>();
@@ -925,8 +921,6 @@
res.addAll(javaElements);
}
}
-
return res;
}
-
}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELOperandTokenizer.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELOperandTokenizer.java 2007-11-16
13:03:12 UTC (rev 4941)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELOperandTokenizer.java 2007-11-16
13:31:37 UTC (rev 4942)
@@ -74,14 +74,22 @@
ELOperandToken token;
fState = STATE_INITIAL;
while ((token = getNextToken()) != ELOperandToken.EOF) {
-
- if (token.type == ELOperandToken.EL_NAME_TOKEN ||
+ if (token.type == ELOperandToken.EL_VARIABLE_NAME_TOKEN ||
+ token.type == ELOperandToken.EL_PROPERTY_NAME_TOKEN ||
token.type == ELOperandToken.EL_METHOD_TOKEN ||
token.type == ELOperandToken.EL_SEPARATOR_TOKEN) {
fTokens.add(0, token);
}
}
+ // set first token as variable
+ for (int i=0; i<fTokens.size(); i++) {
+ token = fTokens.get(i);
+ if(token.isNameToken()) {
+ token.type = ELOperandToken.EL_VARIABLE_NAME_TOKEN;
+ break;
+ }
+ }
}
int fState;
@@ -311,16 +319,17 @@
fState = STATE_VAR;
int endOfToken = index;
int ch;
+ int type = ELOperandToken.EL_PROPERTY_NAME_TOKEN;
while((ch = readCharBackward()) != -1) {
if (!Character.isJavaIdentifierPart(ch)) {
releaseChar();
- return (endOfToken - index > 0 ? new ELOperandToken(index, endOfToken - index,
getCharSequence(index, endOfToken - index), ELOperandToken.EL_NAME_TOKEN) :
ELOperandToken.EOF);
+ return (endOfToken - index > 0 ? new ELOperandToken(index, endOfToken - index,
getCharSequence(index, endOfToken - index), type) : ELOperandToken.EOF);
}
}
releaseChar();
- return (endOfToken - index > 0 ? new ELOperandToken(index, endOfToken - index,
getCharSequence(index, endOfToken - index), ELOperandToken.EL_NAME_TOKEN) :
ELOperandToken.EOF);
+ return (endOfToken - index > 0 ? new ELOperandToken(index, endOfToken - index,
getCharSequence(index, endOfToken - index), type) : ELOperandToken.EOF);
}
-
+
/* Reads the next character in the document
*
* @return
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELTokenizer.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELTokenizer.java 2007-11-16
13:03:12 UTC (rev 4941)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELTokenizer.java 2007-11-16
13:31:37 UTC (rev 4942)
@@ -31,9 +31,15 @@
private String expression;
private List<ELToken> fTokens;
private int index;
+ private int offset = 0;
private int fState;
private static final String OPERATOR_SYMBOLS =
"!=&(){}[]:+-*%?,|/%<>";
+// private static final String OPERATOR_SYMBOLS =
"!=&{}:+-*%?,|/%<>";
+ private static final int START_ROUND_BRACKET_SYMBOL = '(';
+ private static final int END_ROUND_BRACKET_SYMBOL = ')';
+ private static final int START_SQUARE_BRACKET_SYMBOL = '[';
+ private static final int END_SQUARE_BRACKET_SYMBOL = ']';
private static final int STRING_SYMBOL = '\'';
private static final String RESERVED_WORDS = " null empty div and or not mod eq ne
lt gt le ge true false instanceof invalid required ";
@@ -45,13 +51,18 @@
* then tokens are {"var1.pr"," ", "!=",
" ", "var2",}
* @param expression
*/
- public SeamELTokenizer(String expression) {
+ public SeamELTokenizer(String expression, int offset) {
+ this.offset = offset;
this.expression = expression;
index = 0;
fTokens = new ArrayList<ELToken>();
parse();
}
+ public SeamELTokenizer(String expression) {
+ this(expression, 0);
+ }
+
/**
* Returns list of tokens for the expression parsed
*
@@ -68,16 +79,7 @@
ELToken token;
fState = STATE_INITIAL;
while ((token = getNextToken()) != ELToken.EOF) {
-
- if (token.getType() == ELToken.EL_VARIABLE_TOKEN ||
- token.getType() == ELToken.EL_OPERATOR_TOKEN ||
- token.getType() == ELToken.EL_RESERVED_WORD_TOKEN ||
- token.getType() == ELToken.EL_SEPARATOR_TOKEN ||
- token.getType() == ELToken.EL_STRING_TOKEN ||
- token.getType() == ELToken.EL_NUMBER_TOKEN) {
-
- fTokens.add(token);
- }
+ fTokens.add(token);
}
}
@@ -199,7 +201,7 @@
}
releaseChar();
int length = index - startOfToken;
- return (length > 0 ? new ELToken(startOfToken, length, getCharSequence(startOfToken,
length), ELToken.EL_OPERATOR_TOKEN) : ELToken.EOF);
+ return (length > 0 ? new ELToken(offset + startOfToken, length,
getCharSequence(startOfToken, length), ELToken.EL_OPERATOR_TOKEN) : ELToken.EOF);
}
/*
@@ -217,7 +219,7 @@
}
releaseChar();
int length = index - startOfToken;
- return (length > 0 ? new ELToken(startOfToken, length, getCharSequence(startOfToken,
length), ELToken.EL_SEPARATOR_TOKEN) : ELToken.EOF);
+ return (length > 0 ? new ELToken(offset + startOfToken, length,
getCharSequence(startOfToken, length), ELToken.EL_SEPARATOR_TOKEN) : ELToken.EOF);
}
/*
@@ -236,7 +238,7 @@
releaseChar();
int length = index - startOfToken;
- return (length > 0 ? new ELToken(startOfToken, length, getCharSequence(startOfToken,
length), ELToken.EL_STRING_TOKEN) : ELToken.EOF);
+ return (length > 0 ? new ELToken(offset + startOfToken, length,
getCharSequence(startOfToken, length), ELToken.EL_STRING_TOKEN) : ELToken.EOF);
}
/*
@@ -248,6 +250,11 @@
int startOfToken = index;
int ch;
while((ch = readNextChar()) != -1) {
+ if (ch == START_ROUND_BRACKET_SYMBOL) {
+ ch = readTokensWithinBrackets(END_ROUND_BRACKET_SYMBOL);
+ } else if (ch == START_SQUARE_BRACKET_SYMBOL) {
+ ch = readTokensWithinBrackets(END_SQUARE_BRACKET_SYMBOL);
+ }
if (!Character.isJavaIdentifierPart(ch) && ch!='.') {
break;
}
@@ -263,9 +270,23 @@
tokenType = ELToken.EL_NUMBER_TOKEN;
}
- return (length > 0 ? new ELToken(startOfToken, length, getCharSequence(startOfToken,
length), tokenType) : ELToken.EOF);
+ return (length > 0 ? new ELToken(offset + startOfToken, length,
getCharSequence(startOfToken, length), tokenType) : ELToken.EOF);
}
+ private int readTokensWithinBrackets(int expectedEndBracketSymbol) {
+ int start = index;
+ int ch;
+ while((ch = readNextChar()) != -1) {
+ if (ch == expectedEndBracketSymbol) {
+ CharSequence text = getCharSequence(start, index - 1 - start);
+ SeamELTokenizer tokenizer = new SeamELTokenizer(text.toString(), start);
+ fTokens.addAll(tokenizer.getTokens());
+ return readNextChar();
+ }
+ }
+ return ch;
+ }
+
private boolean isResorvedWord(String word) {
return RESERVED_WORDS.indexOf(" " + word.trim() + " ")>-1;
}
@@ -319,4 +340,14 @@
index--;
}
}
+
+ public static void main(String[] args) throws Exception {
+ String test = "hotelBooking.bookHotel(hotel.id, user.username).test.rrr().asss not
null av.test[] ! = var2 <> var3.test3";
+ System.out.println(test);
+ SeamELTokenizer elTokenizer = new SeamELTokenizer(test);
+ List<ELToken> tokens = elTokenizer.getTokens();
+ for (ELToken token : tokens) {
+ System.out.println(token);
+ }
+ }
}
\ No newline at end of file
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-11-16
13:03:12 UTC (rev 4941)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java 2007-11-16
13:31:37 UTC (rev 4942)
@@ -58,7 +58,8 @@
*/
public class SeamELValidator extends SeamValidator {
- protected static final String INVALID_EXPRESSION_MESSAGE_ID =
"INVALID_EXPRESSION"; //$NON-NLS-1$
+ protected static final String UNKNOWN_EL_VARIABLE_NAME_MESSAGE_ID =
"UNKNOWN_EL_VARIABLE_NAME"; //$NON-NLS-1$
+ protected static final String UNKNOWN_EL_VARIABLE_PROPERTY_NAME_MESSAGE_ID =
"UNKNOWN_EL_VARIABLE_PROPERTY_NAME"; //$NON-NLS-1$
protected static final String UNPAIRED_GETTER_OR_SETTER_MESSAGE_ID =
"UNPAIRED_GETTER_OR_SETTER"; //$NON-NLS-1$
protected static final String VALIDATING_EL_FILE_MESSAGE_ID =
"VALIDATING_EL_FILE";
@@ -248,7 +249,6 @@
private void validateEl(IFile file, EL el) {
String exp = el.value;
-// String test = "hotelBooking.bookHotel(hotel.id, user.username) not null
av.test[] ! = var2 <> var3.test3";
SeamELTokenizer elTokenizer = new SeamELTokenizer(exp);
List<ELToken> tokens = elTokenizer.getTokens();
for (ELToken token : tokens) {
@@ -263,6 +263,7 @@
String varName = operand;
int offsetOfVarName = documnetOffset + operandToken.getStart();
int lengthOfVarName = varName.length();
+ boolean unresolvedTokenIsVariable = true;
try {
int offset = operand.length();
if (!operand.endsWith(".")) { //$NON-NLS-1$
@@ -308,10 +309,11 @@
List<ELOperandToken> tokens = status.getUnresolvedTokens();
for (ELOperandToken token : tokens) {
- if((token.getType()==ELOperandToken.EL_NAME_TOKEN) ||
(token.getType()==ELOperandToken.EL_METHOD_TOKEN)) {
+ if((token.getType()==ELOperandToken.EL_VARIABLE_NAME_TOKEN) ||
(token.getType()==ELOperandToken.EL_PROPERTY_NAME_TOKEN) ||
(token.getType()==ELOperandToken.EL_METHOD_TOKEN)) {
varName = token.getText();
offsetOfVarName = documnetOffset + operandToken.getStart() + token.getStart();
lengthOfVarName = varName.length();
+ unresolvedTokenIsVariable =
(token.getType()==ELOperandToken.EL_VARIABLE_NAME_TOKEN);
break;
}
}
@@ -323,7 +325,11 @@
SeamCorePlugin.getDefault().logError(SeamCoreMessages.SEAM_EL_VALIDATOR_ERROR_VALIDATING_SEAM_EL,
e);
}
// Mark invalid EL
- addError(INVALID_EXPRESSION_MESSAGE_ID, SeamPreferences.INVALID_EXPRESSION, new
String[]{varName}, lengthOfVarName, offsetOfVarName, file);
+ if(unresolvedTokenIsVariable) {
+ addError(UNKNOWN_EL_VARIABLE_NAME_MESSAGE_ID,
SeamPreferences.UNKNOWN_EL_VARIABLE_NAME, new String[]{varName}, lengthOfVarName,
offsetOfVarName, file);
+ } else {
+ addError(UNKNOWN_EL_VARIABLE_PROPERTY_NAME_MESSAGE_ID,
SeamPreferences.UNKNOWN_EL_VARIABLE_PROPERTY_NAME, new String[]{varName}, lengthOfVarName,
offsetOfVarName, file);
+ }
}
public static class EL {
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-11-16
13:03:12 UTC (rev 4941)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/messages.properties 2007-11-16
13:31:37 UTC (rev 4942)
@@ -41,7 +41,8 @@
UNKNOWN_VARIABLE_NAME=Unknown context variable name: {0}
#Seam Expression language
-INVALID_EXPRESSION={0} cannot be resolved
+UNKNOWN_EL_VARIABLE_NAME={0} cannot be resolved
+UNKNOWN_EL_VARIABLE_PROPERTY_NAME={0} cannot be resolved
UNPAIRED_GETTER_OR_SETTER=Property "{0}" has only {1}. {2} is missing.
#Messages for Progress Monitor