Author: akazakov
Date: 2008-10-27 15:25:42 -0400 (Mon, 27 Oct 2008)
New Revision: 11222
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ElVarSearcher.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/varAttributes.xhtml
trunk/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:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ElVarSearcher.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ElVarSearcher.java 2008-10-27
19:22:37 UTC (rev 11221)
+++
trunk/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)
@@ -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:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/TypeInfoCollector.java 2008-10-27
19:22:37 UTC (rev 11221)
+++
trunk/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)
@@ -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:
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-10-27
19:22:37 UTC (rev 11221)
+++
trunk/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)
@@ -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:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/varAttributes.xhtml
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/varAttributes.xhtml 2008-10-27
19:22:37 UTC (rev 11221)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/varAttributes.xhtml 2008-10-27
19:25:42 UTC (rev 11222)
@@ -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:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/entity/TestComponentForVarAttributes.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/entity/TestComponentForVarAttributes.java 2008-10-27
19:22:37 UTC (rev 11221)
+++
trunk/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)
@@ -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;