Author: scabanovich
Date: 2011-03-15 18:20:28 -0400 (Tue, 15 Mar 2011)
New Revision: 29802
Modified:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELModelTest.java
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java
Log:
JBIDE-8593
https://issues.jboss.org/browse/JBIDE-8593
Modified:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELModelTest.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELModelTest.java 2011-03-15
22:20:07 UTC (rev 29801)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELModelTest.java 2011-03-15
22:20:28 UTC (rev 29802)
@@ -20,6 +20,7 @@
import org.jboss.tools.common.el.core.model.ELObject;
import org.jboss.tools.common.el.core.model.ELObjectType;
import org.jboss.tools.common.el.core.model.ELParameters;
+import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
import org.jboss.tools.common.el.core.parser.ELParser;
import org.jboss.tools.common.el.core.parser.ELParserUtil;
@@ -68,4 +69,36 @@
assertEquals(ELObjectType.EL_COMPLEX_EXPRESSION, expr_2_1.getType());
}
+ public void testInvokingMethodOnExpressionInParenthesis() {
+ ELParser parser = ELParserUtil.getJbossFactory().createParser();
+ String el = "#{(a.b() + c).d()}";
+ ELModel model = parser.parse(el);
+
+ List<ELInstance> instances = model.getInstances();
+
+ assertEquals(1, instances.size());
+
+ ELInstance instance = instances.get(0);
+ ELExpression expr = instance.getExpression();
+
+ List<ELObject> cs = expr.getChildren();
+ assertEquals(2, cs.size());
+
+
+ assertEquals("(a.b()+c)", cs.get(0).toString());
+ List<ELObject> cs1 = cs.get(0).getChildren();
+ assertEquals(1, cs1.size());
+ ELExpression expr1 = (ELExpression)cs1.get(0);
+ assertEquals("a.b()+c", expr1.toString());
+ List<ELObject> cs2 = expr1.getChildren();
+ assertTrue(cs2.get(0) instanceof ELMethodInvocation);
+ assertEquals("a.b()", cs2.get(0).toString());
+ assertTrue(cs2.get(2) instanceof ELPropertyInvocation);
+ assertEquals("c", cs2.get(2).toString());
+
+ assertTrue(cs.get(1) instanceof ELMethodInvocation);
+ assertEquals("d", ((ELMethodInvocation)cs.get(1)).getName().getText());
+
+ }
+
}
Modified:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java 2011-03-15
22:20:07 UTC (rev 29801)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java 2011-03-15
22:20:28 UTC (rev 29802)
@@ -272,6 +272,11 @@
checkCorrectEL(t, "aaa#{a}bbb#{1}#{c()}");
}
+ public void testElInParenthesis() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ checkCorrectEL(t, "#{(a + 1).toString()}");
+ }
+
private void checkCorrectEL(Tokenizer t, String test) {
LexicalToken token = t.parse(test);
assertEquals(test, restore(token));