Author: scabanovich
Date: 2008-10-02 06:06:26 -0400 (Thu, 02 Oct 2008)
New Revision: 10621
Removed:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ArgRule.java
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/IRule.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/SyntaxError.java
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/TokenizerFactory.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELArgumentExpressionImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELInvocationExpressionImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/ELParserImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/CallRule.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ErrorRecoveryRule.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/rule/OperationRule.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ArgEndTokenDescription.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ArgStartTokenDescription.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ParamUtil.java
Log:
JBIDE-1497.
Parser improved
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/IRule.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/IRule.java 2008-10-02
09:32:15 UTC (rev 10620)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/IRule.java 2008-10-02
10:06:26 UTC (rev 10621)
@@ -23,4 +23,6 @@
public int getFinalState(int state, int token);
+ public String getProblem(int state, Tokenizer tokenizer);
+
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/SyntaxError.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/SyntaxError.java 2008-10-02
09:32:15 UTC (rev 10620)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/SyntaxError.java 2008-10-02
10:06:26 UTC (rev 10621)
@@ -18,6 +18,7 @@
public class SyntaxError {
int position;
int state;
+ String problem;
public SyntaxError(int position, int state) {
this.position = position;
@@ -32,4 +33,12 @@
return position;
}
+ public String getProblem() {
+ return problem;
+ }
+
+ void setProblem(String problem) {
+ this.problem = problem;
+ }
+
}
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 2008-10-02
09:32:15 UTC (rev 10620)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/Tokenizer.java 2008-10-02
10:06:26 UTC (rev 10621)
@@ -102,7 +102,14 @@
char ch = readNextChar();
if(ch == '\0') break;
} else {
- errors.add(new SyntaxError(index, state));
+ SyntaxError error = new SyntaxError(index, state);
+ String problem = null;
+ for (IRule rule : rs) {
+ problem = rule.getProblem(state, this);
+ if(problem != null) break;
+ }
+ error.setProblem(problem);
+ errors.add(error);
state = BasicStates.STATE_ERROR;
}
}
@@ -175,4 +182,8 @@
public int getState() {
return state;
}
+
+ public int getCurrentIndex() {
+ return index;
+ }
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/TokenizerFactory.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/TokenizerFactory.java 2008-10-02
09:32:15 UTC (rev 10620)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/TokenizerFactory.java 2008-10-02
10:06:26 UTC (rev 10621)
@@ -13,11 +13,9 @@
import java.util.List;
import org.jboss.tools.common.el.core.model.ELExpression;
-import org.jboss.tools.common.el.core.model.ELInstance;
import org.jboss.tools.common.el.core.model.ELInvocationExpression;
import org.jboss.tools.common.el.core.model.ELModel;
import org.jboss.tools.common.el.core.model.ELUtil;
-import org.jboss.tools.common.el.internal.core.parser.rule.ArgRule;
import org.jboss.tools.common.el.internal.core.parser.rule.CallRule;
import org.jboss.tools.common.el.internal.core.parser.rule.ErrorRecoveryRule;
import org.jboss.tools.common.el.internal.core.parser.rule.ExpressionRule;
@@ -63,7 +61,6 @@
});
t.setRules(new IRule[]{
ExpressionRule.INSTANCE,
- ArgRule.INSTANCE,
CallRule.INSTANCE,
OperationRule.INSTANCE,
ErrorRecoveryRule.INSTANCE,
@@ -93,7 +90,6 @@
});
t.setRules(new IRule[]{
ExpressionRule.INSTANCE,
- ArgRule.INSTANCE,
CallRule.INSTANCE,
OperationRule.INSTANCE,
ErrorRecoveryRule.INSTANCE,
@@ -102,7 +98,8 @@
}
public static void main(String[] args) {
- String text = "#{.8 +(.9d / - (-.8))}";
+ String text = "#{a.b + 7d -c.d + g}#{hh.vv..m()}";
+//"#{a[b()['l'].j]}";
//"#{g11.g12.y13} #{#{ #{a14.b15(x.t.u(uu.ii[9], j)).b16(m17(v18(i19[2]).u20).)+
a21(c.).b.}";
//"#{not a.b(x,y) + s.h((6 != -8) & (7 + -iy88.g[9].h(7 div 8).i.j)+(8) ? 4 :
7,'p', a.b.c.d[null])}";
//"q82#{a( g.h(7 + 8) + 8, g['h'].j(),'p')}k#{b}";
@@ -117,7 +114,7 @@
}
List<SyntaxError> errors = t.getErrors();
for (SyntaxError e: errors) {
- System.out.println("state=" + e.getState() + " position=" +
e.getPosition());
+ System.out.println("state=" + e.getState() + " position=" +
e.getPosition() + " problem=" + e.getProblem());
}
ELParser parser = ELParserUtil.getJbossFactory().createParser();
ELModel model = parser.parse(text, 0, 90);
@@ -131,7 +128,7 @@
System.out.println(i);
}
- int off = 2;
+ int off = 8;
ELExpression expr1 = ELUtil.findExpression(model, off);
System.out.println("Expression at " + off + ": " + expr1);
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELArgumentExpressionImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELArgumentExpressionImpl.java 2008-10-02
09:32:15 UTC (rev 10620)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELArgumentExpressionImpl.java 2008-10-02
10:06:26 UTC (rev 10621)
@@ -10,7 +10,11 @@
******************************************************************************/
package org.jboss.tools.common.el.internal.core.model;
+import java.util.List;
+
import org.jboss.tools.common.el.core.model.ELArgumentInvocation;
+import org.jboss.tools.common.el.core.model.ELExpression;
+import org.jboss.tools.common.el.core.model.ELInvocationExpression;
import org.jboss.tools.common.el.core.model.ELObjectType;
/**
@@ -54,4 +58,11 @@
return argument.getArgument().getText();
}
+ public void collectInvocationsInArgument(List<ELInvocationExpression> list) {
+ if(argument != null) {
+ if(argument.getArgument() != null) {
+ argument.getArgument().collectInvocations(list);
+ }
+ }
+ }
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELInvocationExpressionImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELInvocationExpressionImpl.java 2008-10-02
09:32:15 UTC (rev 10620)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELInvocationExpressionImpl.java 2008-10-02
10:06:26 UTC (rev 10621)
@@ -56,6 +56,8 @@
while(l != null) {
if(l instanceof ELMethodInvocationImpl) {
((ELMethodInvocationImpl)l).collectInvocationsInParameters(list);
+ } else if(l instanceof ELArgumentExpressionImpl) {
+ ((ELArgumentExpressionImpl)l).collectInvocationsInArgument(list);
}
l = l.getLeft();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/ELParserImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/ELParserImpl.java 2008-10-02
09:32:15 UTC (rev 10620)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/ELParserImpl.java 2008-10-02
10:06:26 UTC (rev 10621)
@@ -179,6 +179,13 @@
ELInvocationExpressionImpl result = name;
setNextToken();
if(current != null) switch (current.getType()) {
+ case ParamStartTokenDescription.PARAM_START:
+ ELParametersImpl params = readParameters();
+ ELMethodInvocationImpl method = new ELMethodInvocationImpl();
+ method.setName(name.getName());
+ method.setParameters(params);
+ result = method;
+ //do not break we are ready to have [] suffix here
case ArgStartTokenDescription.ARG_START:
while(current != null && current.getType() ==
ArgStartTokenDescription.ARG_START) {
ELArgumentImpl arg = readArgument();
@@ -188,12 +195,6 @@
result = call;
}
break;
- case ParamStartTokenDescription.PARAM_START:
- ELParametersImpl params = readParameters();
- ELMethodInvocationImpl method = new ELMethodInvocationImpl();
- method.setName(name.getName());
- method.setParameters(params);
- result = method;
}
if(current != null && current.getType() == DotTokenDescription.DOT) {
LexicalToken dot = current;
Deleted:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ArgRule.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ArgRule.java 2008-10-02
09:32:15 UTC (rev 10620)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ArgRule.java 2008-10-02
10:06:26 UTC (rev 10621)
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.el.internal.core.parser.rule;
-
-import org.jboss.tools.common.el.core.parser.IRule;
-import org.jboss.tools.common.el.internal.core.parser.token.ArgEndTokenDescription;
-import
org.jboss.tools.common.el.internal.core.parser.token.PrimitiveValueTokenDescription;
-import org.jboss.tools.common.el.internal.core.parser.token.StringTokenDescription;
-import org.jboss.tools.common.el.internal.core.parser.token.WhiteSpaceTokenDescription;
-
-/**
- *
- * @author V. Kabanovich
- *
- */
-public class ArgRule implements IRule, BasicStates {
-
- public static ArgRule INSTANCE = new ArgRule();
-
- public int[] getStartStates() {
- return new int[] {
- STATE_EXPECTING_ARG,
- STATE_EXPECTING_ARG_CLOSE,
- };
- }
-
- public int getFinalState(int state, int token) {
- switch (token) {
- case WhiteSpaceTokenDescription.WHITESPACE:
- return state;
- case PrimitiveValueTokenDescription.PRIMITIVE_VALUE:
- case StringTokenDescription.STRING:
- return STATE_EXPECTING_ARG_CLOSE;
- case ArgEndTokenDescription.ARG_END:
- return STATE_EXPECTING_CALL_AFTER_METHOD;
- }
-
- return 0;
- }
-
- public int[] getTokenTypes(int state) {
- switch(state) {
- case STATE_EXPECTING_ARG:
- return new int[] {
- WhiteSpaceTokenDescription.WHITESPACE,
- PrimitiveValueTokenDescription.PRIMITIVE_VALUE,
- StringTokenDescription.STRING,
- };
- case STATE_EXPECTING_ARG_CLOSE:
- return new int[] {
- WhiteSpaceTokenDescription.WHITESPACE,
- ArgEndTokenDescription.ARG_END,
- };
- }
- return new int[0];
- }
-
-}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/CallRule.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/CallRule.java 2008-10-02
09:32:15 UTC (rev 10620)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/CallRule.java 2008-10-02
10:06:26 UTC (rev 10621)
@@ -11,6 +11,8 @@
package org.jboss.tools.common.el.internal.core.parser.rule;
import org.jboss.tools.common.el.core.parser.IRule;
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+import org.jboss.tools.common.el.internal.core.parser.token.ArgEndTokenDescription;
import org.jboss.tools.common.el.internal.core.parser.token.ArgStartTokenDescription;
import org.jboss.tools.common.el.internal.core.parser.token.CommaTokenDescription;
import org.jboss.tools.common.el.internal.core.parser.token.DotTokenDescription;
@@ -19,6 +21,7 @@
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.ParamStartTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ParamUtil;
import org.jboss.tools.common.el.internal.core.parser.token.WhiteSpaceTokenDescription;
/**
@@ -49,6 +52,7 @@
case OperationTokenDescription.OPERATION:
return STATE_EXPECTING_OPERAND;
case ParamEndTokenDescription.PARAM_END:
+ case ArgEndTokenDescription.ARG_END:
return STATE_EXPECTING_CALL_AFTER_METHOD;
case ParamStartTokenDescription.PARAM_START:
return STATE_EXPECTING_PARAM;
@@ -71,6 +75,7 @@
CommaTokenDescription.COMMA,
OperationTokenDescription.OPERATION,
ParamEndTokenDescription.PARAM_END,
+ ArgEndTokenDescription.ARG_END,
ExprEndTokenDescription.EXPR_END,
ParamStartTokenDescription.PARAM_START,
ArgStartTokenDescription.ARG_START,
@@ -83,10 +88,28 @@
CommaTokenDescription.COMMA,
OperationTokenDescription.OPERATION,
ParamEndTokenDescription.PARAM_END,
+ ArgEndTokenDescription.ARG_END,
ExprEndTokenDescription.EXPR_END,
+ ArgStartTokenDescription.ARG_START,
};
}
return new int[0];
}
+ public String getProblem(int state, Tokenizer tokenizer) {
+ if(ParamUtil.isMethodParamContext(tokenizer.getContext())) {
+ return "Expecting ',' or ')'";
+ } else if(ParamUtil.isComplexExpressionContext(tokenizer.getContext())) {
+ return "Expecting ')'";
+ } else if(ParamUtil.isArgContext(tokenizer.getContext())) {
+ return "Expecting ']'";
+ }
+ if(state == STATE_EXPECTING_CALL_AFTER_METHOD) {
+ if(ParamStartTokenDescription.INSTANCE.isStart(tokenizer,
tokenizer.getCurrentIndex())) {
+ return "Unexpected symbol '('";
+ }
+ }
+ return "Expecting '}'";
+ }
+
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ErrorRecoveryRule.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ErrorRecoveryRule.java 2008-10-02
09:32:15 UTC (rev 10620)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ErrorRecoveryRule.java 2008-10-02
10:06:26 UTC (rev 10621)
@@ -11,6 +11,7 @@
package org.jboss.tools.common.el.internal.core.parser.rule;
import org.jboss.tools.common.el.core.parser.IRule;
+import org.jboss.tools.common.el.core.parser.Tokenizer;
import org.jboss.tools.common.el.internal.core.parser.token.ArgEndTokenDescription;
import org.jboss.tools.common.el.internal.core.parser.token.EndELTokenDescription;
import org.jboss.tools.common.el.internal.core.parser.token.ExprEndTokenDescription;
@@ -33,7 +34,6 @@
case StartELTokenDescription.START_EL:
return BasicStates.STATE_EXPECTING_EXPRESSION;
case ArgEndTokenDescription.ARG_END:
- return BasicStates.STATE_EXPECTING_CALL_AFTER_METHOD;
case ParamEndTokenDescription.PARAM_END:
return BasicStates.STATE_EXPECTING_CALL_AFTER_METHOD;
case ExprEndTokenDescription.EXPR_END:
@@ -56,4 +56,9 @@
};
}
+ public String getProblem(int state, Tokenizer tokenizer) {
+ // Other rules already reported a problem.
+ return null;
+ }
+
}
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 2008-10-02
09:32:15 UTC (rev 10620)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ExpressionRule.java 2008-10-02
10:06:26 UTC (rev 10621)
@@ -11,6 +11,8 @@
package org.jboss.tools.common.el.internal.core.parser.rule;
import org.jboss.tools.common.el.core.parser.IRule;
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+import org.jboss.tools.common.el.internal.core.parser.token.ArgEndTokenDescription;
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;
@@ -37,6 +39,7 @@
STATE_EXPECTING_EXPRESSION,
STATE_EXPECTING_NAME,
STATE_EXPECTING_PARAM,
+ STATE_EXPECTING_ARG,
STATE_EXPECTING_OPERAND
};
}
@@ -56,6 +59,7 @@
case PrimitiveValueTokenDescription.PRIMITIVE_VALUE:
return STATE_EXPECTING_OPERATION;
case ParamEndTokenDescription.PARAM_END:
+ case ArgEndTokenDescription.ARG_END:
return STATE_EXPECTING_CALL_AFTER_METHOD;
case ExprStartTokenDescription.EXPR_START:
case UnaryTokenDescription.UNARY:
@@ -97,6 +101,15 @@
ExprStartTokenDescription.EXPR_START,
ParamEndTokenDescription.PARAM_END
};
+ case STATE_EXPECTING_ARG:
+ return new int[] {
+ WhiteSpaceTokenDescription.WHITESPACE,
+ UnaryTokenDescription.UNARY,
+ PrimitiveValueTokenDescription.PRIMITIVE_VALUE,
+ JavaNameTokenDescription.JAVA_NAME,
+ StringTokenDescription.STRING,
+ ExprStartTokenDescription.EXPR_START
+ };
case STATE_EXPECTING_OPERAND:
return new int[] {
WhiteSpaceTokenDescription.WHITESPACE,
@@ -111,4 +124,12 @@
return new int[0];
}
+ public String getProblem(int state, Tokenizer tokenizer) {
+ if(state == STATE_EXPECTING_NAME) {
+ return "Expecting Java method or property name";
+ } else {
+ return "Expecting expression";
+ }
+ }
+
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/OperationRule.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/OperationRule.java 2008-10-02
09:32:15 UTC (rev 10620)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/OperationRule.java 2008-10-02
10:06:26 UTC (rev 10621)
@@ -11,11 +11,14 @@
package org.jboss.tools.common.el.internal.core.parser.rule;
import org.jboss.tools.common.el.core.parser.IRule;
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+import org.jboss.tools.common.el.internal.core.parser.token.ArgEndTokenDescription;
import org.jboss.tools.common.el.internal.core.parser.token.CommaTokenDescription;
import org.jboss.tools.common.el.internal.core.parser.token.EndELTokenDescription;
import org.jboss.tools.common.el.internal.core.parser.token.ExprEndTokenDescription;
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.ParamUtil;
import org.jboss.tools.common.el.internal.core.parser.token.WhiteSpaceTokenDescription;
/**
@@ -43,6 +46,7 @@
case OperationTokenDescription.OPERATION:
return STATE_EXPECTING_OPERAND;
case ParamEndTokenDescription.PARAM_END:
+ case ArgEndTokenDescription.ARG_END:
return STATE_EXPECTING_CALL_AFTER_METHOD;
case ExprEndTokenDescription.EXPR_END:
return STATE_EXPECTING_OPERATION;
@@ -56,6 +60,7 @@
return new int[] {
WhiteSpaceTokenDescription.WHITESPACE,
ParamEndTokenDescription.PARAM_END,
+ ArgEndTokenDescription.ARG_END,
ExprEndTokenDescription.EXPR_END,
CommaTokenDescription.COMMA,
OperationTokenDescription.OPERATION,
@@ -65,4 +70,15 @@
return new int[0];
}
+ public String getProblem(int state, Tokenizer tokenizer) {
+ if(ParamUtil.isMethodParamContext(tokenizer.getContext())) {
+ return "Expecting ')'";
+ } else if(ParamUtil.isComplexExpressionContext(tokenizer.getContext())) {
+ return "Expecting ')'";
+ } else if(ParamUtil.isArgContext(tokenizer.getContext())) {
+ return "Expecting ']'";
+ }
+ return "Expecting '}'";
+ }
+
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ArgEndTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ArgEndTokenDescription.java 2008-10-02
09:32:15 UTC (rev 10620)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ArgEndTokenDescription.java 2008-10-02
10:06:26 UTC (rev 10621)
@@ -38,19 +38,15 @@
}
public boolean isStart(Tokenizer tokenizer, int offset) {
- return isInArg(tokenizer) && super.isStart(tokenizer, offset);
+ return ParamUtil.isArgContext(tokenizer.getContext()) &&
super.isStart(tokenizer, offset);
}
public boolean read(Tokenizer tokenizer, int offset) {
boolean b = super.read(tokenizer, offset);
if(b) {
- tokenizer.getContext().remove("arg");
+ ParamUtil.closeCurrentParamContext(tokenizer.getContext());
}
return b;
}
- private boolean isInArg(Tokenizer tokenizer) {
- return tokenizer.getContext().get("arg") != null;
- }
-
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ArgStartTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ArgStartTokenDescription.java 2008-10-02
09:32:15 UTC (rev 10620)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ArgStartTokenDescription.java 2008-10-02
10:06:26 UTC (rev 10621)
@@ -30,7 +30,7 @@
public boolean read(Tokenizer tokenizer, int offset) {
boolean b = super.read(tokenizer, offset);
if(b) {
- tokenizer.getContext().put("arg", OPEN);
+ ParamUtil.openArgContext(tokenizer.getContext());
}
return b;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ParamUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ParamUtil.java 2008-10-02
09:32:15 UTC (rev 10620)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ParamUtil.java 2008-10-02
10:06:26 UTC (rev 10621)
@@ -43,6 +43,11 @@
return i != null && i.size() > 0 &&
"params".equals(i.get(i.size() - 1));
}
+ public static boolean isArgContext(Properties context) {
+ ParamHistory i = (ParamHistory)(context.get(PARAM_HISTORY));
+ return i != null && i.size() > 0 &&
"arg".equals(i.get(i.size() - 1));
+ }
+
public static boolean isComplexExpressionContext(Properties context) {
ParamHistory i = (ParamHistory)(context.get("(_level"));
return i != null && i.size() > 0 &&
"expr".equals(i.get(i.size() - 1));
@@ -65,4 +70,10 @@
i.add("expr");
}
+ public static void openArgContext(Properties context) {
+ ParamHistory i = (ParamHistory)(context.get("(_level"));
+ i.add("arg");
+ }
+
+
}