Author: vrubezhny
Date: 2007-11-05 14:56:48 -0500 (Mon, 05 Nov 2007)
New Revision: 4720
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/SeamExpressionResolver.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/TypeInfoCollector.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1256 EL autcompletion and validation should be
aware of ELResolvers
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 2007-11-05
19:33:29 UTC (rev 4719)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2007-11-05
19:56:48 UTC (rev 4720)
@@ -282,14 +282,24 @@
Map<String, TypeInfoCollector.MethodInfo> unpairedGettersOrSetters;
Set<String> proposals;
private ELOperandToken lastResolvedToken;
+ private boolean isMapOrBundleAmoungTheTokens;
public SeamELOperandResolveStatus(List<ELOperandToken> tokens) {
this.tokens = tokens;
this.lastResolvedToken = null;
+ this.isMapOrBundleAmoungTheTokens = false;
}
+ public boolean isMapOrBundleAmoungTheTokens() {
+ return this.isMapOrBundleAmoungTheTokens;
+ }
+
+ public void setMapOrBundleAmoungTheTokens() {
+ this.isMapOrBundleAmoungTheTokens = true;
+ }
+
public boolean isOK() {
- return !getProposals().isEmpty();
+ return !getProposals().isEmpty() || isMapOrBundleAmoungTheTokens();
}
public boolean isError() {
@@ -455,6 +465,9 @@
for (TypeInfoCollector.MemberInfo mbr : members) {
TypeInfoCollector infos =
SeamExpressionResolver.collectTypeInfo(mbr.getMemberType());
List<TypeInfoCollector.MemberInfo> properties = infos.getProperties();
+ if (TypeInfoCollector.isMap(mbr.getMemberType()) ||
TypeInfoCollector.isResourceBundle(mbr.getMemberType())) {
+ status.setMapOrBundleAmoungTheTokens();
+ }
for (TypeInfoCollector.MemberInfo property : properties) {
StringBuffer propertyName = new StringBuffer(property.getName());
if (property instanceof TypeInfoCollector.MethodInfo) { // Setter or getter
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java 2007-11-05
19:33:29 UTC (rev 4719)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java 2007-11-05
19:56:48 UTC (rev 4720)
@@ -202,6 +202,8 @@
}
public static TypeInfoCollector collectTypeInfo(IType type) {
+ if (type == null)
+ System.out.println("type is null");
TypeInfoCollector typeInfo = new TypeInfoCollector(type);
typeInfo.collectInfo();
return typeInfo;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/TypeInfoCollector.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/TypeInfoCollector.java 2007-11-05
19:33:29 UTC (rev 4719)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/TypeInfoCollector.java 2007-11-05
19:56:48 UTC (rev 4720)
@@ -431,6 +431,10 @@
this.fType = type;
}
+ public IType getType() {
+ return this.fType;
+ }
+
public void collectInfo() {
if (fMethods == null) {
fMethods = new ArrayList<MethodInfo>();
@@ -475,12 +479,33 @@
}
boolean isDataModelObject(IType type) throws JavaModelException {
- boolean isDataModelObject =
"javax.faces.model.DataModel".equals(type.getFullyQualifiedName());
- if (!isDataModelObject) {
+ return isInstanceofType(type, "javax.faces.model.DataModel");
+ }
+
+ public static boolean isResourceBundle(IType type) {
+ try {
+ return isInstanceofType(type, "java.util.ResourceBundle");
+ } catch (JavaModelException e) {
+ return false;
+ }
+ }
+
+ public static boolean isMap(IType type) {
+ try {
+ return isInstanceofType(type, "java.util.Map");
+ } catch (JavaModelException e) {
+ return false;
+ }
+ }
+
+ public static boolean isInstanceofType(IType type, String qualifiedTypeName) throws
JavaModelException {
+ if (qualifiedTypeName == null || type == null) return false;
+ boolean isInstanceofType = qualifiedTypeName.equals(type.getFullyQualifiedName());
+ if (!isInstanceofType) {
ITypeHierarchy typeHierarchy = type.newSupertypeHierarchy(new NullProgressMonitor());
- IType[] superTypes = typeHierarchy == null ? null :
typeHierarchy.getSupertypes(fType);
- for (int i = 0; !isDataModelObject && superTypes != null && i <
superTypes.length; i++) {
- if ("javax.faces.model.DataModel".equals(superTypes[i])) {
+ IType[] superTypes = typeHierarchy == null ? null :
typeHierarchy.getSupertypes(type);
+ for (int i = 0; !isInstanceofType && superTypes != null && i <
superTypes.length; i++) {
+ if (qualifiedTypeName.equals(superTypes[i])) {
return true;
}
}