Author: scabanovich
Date: 2009-03-10 13:47:17 -0400 (Tue, 10 Mar 2009)
New Revision: 14155
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/Tokenizer.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ExpressionRule.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/JavaNameTokenDescription.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/UnaryTokenDescription.java
Log:
JBIDE-3951
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/Tokenizer.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/Tokenizer.java 2009-03-10
16:52:02 UTC (rev 14154)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/Tokenizer.java 2009-03-10
17:47:17 UTC (rev 14155)
@@ -134,6 +134,13 @@
if(result != null) {
result.makeItFirst();
}
+ if(last != null && last.getStart() + last.getLength() <
sourceString.length()
+ && last.getType() != LITERAL) {
+ int lastEnd = last.getStart() + last.getLength();
+ LexicalToken t = new LexicalToken(lastEnd, length, getCharSequence(lastEnd,
sourceString.length()), LITERAL);
+ last.setNextToken(t);
+ last = t;
+ }
return result;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ExpressionRule.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ExpressionRule.java 2009-03-10
16:52:02 UTC (rev 14154)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ExpressionRule.java 2009-03-10
17:47:17 UTC (rev 14155)
@@ -16,6 +16,7 @@
import org.jboss.tools.common.el.internal.core.parser.token.EndELTokenDescription;
import org.jboss.tools.common.el.internal.core.parser.token.ExprStartTokenDescription;
import org.jboss.tools.common.el.internal.core.parser.token.JavaNameTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.OperationTokenDescription;
import org.jboss.tools.common.el.internal.core.parser.token.ParamEndTokenDescription;
import
org.jboss.tools.common.el.internal.core.parser.token.PrimitiveValueTokenDescription;
import org.jboss.tools.common.el.internal.core.parser.token.StartELTokenDescription;
@@ -128,6 +129,12 @@
if(state == STATE_EXPECTING_NAME) {
return "Expecting Java method or property name";
} else {
+ if(OperationTokenDescription.INSTANCE.isStart(tokenizer, tokenizer.getCurrentIndex()))
{
+ return "Expression cannot start with binary operator.";
+ }
+ if(JavaNameTokenDescription.INSTANCEOF_INSTANCE.isStart(tokenizer,
tokenizer.getCurrentIndex())) {
+ return "Expression cannot start with instanceof.";
+ }
return "Expecting expression";
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/JavaNameTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/JavaNameTokenDescription.java 2009-03-10
16:52:02 UTC (rev 14154)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/JavaNameTokenDescription.java 2009-03-10
17:47:17 UTC (rev 14155)
@@ -22,6 +22,8 @@
public static final int JAVA_NAME = 3;
public static JavaNameTokenDescription INSTANCE = new JavaNameTokenDescription();
+
+ public static ConstantTokenDescription INSTANCEOF_INSTANCE =
InstanceofTokenDescription.INSTANCE;
public String getName() {
return "NAME";
@@ -32,8 +34,14 @@
}
public boolean isStart(Tokenizer tokenizer, int offset) {
+ if(OperationTokenDescription.INSTANCE.isStart(tokenizer, offset)) {
+ return false;
+ }
+ if(InstanceofTokenDescription.INSTANCE.isStart(tokenizer, offset)) {
+ return false;
+ }
char ch = tokenizer.lookUpChar(offset);
- return Character.isJavaIdentifierStart(ch) && ch != '\0';
+ return Character.isJavaIdentifierStart(ch) && ch != '\0' && ch
!= '$';
}
public boolean read(Tokenizer tokenizer, int offset) {
@@ -50,3 +58,52 @@
}
}
+
+class InstanceofTokenDescription extends ConstantTokenDescription {
+ public static final int INSTANCEOF = 16;
+
+ public static InstanceofTokenDescription INSTANCE = new InstanceofTokenDescription();
+
+ private static final String[] OPS_2 = {
+ "instanceof"
+ };
+
+ public InstanceofTokenDescription() {
+ super("!", INSTANCEOF);
+ }
+
+ public boolean isStart(Tokenizer tokenizer, int offset) {
+ if(super.isStart(tokenizer, offset)) {
+ return true;
+ }
+ int end = -1;
+ for (int i = 0; end < 0 && i < OPS_2.length; i++) {
+ if(tokenizer.startsWith(OPS_2[i])) {
+ end = offset + OPS_2[i].length();
+ }
+ }
+ if(end < 0) return false;
+ char ch = tokenizer.lookUpChar(end);
+ if(Character.isWhitespace(ch) || ch == '\0' || ch == '(' ||
!Character.isJavaIdentifierPart(ch)
+ ) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public boolean read(Tokenizer tokenizer, int offset) {
+ if(super.isStart(tokenizer, offset)) {
+ return super.read(tokenizer, offset);
+ }
+ int end = -1;
+ for (int i = 0; end < 0 && i < OPS_2.length; i++) {
+ if(tokenizer.startsWith(OPS_2[i])) {
+ end = offset + OPS_2[i].length();
+ }
+ }
+ tokenizer.addToken(getType(), offset, end);
+ return true;
+ }
+
+}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/UnaryTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/UnaryTokenDescription.java 2009-03-10
16:52:02 UTC (rev 14154)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/UnaryTokenDescription.java 2009-03-10
17:47:17 UTC (rev 14155)
@@ -46,7 +46,7 @@
}
if(end < 0) return false;
char ch = tokenizer.lookUpChar(end);
- if(Character.isWhitespace(ch) || ch == '\0' || ch == '('
+ if(Character.isWhitespace(ch) || ch == '\0' || ch == '(' ||
!Character.isJavaIdentifierPart(ch)
) {
return true;
}
Show replies by date