Author: scabanovich
Date: 2009-07-27 11:23:22 -0400 (Mon, 27 Jul 2009)
New Revision: 16819
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserUtil.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/TokenizerFactory.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2016
In case of collection and maps default EL parser used for JSF is extended to understand
access to elements like iterator().next().
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserUtil.java 2009-07-27
15:03:34 UTC (rev 16818)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserUtil.java 2009-07-27
15:23:22 UTC (rev 16819)
@@ -42,6 +42,29 @@
return DEFAULT_FACTORY;
}
+ private static ELParserFactory COLLECTION_FACTORY = new DefaultFactory() {
+ public ELParser newParser() {
+ return new DefaultParser() {
+ protected Tokenizer createTokenizer() {
+ return TokenizerFactory.createCollectionTokenizer();
+ }
+ public void dispose() {
+ super.dispose();
+ release(this);
+ }
+ };
+ }
+ };
+
+ /**
+ * Extends default factory by ability to parse method invocation without parameters
+ * to support access to collection and map elements by .iterator().next()
+ * @return
+ */
+ public static ELParserFactory getCollectionFactory() {
+ return COLLECTION_FACTORY;
+ }
+
private static ELParserFactory JBOSS_FACTORY = new DefaultFactory() {
public ELParser newParser() {
return new DefaultParser() {
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 2009-07-27
15:03:34 UTC (rev 16818)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/TokenizerFactory.java 2009-07-27
15:23:22 UTC (rev 16819)
@@ -11,6 +11,7 @@
package org.jboss.tools.common.el.core.parser;
import java.util.List;
+import java.util.regex.Pattern;
import org.jboss.tools.common.el.core.model.ELExpression;
import org.jboss.tools.common.el.core.model.ELInvocationExpression;
@@ -105,7 +106,35 @@
return t;
}
+ //Adds to default description set param start and param end to support access to
collection and map elements.
+ private static ITokenDescription[] COLLECTIONS_DESCRIPTION_SET = new ITokenDescription[]
{
+ ArgEndTokenDescription.INSTANCE,
+ ArgStartTokenDescription.INSTANCE,
+ DotTokenDescription.INSTANCE,
+ EndELTokenDescription.INSTANCE,
+ JavaNameTokenDescription.INSTANCE,
+ OperationTokenDescription.INSTANCE,
+ ParamEndTokenDescription.INSTANCE,
+ ParamStartTokenDescription.INSTANCE,
+ UnaryTokenDescription.INSTANCE,
+ PrimitiveValueTokenDescription.INSTANCE,
+ StartELTokenDescription.INSTANCE,
+ StringTokenDescription.INSTANCE,
+ WhiteSpaceTokenDescription.INSTANCE,
+ };
+
+ public static Tokenizer createCollectionTokenizer() {
+ Tokenizer t = new Tokenizer();
+ t.setTokenDescriptions(COLLECTIONS_DESCRIPTION_SET);
+ t.setRules(DEFAULT_RULE_SET);
+ return t;
+ }
+
+
public static void main(String[] args) {
+ boolean b = Pattern.matches("re(he|ma)*\\sat", "rehemahe at");
+ System.out.println(b);
+ if(true) return;
String text = "ioioio#{a(1.2e1i) + b c + d}ioioio#{0}"; //$NON-NLS-1$
//"#{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.}";