Author: scabanovich
Date: 2011-03-15 18:18:34 -0400 (Tue, 15 Mar 2011)
New Revision: 29800
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELComplexInvocationExpressionImpl.java
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELUtil.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/OperationRule.java
Log:
JBIDE-8593
https://issues.jboss.org/browse/JBIDE-8593
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELUtil.java 2011-03-15
22:12:08 UTC (rev 29799)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELUtil.java 2011-03-15
22:18:34 UTC (rev 29800)
@@ -50,6 +50,7 @@
result = l;
l = l.getLeft();
}
+ return result;
}
}
}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELComplexInvocationExpressionImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELComplexInvocationExpressionImpl.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELComplexInvocationExpressionImpl.java 2011-03-15
22:18:34 UTC (rev 29800)
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * 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.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;
+import org.jboss.tools.common.el.internal.core.parser.token.ExprStartTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.UnaryTokenDescription;
+
+/**
+ * '(' expression ')'
+ * @author V. Kabanovich
+ */
+public class ELComplexInvocationExpressionImpl extends ELExpressionImpl {
+ ELComplexExpressionImpl expression;
+ ELInvocationExpressionImpl invocation;
+
+ public ELComplexInvocationExpressionImpl() {
+ }
+
+ public ELExpressionImpl getExpression() {
+ return expression;
+ }
+
+ public ELInvocationExpressionImpl getInvocation() {
+ return invocation;
+ }
+
+ public void addChild(ELObjectImpl child) {
+ if(child instanceof ELComplexExpressionImpl) {
+ setExpression((ELComplexExpressionImpl)child);
+ } else if(child instanceof ELInvocationExpressionImpl) {
+ setInvocation((ELInvocationExpressionImpl)child);
+ } else {
+ throw new IllegalArgumentException("EL instance can have only EL expression as
child."); //$NON-NLS-1$
+ }
+ }
+
+ public void setExpression(ELComplexExpressionImpl expression) {
+ if(this.expression == expression) {
+ return;
+ }
+ if(this.expression != null) {
+ removeChild(this.expression);
+ }
+ this.expression = expression;
+ if(expression != null) {
+ super.addChild(expression);
+ }
+ }
+
+ public void setInvocation(ELInvocationExpressionImpl invocation) {
+ if(this.invocation == invocation) {
+ return;
+ }
+ if(this.invocation != null) {
+ removeChild(this.invocation);
+ }
+ this.invocation = invocation;
+ if(invocation != null) {
+ super.addChild(invocation);
+ }
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ if(expression != null) {
+ sb.append(expression.toString());
+ }
+ if(invocation != null) {
+ sb.append(invocation.toString());
+
+ }
+ return sb.toString();
+ }
+
+ public ELObjectType getType() {
+ return ELObjectType.EL_METHOD_INVOCATION;
+ }
+
+ public void collectInvocations(List<ELInvocationExpression> list) {
+ if(expression != null) {
+ expression.collectInvocations(list);
+ }
+ if(invocation != null) {
+ list.add(invocation);
+ }
+ }
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELComplexInvocationExpressionImpl.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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 2011-03-15
22:12:08 UTC (rev 29799)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELInvocationExpressionImpl.java 2011-03-15
22:18:34 UTC (rev 29800)
@@ -22,6 +22,7 @@
*/
public abstract class ELInvocationExpressionImpl extends ELExpressionImpl implements
ELInvocationExpression {
protected ELInvocationExpressionImpl left;
+ boolean leftIsFake = false;
public ELInvocationExpressionImpl() {}
@@ -32,6 +33,10 @@
return left;
}
+ public void setLeftIsFake(boolean b) {
+ leftIsFake = b;
+ }
+
public void setLeft(ELInvocationExpressionImpl left) {
this.left = left;
if(left != null) {
@@ -46,7 +51,7 @@
}
public String toString() {
- return left != null ? left.toString() : ""; //$NON-NLS-1$
+ return left != null && !leftIsFake ? left.toString() : "";
//$NON-NLS-1$
}
public void collectInvocations(List<ELInvocationExpression> list) {
@@ -59,6 +64,7 @@
} else if(l instanceof ELArgumentExpressionImpl) {
((ELArgumentExpressionImpl)l).collectInvocationsInArgument(list);
}
+ if(leftIsFake) break;
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 2011-03-15
22:12:08 UTC (rev 29799)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/ELParserImpl.java 2011-03-15
22:18:34 UTC (rev 29800)
@@ -10,11 +10,15 @@
******************************************************************************/
package org.jboss.tools.common.el.internal.core.parser;
+import java.util.List;
+
+import org.jboss.tools.common.el.core.model.ELInvocationExpression;
import org.jboss.tools.common.el.core.parser.LexicalToken;
import org.jboss.tools.common.el.core.parser.Tokenizer;
import org.jboss.tools.common.el.internal.core.model.ELArgumentImpl;
import org.jboss.tools.common.el.internal.core.model.ELArgumentExpressionImpl;
import org.jboss.tools.common.el.internal.core.model.ELComplexExpressionImpl;
+import org.jboss.tools.common.el.internal.core.model.ELComplexInvocationExpressionImpl;
import org.jboss.tools.common.el.internal.core.model.ELExpressionImpl;
import org.jboss.tools.common.el.internal.core.model.ELInstanceImpl;
import org.jboss.tools.common.el.internal.core.model.ELInvocationExpressionImpl;
@@ -156,6 +160,12 @@
if(current == null) return null;
switch(current.getType()) {
case ExprStartTokenDescription.EXPR_START:
+ ELComplexExpressionImpl complex = readComplexExpression();
+ if(current != null && current.getType() == DotTokenDescription.DOT) {
+ return readComplexInvocationExpression(complex);
+ } else {
+ return complex;
+ }
case UnaryTokenDescription.UNARY:
return readComplexExpression();
case StringTokenDescription.STRING:
@@ -175,7 +185,7 @@
return null;
}
- protected ELExpressionImpl readComplexExpression() {
+ protected ELComplexExpressionImpl readComplexExpression() {
ELComplexExpressionImpl expr = new ELComplexExpressionImpl();
expr.setFirstToken(current);
if(!hasNextToken()) {
@@ -195,6 +205,28 @@
return expr;
}
+ protected ELComplexInvocationExpressionImpl
readComplexInvocationExpression(ELComplexExpressionImpl complex) {
+ ELInvocationExpressionImpl left = null;
+ List<ELInvocationExpression> is = complex.getInvocations();
+ if(is != null && !is.isEmpty()) {
+ left = (ELInvocationExpressionImpl)is.get(0);
+ } else {
+ ELPropertyInvocationImpl fake = new ELPropertyInvocationImpl();
+ LexicalToken t = new LexicalToken(current.getStart(), 0, "",
StringTokenDescription.STRING);
+ fake.setName(t);
+ left = fake;
+ }
+ ELComplexInvocationExpressionImpl result = new ELComplexInvocationExpressionImpl();
+ result.setExpression(complex);
+ ELInvocationExpressionImpl right = readRightExpression(left, true);
+ if(right != left) {
+ result.setInvocation(right);
+ }
+ result.setFirstToken(complex.getFirstToken());
+ result.setLastToken(right.getLastToken());
+ return result;
+ }
+
protected ELInvocationExpressionImpl readInvocationExpression() {
if(current == null ||
(current.getType() != JavaNameTokenDescription.JAVA_NAME &&
@@ -223,6 +255,10 @@
}
break;
}
+ return readRightExpression(result, false);
+ }
+
+ ELInvocationExpressionImpl readRightExpression(ELInvocationExpressionImpl result,
boolean isLeftFake) {
if(current != null && current.getType() == DotTokenDescription.DOT) {
LexicalToken dot = current;
setNextToken();
@@ -235,13 +271,15 @@
} else {
//is it possible?
}
- r.setLeft(result);
+ r.setLeft(result);
+ r.setLeftIsFake(isLeftFake);
result = right;
} else {
ELPropertyInvocationImpl incompleteProperty = new ELPropertyInvocationImpl();
incompleteProperty.setSeparator(dot);
incompleteProperty.setLastToken(dot);
incompleteProperty.setLeft(result);
+ incompleteProperty.setLeftIsFake(isLeftFake);
result = incompleteProperty;
}
}
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 2011-03-15
22:12:08 UTC (rev 29799)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/CallRule.java 2011-03-15
22:18:34 UTC (rev 29800)
@@ -60,7 +60,7 @@
case ArgStartTokenDescription.ARG_START:
return STATE_EXPECTING_ARG;
case ExprEndTokenDescription.EXPR_END:
- return STATE_EXPECTING_OPERATION;
+ return STATE_EXPECTING_CALL; // STATE_EXPECTING_OPERATION;
}
return 0;
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 2011-03-15
22:12:08 UTC (rev 29799)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ErrorRecoveryRule.java 2011-03-15
22:18:34 UTC (rev 29800)
@@ -37,7 +37,7 @@
case ParamEndTokenDescription.PARAM_END:
return BasicStates.STATE_EXPECTING_CALL_AFTER_METHOD;
case ExprEndTokenDescription.EXPR_END:
- return BasicStates.STATE_EXPECTING_OPERATION;
+ return BasicStates.STATE_EXPECTING_CALL; // STATE_EXPECTING_OPERATION;
}
return 0;
}
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 2011-03-15
22:12:08 UTC (rev 29799)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/OperationRule.java 2011-03-15
22:18:34 UTC (rev 29800)
@@ -50,7 +50,7 @@
case ArgEndTokenDescription.ARG_END:
return STATE_EXPECTING_CALL_AFTER_METHOD;
case ExprEndTokenDescription.EXPR_END:
- return STATE_EXPECTING_OPERATION;
+ return STATE_EXPECTING_CALL; // STATE_EXPECTING_OPERATION;
}
return 0;