Author: akazakov
Date: 2008-10-27 15:40:44 -0400 (Mon, 27 Oct 2008)
New Revision: 11223
Modified:
branches/jbosstools-3.0.0.Beta1/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ElVarSearcher.java
branches/jbosstools-3.0.0.Beta1/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java
branches/jbosstools-3.0.0.Beta1/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/varAttributes.xhtml
branches/jbosstools-3.0.0.Beta1/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/entity/TestComponentForVarAttributes.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2914 Fixed
Modified:
branches/jbosstools-3.0.0.Beta1/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ElVarSearcher.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ElVarSearcher.java 2008-10-27
19:25:42 UTC (rev 11222)
+++
branches/jbosstools-3.0.0.Beta1/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ElVarSearcher.java 2008-10-27
19:40:44 UTC (rev 11223)
@@ -171,7 +171,8 @@
*/
public List<Var> findAllVars(Node node) {
ArrayList<Var> vars = null;
- Node parentNode = node.getParentNode();
+// Node parentNode = node.getParentNode();
+ Node parentNode = node;
while(parentNode!=null) {
Var var = findVar(parentNode);
if(var!=null) {
@@ -248,7 +249,7 @@
ELExpression token = var.getElToken();
if(token!=null && !token.getText().endsWith(".")) {
String varName = var.getName();
- if(el.startsWith(varName)) { //TODO it was el.equals(varName) and did not work.
Why?
+ if(el.equals(varName) || el.startsWith(varName.trim()+".")) {
if(var.getElToken()!=null && initializeNestedVars) {
Var parentVar = findVarForEl(var.getElToken().getText(), parentVars, true);
if(parentVar!=null) {
Modified:
branches/jbosstools-3.0.0.Beta1/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java 2008-10-27
19:25:42 UTC (rev 11222)
+++
branches/jbosstools-3.0.0.Beta1/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java 2008-10-27
19:40:44 UTC (rev 11223)
@@ -322,15 +322,19 @@
return isDataModel;
}
- protected void setDataModel(boolean isDataModel) {
+ public void setDataModel(boolean isDataModel) {
this.isDataModel = isDataModel;
}
public TypeInfoCollector getTypeCollector() {
+ return getTypeCollector(false);
+ }
+
+ public TypeInfoCollector getTypeCollector(boolean varIsUsed) {
// The rev. 7651 results in a deadlock, typeInfo is not stored anymore
// The rev. 7623 results in a deadlock, so, it's rolled back
// >>> Fix for JBIDE-2090
- return new TypeInfoCollector(this);
+ return new TypeInfoCollector(this, varIsUsed);
// <<< Fix for JBIDE-2090
}
@@ -682,9 +686,13 @@
}
public TypeInfoCollector(MemberInfo member) {
+ this(member, false);
+ }
+
+ public TypeInfoCollector(MemberInfo member, boolean varIsUsed) {
this.fMember = member;
this.fType = member.getMemberType();
- collectInfo();
+ collectInfo(varIsUsed);
}
public IType getType() {
@@ -692,6 +700,10 @@
}
public void collectInfo() {
+ collectInfo(false);
+ }
+
+ public void collectInfo(boolean var) {
if (fMethods == null) {
fMethods = new ArrayList<MethodInfo>();
} else {
@@ -722,7 +734,12 @@
if (binMethods[i].isConstructor()) {
continue;
}
- fMethods.add(new MethodInfo(binMethods[i], fTypeInfo, parent, false));
+ MethodInfo info = new MethodInfo(binMethods[i], fTypeInfo, parent, false);
+ if(info.getType().isArray() && var) {
+ info.setDataModel(true);
+ }
+ fMethods.add(info);
+
}
binType = getSuperclass(binType);
if(binType!=null) {
Modified:
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2008-10-27
19:25:42 UTC (rev 11222)
+++
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2008-10-27
19:40:44 UTC (rev 11223)
@@ -132,30 +132,39 @@
Var var = varSearcher.findVarForEl(oldEl, vars, true);
String suffix = "";
String newEl = oldEl;
+ TypeInfoCollector.MemberInfo member = null;
+ boolean isArray = false;
if(var!=null) {
- TypeInfoCollector.MemberInfo member = resolveSeamEL(file, var.getElToken());
- if(member!=null && !member.getType().isArray()) {
- IType type = member.getMemberType();
- if(type!=null) {
- try {
- if(TypeInfoCollector.isInstanceofType(type, "java.util.Map")) {
- suffix = collectionAdditionForMapDataModel;
- } else {
- suffix = collectionAdditionForCollectionDataModel;
+ member = resolveSeamEL(file, var.getElToken());
+ if(member!=null) {
+ if(!member.getType().isArray()) {
+ IType type = member.getMemberType();
+ if(type!=null) {
+ try {
+ if(TypeInfoCollector.isInstanceofType(type, "java.util.Map")) {
+ suffix = collectionAdditionForMapDataModel;
+ } else {
+ suffix = collectionAdditionForCollectionDataModel;
+ }
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
}
- } catch (JavaModelException e) {
- SeamCorePlugin.getPluginLog().logError(e);
}
+ } else {
+ isArray = true;
}
}
if(var.getElToken() != null) {
newEl = var.getElToken().getText() + suffix +
oldEl.substring(var.getName().length());
}
}
- boolean prefixWasChanged = newEl != oldEl;
+ boolean prefixWasChanged = !oldEl.equals(newEl);
+ if(prefixWasChanged && isArray) {
+ member.setDataModel(true);
+ }
ELExpression newOperand = (prefixWasChanged) ? parseOperand(newEl) : operand;
- SeamELOperandResolveStatus status = resolveELOperand(file, newOperand,
returnEqualedVariablesOnly);
+ SeamELOperandResolveStatus status = resolveELOperand(file, newOperand,
returnEqualedVariablesOnly, prefixWasChanged);
if(prefixWasChanged) {
ELInvocationExpression newLastResolvedToken = status.getLastResolvedToken();
@@ -211,7 +220,7 @@
*/
public TypeInfoCollector.MemberInfo resolveSeamEL(IFile file, ELExpression operand)
throws BadLocationException, StringIndexOutOfBoundsException {
if(!(operand instanceof ELInvocationExpression)) return null;
- ELOperandResolveStatus status = resolveELOperand(file, operand, true);
+ ELOperandResolveStatus status = resolveELOperand(file, operand, true, false);
return status.getMemberOfResolvedOperand();
}
@@ -272,7 +281,7 @@
}
public SeamELOperandResolveStatus resolveELOperand(IFile file, ELExpression operand,
- boolean returnEqualedVariablesOnly) throws BadLocationException,
StringIndexOutOfBoundsException {
+ boolean returnEqualedVariablesOnly, boolean varIsUsed) throws BadLocationException,
StringIndexOutOfBoundsException {
if(!(operand instanceof ELInvocationExpression)) {
return new SeamELOperandResolveStatus(null);
}
@@ -357,9 +366,9 @@
if(left != null) while(left != expr) {
left = (ELInvocationExpression)left.getParent();
if (left != expr) { // inside expression
- members = resolveSegment(left, members, status, returnEqualedVariablesOnly);
+ members = resolveSegment(left, members, status, returnEqualedVariablesOnly,
varIsUsed);
} else { // Last segment
- resolveLastSegment((ELInvocationExpression)operand, members, status,
returnEqualedVariablesOnly);
+ resolveLastSegment((ELInvocationExpression)operand, members, status,
returnEqualedVariablesOnly, varIsUsed);
break;
}
}
@@ -373,7 +382,7 @@
private List<TypeInfoCollector.MemberInfo> resolveSegment(ELInvocationExpression
expr,
List<TypeInfoCollector.MemberInfo> members,
ELOperandResolveStatus status,
- boolean returnEqualedVariablesOnly) {
+ boolean returnEqualedVariablesOnly, boolean varIsUsed) {
LexicalToken lt = (expr instanceof ELPropertyInvocation)
? ((ELPropertyInvocation)expr).getName()
: (expr instanceof ELMethodInvocation)
@@ -385,7 +394,7 @@
List<TypeInfoCollector.MemberInfo> newMembers = new
ArrayList<TypeInfoCollector.MemberInfo>();
for (TypeInfoCollector.MemberInfo mbr : members) {
if (mbr.getMemberType() == null) continue;
- TypeInfoCollector infos = mbr.getTypeCollector();
+ TypeInfoCollector infos = mbr.getTypeCollector(varIsUsed);
if (TypeInfoCollector.isNotParameterizedCollection(mbr) ||
TypeInfoCollector.isResourceBundle(mbr.getMemberType())) {
status.setMapOrCollectionOrBundleAmoungTheTokens();
}
@@ -434,7 +443,7 @@
private void resolveLastSegment(ELInvocationExpression expr,
List<TypeInfoCollector.MemberInfo> members,
ELOperandResolveStatus status,
- boolean returnEqualedVariablesOnly) {
+ boolean returnEqualedVariablesOnly, boolean varIsUsed) {
Set<String> proposals = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
if (expr.getType() == ELObjectType.EL_PROPERTY_INVOCATION &&
((ELPropertyInvocation)expr).getName() == null) {
// return all the methods + properties
@@ -459,7 +468,7 @@
if (mbr.getMemberType() == null) {
continue;
}
- TypeInfoCollector infos = mbr.getTypeCollector();
+ TypeInfoCollector infos = mbr.getTypeCollector(varIsUsed);
if (TypeInfoCollector.isNotParameterizedCollection(mbr) ||
TypeInfoCollector.isResourceBundle(mbr.getMemberType())) {
status.setMapOrCollectionOrBundleAmoungTheTokens();
}
Modified:
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java 2008-10-27
19:25:42 UTC (rev 11222)
+++
branches/jbosstools-3.0.0.Beta1/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java 2008-10-27
19:40:44 UTC (rev 11223)
@@ -214,26 +214,26 @@
private void validateChildNodes(IFile file, Node parent) {
String preferenceValue = SeamPreferences.getProjectPreference(project,
SeamPreferences.CHECK_VARS);
- Var var = null;
- if (SeamPreferences.ENABLE.equals(preferenceValue)) {
- var = elVarSearcher.findVar(parent);
- }
- if(var!=null) {
- varListForCurentValidatedNode.add(var);
- }
NodeList children = parent.getChildNodes();
for(int i=0; i<children.getLength() && !reporter.isCancelled(); i++) {
Node curentValidatedNode = children.item(i);
+ Var var = null;
if(Node.ELEMENT_NODE == curentValidatedNode.getNodeType()) {
+ if (SeamPreferences.ENABLE.equals(preferenceValue)) {
+ var = elVarSearcher.findVar(curentValidatedNode);
+ }
+ if(var!=null) {
+ varListForCurentValidatedNode.add(var);
+ }
validateNodeContent(file,
((IDOMNode)curentValidatedNode).getFirstStructuredDocumentRegion(),
DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE);
} else if(Node.TEXT_NODE == curentValidatedNode.getNodeType()) {
validateNodeContent(file,
((IDOMNode)curentValidatedNode).getFirstStructuredDocumentRegion(),
DOMRegionContext.XML_CONTENT);
}
validateChildNodes(file, curentValidatedNode);
+ if(var!=null) {
+ varListForCurentValidatedNode.remove(var);
+ }
}
- if(var!=null) {
- varListForCurentValidatedNode.remove(var);
- }
}
private void validateNodeContent(IFile file, IStructuredDocumentRegion node, String
regionType) {
@@ -299,51 +299,48 @@
try {
int offset = operand.length();
if (!operand.endsWith(".")) { //$NON-NLS-1$
- {
- SeamELOperandResolveStatus status =
- engine.resolveELOperand(file, operandToken, true, varListForCurentValidatedNode,
elVarSearcher);
+ SeamELOperandResolveStatus status =
+ engine.resolveELOperand(file, operandToken, true, varListForCurentValidatedNode,
elVarSearcher);
- if(status.getUsedVariables().size()==0 && status.isError()) {
- // Save resources with unknown variables names
- validationContext.addUnnamedElResource(file.getFullPath());
- } else {
- // Save links between resource and used variables names
- for(ISeamContextVariable variable: status.getUsedVariables()) {
- validationContext.addLinkedElResource(variable.getName(), file.getFullPath());
- }
+ if(status.getUsedVariables().size()==0 && status.isError()) {
+ // Save resources with unknown variables names
+ validationContext.addUnnamedElResource(file.getFullPath());
+ } else {
+ // Save links between resource and used variables names
+ for(ISeamContextVariable variable: status.getUsedVariables()) {
+ validationContext.addLinkedElResource(variable.getName(), file.getFullPath());
}
+ }
- // Check pair for getter/setter
- if(status.getUnpairedGettersOrSetters().size()>0) {
- TypeInfoCollector.MethodInfo unpairedMethod =
status.getUnpairedGettersOrSetters().values().iterator().next();
- String methodName = unpairedMethod.getName();
- String propertyName =
status.getUnpairedGettersOrSetters().keySet().iterator().next();
- String missingMethodName = SeamCoreMessages.SEAM_EL_VALIDATOR_SETTER;
- String existedMethodName = SeamCoreMessages.SEAM_EL_VALIDATOR_GETTER;
- if(methodName.startsWith("s")) { //$NON-NLS-1$
- missingMethodName = existedMethodName;
- existedMethodName = SeamCoreMessages.SEAM_EL_VALIDATOR_SETTER;
- }
- addError(UNPAIRED_GETTER_OR_SETTER_MESSAGE_ID,
SeamPreferences.UNPAIRED_GETTER_OR_SETTER, new String[]{propertyName, existedMethodName,
missingMethodName}, operand.length(), documnetOffset, file);
+ // Check pair for getter/setter
+ if(status.getUnpairedGettersOrSetters().size()>0) {
+ TypeInfoCollector.MethodInfo unpairedMethod =
status.getUnpairedGettersOrSetters().values().iterator().next();
+ String methodName = unpairedMethod.getName();
+ String propertyName =
status.getUnpairedGettersOrSetters().keySet().iterator().next();
+ String missingMethodName = SeamCoreMessages.SEAM_EL_VALIDATOR_SETTER;
+ String existedMethodName = SeamCoreMessages.SEAM_EL_VALIDATOR_GETTER;
+ if(methodName.startsWith("s")) { //$NON-NLS-1$
+ missingMethodName = existedMethodName;
+ existedMethodName = SeamCoreMessages.SEAM_EL_VALIDATOR_SETTER;
}
+ addError(UNPAIRED_GETTER_OR_SETTER_MESSAGE_ID,
SeamPreferences.UNPAIRED_GETTER_OR_SETTER, new String[]{propertyName, existedMethodName,
missingMethodName}, operand.length(), documnetOffset, file);
+ }
- if (status.isOK()) {
- // It's valid EL.
- return;
- }
-
- ELInvocationExpression ts = status.getUnresolvedTokens();
-
- varName = ts.getMemberName();
- if(varName == null) {
- //This is syntax error case. Reported by parser.
- return;
- }
- offsetOfVarName = documnetOffset + ts.getInvocationStartPosition();
- lengthOfVarName = varName == null ? 0 : varName.length();
- unresolvedTokenIsVariable = true;
-
+ if (status.isOK()) {
+ // It's valid EL.
+ return;
}
+
+ ELInvocationExpression ts = status.getUnresolvedTokens();
+
+ varName = ts.getMemberName();
+ if(varName == null) {
+ //This is syntax error case. Reported by parser.
+ return;
+ }
+ offsetOfVarName = documnetOffset + ts.getInvocationStartPosition();
+ lengthOfVarName = varName == null ? 0 : varName.length();
+ unresolvedTokenIsVariable = true;
}
} catch (BadLocationException e) {
SeamCorePlugin.getDefault().logError(SeamCoreMessages.SEAM_EL_VALIDATOR_ERROR_VALIDATING_SEAM_EL,
e);
Modified:
branches/jbosstools-3.0.0.Beta1/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/varAttributes.xhtml
===================================================================
---
branches/jbosstools-3.0.0.Beta1/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/varAttributes.xhtml 2008-10-27
19:25:42 UTC (rev 11222)
+++
branches/jbosstools-3.0.0.Beta1/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/varAttributes.xhtml 2008-10-27
19:40:44 UTC (rev 11223)
@@ -26,6 +26,18 @@
<h:dataTable value="#{testComponentForVars.list}"
var="item">
<h:outputText value="#{item.name}"/>
</h:dataTable>
+
+ <h:dataTable value="#{tipos}" var="itemNew"
label="#{itemNew}">
+ <h:outputText value="#{itemNew.name}"/>
+ </h:dataTable>
+
+ <h:dataTable value="#{tiposs}" var="secondItem">
+ <h:outputText value="#{secondItem.name}"/>
+ </h:dataTable>
+
+ <h:dataTable value="#{testComponentForVars.array}"
var="thrItem">
+ <h:outputText value="#{thrItem.name}"/>
+ </h:dataTable>
</h:dataTable>
</ui:define>
Modified:
branches/jbosstools-3.0.0.Beta1/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/entity/TestComponentForVarAttributes.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/entity/TestComponentForVarAttributes.java 2008-10-27
19:25:42 UTC (rev 11222)
+++
branches/jbosstools-3.0.0.Beta1/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/entity/TestComponentForVarAttributes.java 2008-10-27
19:40:44 UTC (rev 11223)
@@ -30,6 +30,20 @@
return null;
}
+ @Factory("tipos")
+ public Value[] initTipos() {
+ return null;
+ }
+
+ public Value[] getArray() {
+ return null;
+ }
+
+ @Factory("tiposs")
+ public List<Value> initTiposNew() {
+ return null;
+ }
+
public static class Value {
public String getName() {
return null;