Author: scabanovich
Date: 2008-09-24 09:24:20 -0400 (Wed, 24 Sep 2008)
New Revision: 10448
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELExpression.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/ELComplexExpressionImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELExpressionImpl.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/model/ELMethodInvocationImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELMultiExpressionImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELPropertyInvocationImpl.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/ExpressionRule.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/OperationTokenDescription.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/UnaryTokenDescription.java
Log:
JBIDE-1497.
Minor fixes in EL parser.
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELExpression.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELExpression.java 2008-09-24
13:08:51 UTC (rev 10447)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELExpression.java 2008-09-24
13:24:20 UTC (rev 10448)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.common.el.core.model;
+import java.util.List;
+
/**
*
* @author V. Kabanovich
@@ -17,4 +19,10 @@
*/
public interface ELExpression extends ELObject {
+ /**
+ * Utility method
+ * @return
+ */
+ public List<ELInvocationExpression> getInvocations();
+
}
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-09-24
13:08:51 UTC (rev 10447)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/TokenizerFactory.java 2008-09-24
13:24:20 UTC (rev 10448)
@@ -13,6 +13,7 @@
import java.util.List;
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.ELModel;
import org.jboss.tools.common.el.internal.core.parser.rule.ArgRule;
import org.jboss.tools.common.el.internal.core.parser.rule.CallRule;
@@ -99,8 +100,8 @@
}
public static void main(String[] args) {
- String text = //"#{a.b.}";
-"#{a.b + s.h((6 != -8) & (7 + -iy88.g[9].h(7 div 8).i.j)+(8) ? 4 :
7,'p', a.b.c.d[null])}";
+ String text = "#{a.b().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}";
Tokenizer t = createJbossTokenizer();
LexicalToken token = t.parse(text);
@@ -120,6 +121,11 @@
System.out.println(model);
ELExpression expr = model.getInstances().get(0).getExpression();
System.out.println("Expression=" + expr);
+ List<ELInvocationExpression> is = expr.getInvocations();
+ System.out.println("Invocations:");
+ for (ELInvocationExpression i : is) {
+ System.out.println(i);
+ }
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELComplexExpressionImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELComplexExpressionImpl.java 2008-09-24
13:08:51 UTC (rev 10447)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELComplexExpressionImpl.java 2008-09-24
13:24:20 UTC (rev 10448)
@@ -10,6 +10,9 @@
******************************************************************************/
package org.jboss.tools.common.el.internal.core.model;
+import java.util.List;
+
+import org.jboss.tools.common.el.core.model.ELInvocationExpression;
import org.jboss.tools.common.el.core.model.ELObjectType;
import org.jboss.tools.common.el.core.parser.LexicalToken;
import org.jboss.tools.common.el.internal.core.parser.token.ExprEndTokenDescription;
@@ -89,4 +92,9 @@
return ELObjectType.EL_COMPLEX_EXPRESSION;
}
+ public void collectInvocations(List<ELInvocationExpression> list) {
+ if(expression != null) {
+ expression.collectInvocations(list);
+ }
+ }
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELExpressionImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELExpressionImpl.java 2008-09-24
13:08:51 UTC (rev 10447)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELExpressionImpl.java 2008-09-24
13:24:20 UTC (rev 10448)
@@ -10,7 +10,11 @@
******************************************************************************/
package org.jboss.tools.common.el.internal.core.model;
+import java.util.ArrayList;
+import java.util.List;
+
import org.jboss.tools.common.el.core.model.ELExpression;
+import org.jboss.tools.common.el.core.model.ELInvocationExpression;
/**
*
@@ -21,4 +25,13 @@
public ELExpressionImpl() {}
+ public List<ELInvocationExpression> getInvocations() {
+ List<ELInvocationExpression> list = new
ArrayList<ELInvocationExpression>();
+ collectInvocations(list);
+ return list;
+ }
+
+ public void collectInvocations(List<ELInvocationExpression> 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-09-24
13:08:51 UTC (rev 10447)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELInvocationExpressionImpl.java 2008-09-24
13:24:20 UTC (rev 10448)
@@ -10,7 +10,10 @@
******************************************************************************/
package org.jboss.tools.common.el.internal.core.model;
+import java.util.List;
+
import org.jboss.tools.common.el.core.model.ELInvocationExpression;
+import org.jboss.tools.common.el.core.model.ELObject;
/**
*
@@ -34,6 +37,11 @@
if(left != null) {
left.setParent(this);
setFirstToken(left.getFirstToken());
+ ELObject p = parent;
+ while(p instanceof ELInvocationExpressionImpl) {
+ ((ELInvocationExpressionImpl)p).setFirstToken(firstToken);
+ p = p.getParent();
+ }
}
}
@@ -41,4 +49,8 @@
return left != null ? left.toString() : "";
}
+ public void collectInvocations(List<ELInvocationExpression> list) {
+ list.add(this);
+ //We do not need left part expression, it is part of this invocation
+ }
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELMethodInvocationImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELMethodInvocationImpl.java 2008-09-24
13:08:51 UTC (rev 10447)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELMethodInvocationImpl.java 2008-09-24
13:24:20 UTC (rev 10448)
@@ -10,6 +10,10 @@
******************************************************************************/
package org.jboss.tools.common.el.internal.core.model;
+import java.util.List;
+
+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.ELMethodInvocation;
import org.jboss.tools.common.el.core.model.ELObjectType;
@@ -49,4 +53,13 @@
return ELObjectType.EL_METHOD_INVOCATION;
}
+ public void collectInvocations(List<ELInvocationExpression> list) {
+ super.collectInvocations(list);
+ if(parameters != null) {
+ List<ELExpression> ps = parameters.getParameters();
+ for (ELExpression expr: ps) {
+ ((ELExpressionImpl)expr).collectInvocations(list);
+ }
+ }
+ }
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELMultiExpressionImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELMultiExpressionImpl.java 2008-09-24
13:08:51 UTC (rev 10447)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELMultiExpressionImpl.java 2008-09-24
13:24:20 UTC (rev 10448)
@@ -13,6 +13,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.tools.common.el.core.model.ELInvocationExpression;
import org.jboss.tools.common.el.core.model.ELObject;
import org.jboss.tools.common.el.core.model.ELObjectType;
@@ -77,4 +78,10 @@
return ELObjectType.EL_MULTI_EXPRESSION;
}
+ public void collectInvocations(List<ELInvocationExpression> list) {
+ for (ELExpressionImpl expr: expressions) {
+ expr.collectInvocations(list);
+ }
+ }
+
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELPropertyInvocationImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELPropertyInvocationImpl.java 2008-09-24
13:08:51 UTC (rev 10447)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELPropertyInvocationImpl.java 2008-09-24
13:24:20 UTC (rev 10448)
@@ -40,6 +40,7 @@
this.name = name;
if(name != null) {
if(left == null) setFirstToken(name);
+ setLastToken(name);
}
}
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-09-24
13:08:51 UTC (rev 10447)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/ELParserImpl.java 2008-09-24
13:24:20 UTC (rev 10448)
@@ -181,8 +181,8 @@
case ParamStartTokenDescription.PARAM_START:
ELParametersImpl params = readParameters();
ELMethodInvocationImpl method = new ELMethodInvocationImpl();
+ method.setName(name.getName());
method.setParameters(params);
- method.setName(name.getName());
result = method;
}
if(current.getType() == DotTokenDescription.DOT) {
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-09-24
13:08:51 UTC (rev 10447)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ExpressionRule.java 2008-09-24
13:24:20 UTC (rev 10448)
@@ -75,12 +75,12 @@
case STATE_EXPECTING_EXPRESSION:
return new int[] {
WhiteSpaceTokenDescription.WHITESPACE,
+ UnaryTokenDescription.UNARY,
EndELTokenDescription.END_EL,
PrimitiveValueTokenDescription.PRIMITIVE_VALUE,
JavaNameTokenDescription.JAVA_NAME,
StringTokenDescription.STRING,
ExprStartTokenDescription.EXPR_START,
- UnaryTokenDescription.UNARY,
};
case STATE_EXPECTING_NAME:
return new int[] {
@@ -90,20 +90,20 @@
case STATE_EXPECTING_PARAM:
return new int[] {
WhiteSpaceTokenDescription.WHITESPACE,
+ UnaryTokenDescription.UNARY,
PrimitiveValueTokenDescription.PRIMITIVE_VALUE,
JavaNameTokenDescription.JAVA_NAME,
StringTokenDescription.STRING,
ExprStartTokenDescription.EXPR_START,
- UnaryTokenDescription.UNARY,
ParamEndTokenDescription.PARAM_END
};
case STATE_EXPECTING_OPERAND:
return new int[] {
WhiteSpaceTokenDescription.WHITESPACE,
+ UnaryTokenDescription.UNARY,
PrimitiveValueTokenDescription.PRIMITIVE_VALUE,
StringTokenDescription.STRING,
ExprStartTokenDescription.EXPR_START,
- UnaryTokenDescription.UNARY,
JavaNameTokenDescription.JAVA_NAME,
};
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/OperationTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/OperationTokenDescription.java 2008-09-24
13:08:51 UTC (rev 10447)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/OperationTokenDescription.java 2008-09-24
13:24:20 UTC (rev 10448)
@@ -56,7 +56,8 @@
if(end < 0) return false;
char ch = tokenizer.lookUpChar(end);
if(Character.isWhitespace(ch) || ch == '\0' || ch == '('
- || (canBeFollowedByOperand && Character.isJavaIdentifierPart(ch))) {
+ || (canBeFollowedByOperand && Character.isJavaIdentifierPart(ch)
+ || ch == '\'' || ch == '"' || ch == '-')) {
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 2008-09-24
13:08:51 UTC (rev 10447)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/UnaryTokenDescription.java 2008-09-24
13:24:20 UTC (rev 10448)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.common.el.internal.core.parser.token;
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+
/**
*
* @author V. Kabanovich
@@ -20,6 +22,10 @@
public static UnaryTokenDescription INSTANCE = new UnaryTokenDescription();
+ private static final String[] OPS_2 = {
+ "not",
+ };
+
public UnaryTokenDescription() {
super("!", UNARY);
addContent("--");
@@ -28,4 +34,38 @@
addContent("-");
}
+ 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 == '('
+ ) {
+ 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;
+ }
+
}