Author: scabanovich
Date: 2008-09-23 10:01:49 -0400 (Tue, 23 Sep 2008)
New Revision: 10409
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELOperandResolveStatus.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/Var.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/ElVarSearcher.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java
Log:
JBIDE-1497
Classes Var and SeamELOperandResolveStatus are moved to separate files.
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF 2008-09-23 14:00:46
UTC (rev 10408)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF 2008-09-23 14:01:49
UTC (rev 10409)
@@ -14,6 +14,7 @@
org.eclipse.jdt.core,
org.eclipse.jdt.ui,
org.jboss.tools.common.model,
+ org.jboss.tools.common.el.core,
org.eclipse.wst.common.frameworks.ui,
org.eclipse.wst.common.project.facet.core,
org.eclipse.jst.jsf.core,
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/ElVarSearcher.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/ElVarSearcher.java 2008-09-23
14:00:46 UTC (rev 10408)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/ElVarSearcher.java 2008-09-23
14:01:49 UTC (rev 10409)
@@ -284,141 +284,4 @@
return null;
}
- /**
- * Represents "var"/"value" attributes.
- * @author Alexey Kazakov
- */
- public static class Var {
- String name;
- String value;
- ELToken elToken;
- String resolvedValue;
- ELToken resolvedElToken;
- int declOffset;
- int declLength;
-
- /**
- * Constructor
- * @param name - value of "var" attribute.
- * @param value - value of "value" attribute.
- */
- public Var(String name, String value, int declOffset, int declLength) {
- super();
- this.name = name;
- this.value = value;
- elToken = parseEl(value);
- this.declOffset = declOffset;
- this.declLength = declLength;
- }
-
- /**
- * Constructor
- * @param name - value of "var" attribute.
- * @param value - value of "value" attribute.
- */
- public Var(String name, String value) {
- this(name, value, 0, 0);
- }
-
- private ELToken parseEl(String el) {
- if(el.length()>3 && el.startsWith("#{") &&
el.endsWith("}")) {
- String elBody = el.substring(0, el.length()-1).substring(2);
- SeamELTokenizer elTokenizer = new SeamELTokenizer(elBody);
- List<ELToken> tokens = elTokenizer.getTokens();
- for (ELToken token : tokens) {
- if(token.getType()==ELToken.EL_VARIABLE_TOKEN) {
- return token;
- }
- }
- }
- return null;
- }
-
- /**
- * Sets value to new resolved EL which we got as result of parsing value.
- * For example:
- * <h:datatable value="#{list}" var="item">
- * <h:dataTable value="#{item.anotherList}"
var="innerItem">
- * ...
- * </h:dataTable>
- * </h:dataTable>
- * Original El is #{item.anotherList}
- * Resolved El is #{list.iterator().next().anotherList}
- * It's very useful for nested vars.
- * @param newEl
- */
- public void resolveValue(String newEl) {
- resolvedValue = newEl;
- resolvedElToken = parseEl(newEl);
- }
-
- /**
- * @return parsed EL from "value" attribute. Returns null if EL is not
valid.
- */
- public ELToken getElToken() {
- return elToken;
- }
-
- /**
- * @return parsed resolved EL from "value" attribute. May be null.
- */
- public ELToken getResolvedElToken() {
- return resolvedElToken;
- }
-
- /**
- * @return name of variable.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @return value of variable. It's EL.
- */
- public String getValue() {
- return value;
- }
-
- /**
- * @return resolved value of variable. It's EL. May be null.
- */
- public String getResolvedValue() {
- return resolvedValue;
- }
-
- /**
- * @return offset of the var declaration
- */
- public int getDeclarationOffset() {
- return declOffset;
- }
-
- /**
- * @return length of the var declaration
- */
- public int getDeclarationLength() {
- return declLength;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof Var) {
- Var compare = (Var)obj;
- String str = getName();
- if (str != null) {
- if (!str.equals(compare.getName()))
- return false;
- } else {
- if (compare.getName() != null)
- return false;
- }
- str = getValue();
- return (str != null ?
- str.equals(compare.getValue()) :
- compare.getValue() == null);
- }
- return false;
- }
- }
}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2008-09-23
14:00:46 UTC (rev 10408)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2008-09-23
14:01:49 UTC (rev 10409)
@@ -36,7 +36,6 @@
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ScopeType;
import org.jboss.tools.seam.core.SeamCorePlugin;
-import org.jboss.tools.seam.internal.core.el.ElVarSearcher.Var;
import org.jboss.tools.seam.internal.core.el.SeamExpressionResolver.MessagesInfo;
/**
@@ -105,169 +104,6 @@
return completions;
}
- /**
- * Status of EL resolving.
- * @author Jeremy
- */
- public static class SeamELOperandResolveStatus {
- private List<ELOperandToken> tokens;
- public List<ISeamContextVariable> usedVariables;
- Map<String, TypeInfoCollector.MethodInfo> unpairedGettersOrSetters;
- Set<String> proposals;
- private ELOperandToken lastResolvedToken;
- private boolean isMapOrCollectionOrBundleAmoungTheTokens = false;
- private TypeInfoCollector.MemberInfo memberOfResolvedOperand;
-
- /**
- * @return MemberInfo of last segment of EL operand. Null if El is not resolved.
- */
- public TypeInfoCollector.MemberInfo getMemberOfResolvedOperand() {
- return memberOfResolvedOperand;
- }
-
- /**
- * Sets MemberInfo for last segment of EL operand.
- * @param lastResolvedMember
- */
- public void setMemberOfResolvedOperand(
- TypeInfoCollector.MemberInfo lastResolvedMember) {
- this.memberOfResolvedOperand = lastResolvedMember;
- }
-
- /**
- * Constructor
- * @param tokens Tokens of EL
- */
- public SeamELOperandResolveStatus(List<ELOperandToken> tokens) {
- this.tokens = tokens;
- }
-
- /**
- * @return true if EL contains any not parametrized Collection or ResourceBundle.
- */
- public boolean isMapOrCollectionOrBundleAmoungTheTokens() {
- return this.isMapOrCollectionOrBundleAmoungTheTokens;
- }
-
- public void setMapOrCollectionOrBundleAmoungTheTokens() {
- this.isMapOrCollectionOrBundleAmoungTheTokens = true;
- }
-
- /**
- * @return true if EL is resolved.
- */
- public boolean isOK() {
- return !getProposals().isEmpty() || isMapOrCollectionOrBundleAmoungTheTokens();
- }
-
- /**
- * @return false if El is not resolved.
- */
- public boolean isError() {
- return !isOK();
- }
-
- /**
- * @return List of resolved tokens of EL. Includes separators "."
- */
- public List<ELOperandToken> getResolvedTokens() {
- List<ELOperandToken> resolvedTokens = new ArrayList<ELOperandToken>();
- int index = tokens.indexOf(lastResolvedToken); // index == -1 means that no tokens are
resolved
- for (int i = 0; i < tokens.size() && i <= index; i++) {
- resolvedTokens.add(tokens.get(i));
- }
- return resolvedTokens;
- }
-
- /**
- * @return List of unresolved tokens of EL.
- */
- public List<ELOperandToken> getUnresolvedTokens() {
- List<ELOperandToken> unresolvedTokens = new ArrayList<ELOperandToken>();
- int index = tokens.indexOf(lastResolvedToken); // index == -1 means that no tokens are
resolved
- for (int i = index + 1; i < tokens.size(); i++) {
- unresolvedTokens.add(tokens.get(i));
- }
- return unresolvedTokens;
- }
-
- /**
- * @return Last resolved token of EL. Can be separator "."
- */
- public ELOperandToken getLastResolvedToken() {
- return lastResolvedToken;
- }
-
- /**
- * @param lastResolvedToken Last resolved token of EL. Can be separator "."
- */
- public void setLastResolvedToken(ELOperandToken lastResolvedToken) {
- this.lastResolvedToken = lastResolvedToken;
- }
-
- /**
- * @return Tokens of EL.
- */
- public List<ELOperandToken> getTokens() {
- return tokens;
- }
-
- /**
- * @param tokens Tokens of EL.
- */
- public void setTokens(List<ELOperandToken> tokens) {
- this.tokens = tokens;
- }
-
- /**
- * @return Set of proposals for EL.
- */
- public Set<String> getProposals() {
- return proposals == null ? new TreeSet<String>() : proposals;
- }
-
- /**
- * @param proposals Set of proposals.
- */
- public void setProposals(Set<String> proposals) {
- this.proposals = proposals;
- }
-
- /**
- * @return List of Seam Context Variables used in EL.
- */
- public List<ISeamContextVariable> getUsedVariables() {
- return (usedVariables == null ? new ArrayList<ISeamContextVariable>() :
usedVariables);
- }
-
- /**
- * @param usedVariables List of Seam Context Variables used in EL.
- */
- public void setUsedVariables(List<ISeamContextVariable> usedVariables) {
- this.usedVariables = usedVariables;
- }
-
- /**
- * @return Map of unpaired getters and setters (getters/setters without proper
setters/getters).
- * of all properties used in EL.
- * Key - name of property.
- * Value - MethodInfo of existed getter/setter.
- */
- public Map<String, TypeInfoCollector.MethodInfo> getUnpairedGettersOrSetters() {
- if (unpairedGettersOrSetters == null) {
- unpairedGettersOrSetters = new HashMap<String,
TypeInfoCollector.MethodInfo>();
- }
- return unpairedGettersOrSetters;
- }
-
- /**
- * Clear Map of unpaired getters and setters.
- */
- public void clearUnpairedGettersOrSetters() {
- getUnpairedGettersOrSetters().clear();
- }
- }
-
private static final String collectionAdditionForCollectionDataModel =
".iterator().next()";
private static final String collectionAdditionForMapDataModel =
".entrySet().iterator().next()";
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELOperandResolveStatus.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELOperandResolveStatus.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELOperandResolveStatus.java 2008-09-23
14:01:49 UTC (rev 10409)
@@ -0,0 +1,175 @@
+package org.jboss.tools.seam.internal.core.el;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.jboss.tools.common.model.util.TypeInfoCollector;
+import org.jboss.tools.seam.core.ISeamContextVariable;
+
+/**
+ * Status of EL resolving.
+ * @author Jeremy
+ */
+public class SeamELOperandResolveStatus {
+ private List<ELOperandToken> tokens;
+ public List<ISeamContextVariable> usedVariables;
+ Map<String, TypeInfoCollector.MethodInfo> unpairedGettersOrSetters;
+ Set<String> proposals;
+ private ELOperandToken lastResolvedToken;
+ private boolean isMapOrCollectionOrBundleAmoungTheTokens = false;
+ private TypeInfoCollector.MemberInfo memberOfResolvedOperand;
+
+ /**
+ * @return MemberInfo of last segment of EL operand. Null if El is not resolved.
+ */
+ public TypeInfoCollector.MemberInfo getMemberOfResolvedOperand() {
+ return memberOfResolvedOperand;
+ }
+
+ /**
+ * Sets MemberInfo for last segment of EL operand.
+ * @param lastResolvedMember
+ */
+ public void setMemberOfResolvedOperand(
+ TypeInfoCollector.MemberInfo lastResolvedMember) {
+ this.memberOfResolvedOperand = lastResolvedMember;
+ }
+
+ /**
+ * Constructor
+ * @param tokens Tokens of EL
+ */
+ public SeamELOperandResolveStatus(List<ELOperandToken> tokens) {
+ this.tokens = tokens;
+ }
+
+ /**
+ * @return true if EL contains any not parametrized Collection or ResourceBundle.
+ */
+ public boolean isMapOrCollectionOrBundleAmoungTheTokens() {
+ return this.isMapOrCollectionOrBundleAmoungTheTokens;
+ }
+
+ public void setMapOrCollectionOrBundleAmoungTheTokens() {
+ this.isMapOrCollectionOrBundleAmoungTheTokens = true;
+ }
+
+ /**
+ * @return true if EL is resolved.
+ */
+ public boolean isOK() {
+ return !getProposals().isEmpty() || isMapOrCollectionOrBundleAmoungTheTokens();
+ }
+
+ /**
+ * @return false if El is not resolved.
+ */
+ public boolean isError() {
+ return !isOK();
+ }
+
+ /**
+ * @return List of resolved tokens of EL. Includes separators "."
+ */
+ public List<ELOperandToken> getResolvedTokens() {
+ List<ELOperandToken> resolvedTokens = new ArrayList<ELOperandToken>();
+ int index = tokens.indexOf(lastResolvedToken); // index == -1 means that no tokens are
resolved
+ for (int i = 0; i < tokens.size() && i <= index; i++) {
+ resolvedTokens.add(tokens.get(i));
+ }
+ return resolvedTokens;
+ }
+
+ /**
+ * @return List of unresolved tokens of EL.
+ */
+ public List<ELOperandToken> getUnresolvedTokens() {
+ List<ELOperandToken> unresolvedTokens = new ArrayList<ELOperandToken>();
+ int index = tokens.indexOf(lastResolvedToken); // index == -1 means that no tokens are
resolved
+ for (int i = index + 1; i < tokens.size(); i++) {
+ unresolvedTokens.add(tokens.get(i));
+ }
+ return unresolvedTokens;
+ }
+
+ /**
+ * @return Last resolved token of EL. Can be separator "."
+ */
+ public ELOperandToken getLastResolvedToken() {
+ return lastResolvedToken;
+ }
+
+ /**
+ * @param lastResolvedToken Last resolved token of EL. Can be separator "."
+ */
+ public void setLastResolvedToken(ELOperandToken lastResolvedToken) {
+ this.lastResolvedToken = lastResolvedToken;
+ }
+
+ /**
+ * @return Tokens of EL.
+ */
+ public List<ELOperandToken> getTokens() {
+ return tokens;
+ }
+
+ /**
+ * @param tokens Tokens of EL.
+ */
+ public void setTokens(List<ELOperandToken> tokens) {
+ this.tokens = tokens;
+ }
+
+ /**
+ * @return Set of proposals for EL.
+ */
+ public Set<String> getProposals() {
+ return proposals == null ? new TreeSet<String>() : proposals;
+ }
+
+ /**
+ * @param proposals Set of proposals.
+ */
+ public void setProposals(Set<String> proposals) {
+ this.proposals = proposals;
+ }
+
+ /**
+ * @return List of Seam Context Variables used in EL.
+ */
+ public List<ISeamContextVariable> getUsedVariables() {
+ return (usedVariables == null ? new ArrayList<ISeamContextVariable>() :
usedVariables);
+ }
+
+ /**
+ * @param usedVariables List of Seam Context Variables used in EL.
+ */
+ public void setUsedVariables(List<ISeamContextVariable> usedVariables) {
+ this.usedVariables = usedVariables;
+ }
+
+ /**
+ * @return Map of unpaired getters and setters (getters/setters without proper
setters/getters).
+ * of all properties used in EL.
+ * Key - name of property.
+ * Value - MethodInfo of existed getter/setter.
+ */
+ public Map<String, TypeInfoCollector.MethodInfo> getUnpairedGettersOrSetters() {
+ if (unpairedGettersOrSetters == null) {
+ unpairedGettersOrSetters = new HashMap<String, TypeInfoCollector.MethodInfo>();
+ }
+ return unpairedGettersOrSetters;
+ }
+
+ /**
+ * Clear Map of unpaired getters and setters.
+ */
+ public void clearUnpairedGettersOrSetters() {
+ getUnpairedGettersOrSetters().clear();
+ }
+
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/Var.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/Var.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/Var.java 2008-09-23
14:01:49 UTC (rev 10409)
@@ -0,0 +1,142 @@
+package org.jboss.tools.seam.internal.core.el;
+
+import java.util.List;
+
+/**
+ * Represents "var"/"value" attributes.
+ * @author Alexey Kazakov
+ */
+public class Var {
+ String name;
+ String value;
+ ELToken elToken;
+ String resolvedValue;
+ ELToken resolvedElToken;
+ int declOffset;
+ int declLength;
+
+ /**
+ * Constructor
+ * @param name - value of "var" attribute.
+ * @param value - value of "value" attribute.
+ */
+ public Var(String name, String value, int declOffset, int declLength) {
+ super();
+ this.name = name;
+ this.value = value;
+ elToken = parseEl(value);
+ this.declOffset = declOffset;
+ this.declLength = declLength;
+ }
+
+ /**
+ * Constructor
+ * @param name - value of "var" attribute.
+ * @param value - value of "value" attribute.
+ */
+ public Var(String name, String value) {
+ this(name, value, 0, 0);
+ }
+
+ ELToken parseEl(String el) {
+ if(el.length()>3 && el.startsWith("#{") &&
el.endsWith("}")) {
+ String elBody = el.substring(0, el.length()-1).substring(2);
+ SeamELTokenizer elTokenizer = new SeamELTokenizer(elBody);
+ List<ELToken> tokens = elTokenizer.getTokens();
+ for (ELToken token : tokens) {
+ if(token.getType()==ELToken.EL_VARIABLE_TOKEN) {
+ return token;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Sets value to new resolved EL which we got as result of parsing value.
+ * For example:
+ * <h:datatable value="#{list}" var="item">
+ * <h:dataTable value="#{item.anotherList}" var="innerItem">
+ * ...
+ * </h:dataTable>
+ * </h:dataTable>
+ * Original El is #{item.anotherList}
+ * Resolved El is #{list.iterator().next().anotherList}
+ * It's very useful for nested vars.
+ * @param newEl
+ */
+ public void resolveValue(String newEl) {
+ resolvedValue = newEl;
+ resolvedElToken = parseEl(newEl);
+ }
+
+ /**
+ * @return parsed EL from "value" attribute. Returns null if EL is not valid.
+ */
+ public ELToken getElToken() {
+ return elToken;
+ }
+
+ /**
+ * @return parsed resolved EL from "value" attribute. May be null.
+ */
+ public ELToken getResolvedElToken() {
+ return resolvedElToken;
+ }
+
+ /**
+ * @return name of variable.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return value of variable. It's EL.
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * @return resolved value of variable. It's EL. May be null.
+ */
+ public String getResolvedValue() {
+ return resolvedValue;
+ }
+
+ /**
+ * @return offset of the var declaration
+ */
+ public int getDeclarationOffset() {
+ return declOffset;
+ }
+
+ /**
+ * @return length of the var declaration
+ */
+ public int getDeclarationLength() {
+ return declLength;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof Var) {
+ Var compare = (Var)obj;
+ String str = getName();
+ if (str != null) {
+ if (!str.equals(compare.getName()))
+ return false;
+ } else {
+ if (compare.getName() != null)
+ return false;
+ }
+ str = getValue();
+ return (str != null ?
+ str.equals(compare.getValue()) :
+ compare.getValue() == null);
+ }
+ return false;
+ }
+
+}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java 2008-09-23
14:00:46 UTC (rev 10408)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java 2008-09-23
14:01:49 UTC (rev 10409)
@@ -53,9 +53,10 @@
import org.jboss.tools.seam.internal.core.el.ELToken;
import org.jboss.tools.seam.internal.core.el.ElVarSearcher;
import org.jboss.tools.seam.internal.core.el.SeamELCompletionEngine;
+import org.jboss.tools.seam.internal.core.el.SeamELOperandResolveStatus;
import org.jboss.tools.seam.internal.core.el.SeamELStringTokenizer;
import org.jboss.tools.seam.internal.core.el.SeamELTokenizer;
-import org.jboss.tools.seam.internal.core.el.ElVarSearcher.Var;
+import org.jboss.tools.seam.internal.core.el.Var;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -289,7 +290,7 @@
position = 0;
}
- SeamELCompletionEngine.SeamELOperandResolveStatus status =
+ SeamELOperandResolveStatus status =
engine.resolveSeamELOperand(project, file, operand, prefix, position, true,
varListForCurentValidatedNode, elVarSearcher);
if(status.getUsedVariables().size()==0 && status.isError()) {