Author: akazakov
Date: 2007-11-05 07:06:38 -0500 (Mon, 05 Nov 2007)
New Revision: 4695
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/SeamELTokenizer.java
Log:
Ignore numbers in EL (for example: #{array[10]})
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-05
11:39:36 UTC (rev 4694)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/ELToken.java 2007-11-05
12:06:38 UTC (rev 4695)
@@ -18,11 +18,12 @@
*/
public class ELToken implements IToken {
public static final ELToken EOF = new ELToken(-1, -1, null, -1);
- public static final int EL_OPERAND_TOKEN = 1;
+ public static final int EL_VARIABLE_TOKEN = 1;
public static final int EL_OPERATOR_TOKEN = 2;
public static final int EL_RESERVED_WORD_TOKEN = 3;
public static final int EL_SEPARATOR_TOKEN = 4;
public static final int EL_STRING_TOKEN = 5;
+ public static final int EL_NUMBER_TOKEN = 6;
private int start;
private int length;
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-05
11:39:36 UTC (rev 4694)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELTokenizer.java 2007-11-05
12:06:38 UTC (rev 4695)
@@ -69,10 +69,12 @@
fState = STATE_INITIAL;
while ((token = getNextToken()) != ELToken.EOF) {
- if (token.getType() == ELToken.EL_OPERAND_TOKEN ||
+ 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_SEPARATOR_TOKEN ||
+ token.getType() == ELToken.EL_STRING_TOKEN ||
+ token.getType() == ELToken.EL_NUMBER_TOKEN) {
fTokens.add(token);
}
@@ -253,10 +255,12 @@
releaseChar();
int length = index - startOfToken;
boolean reservedWord = isResorvedWord(startOfToken, length);
- int tokenType = ELToken.EL_OPERAND_TOKEN;
+ int tokenType = ELToken.EL_VARIABLE_TOKEN;
if(reservedWord) {
tokenType = ELToken.EL_RESERVED_WORD_TOKEN;
fState = STATE_RESERVED_WORD;
+ } else if(isNumber(startOfToken, length)) {
+ tokenType = ELToken.EL_NUMBER_TOKEN;
}
return (length > 0 ? new ELToken(startOfToken, length, getCharSequence(startOfToken,
length), tokenType) : ELToken.EOF);
@@ -266,11 +270,31 @@
return RESERVED_WORDS.indexOf(" " + word.trim() + " ")>-1;
}
+ private boolean isNumber(String word) {
+ if(word.length()>0) {
+ char firstChar = word.charAt(0);
+ if(firstChar=='-' || (firstChar>='0' &&
firstChar<='9')) {
+ try {
+ Long.parseLong(word);
+ return true;
+ } catch (NumberFormatException e) {
+ return false;
+ }
+ }
+ }
+ return false;
+ }
+
private boolean isResorvedWord(int beginIndex, int length) {
String word = expression.substring(beginIndex, beginIndex + length);
return isResorvedWord(word);
}
+ private boolean isNumber(int beginIndex, int length) {
+ String word = expression.substring(beginIndex, beginIndex + length);
+ return isNumber(word);
+ }
+
/* Reads the next character
* @return
*/
Show replies by date