Author: vrubezhny
Date: 2007-11-01 15:57:36 -0400 (Thu, 01 Nov 2007)
New Revision: 4648
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/TypeInfoCollector.java
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/validation/SeamELValidator.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-1187 Properties from superclass of a library class
not recognized by autocomplete, validator or F3
The Content Assistant recognizes the parameterized types now
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-01
19:50:18 UTC (rev 4647)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2007-11-01
19:57:36 UTC (rev 4648)
@@ -91,7 +91,7 @@
* Result is {'1','2'}
*/
public List<String> getCompletions(ISeamProject project, IFile file, String
documentContent, CharSequence prefix,
- int position, boolean returnEqualedVariablesOnly, Set<ISeamContextVariable>
usedVariables, Map<String, IMethod> unpairedGettersOrSetters) throws
BadLocationException, StringIndexOutOfBoundsException {
+ int position, boolean returnEqualedVariablesOnly, Set<ISeamContextVariable>
usedVariables, Map<String, TypeInfoCollector.MethodInfo> unpairedGettersOrSetters)
throws BadLocationException, StringIndexOutOfBoundsException {
List<String> res= new ArrayList<String>();
SeamELOperandTokenizer tokenizer = new SeamELOperandTokenizer(documentContent, position
+ prefix.length());
@@ -157,9 +157,9 @@
// First segment is found - proceed with next tokens
int startTokenIndex = (resolvedExpressionPart == null ? 0 :
resolvedExpressionPart.size());
- Set<IMember> members = new HashSet<IMember>();
+ List<TypeInfoCollector.MemberInfo> members = new
ArrayList<TypeInfoCollector.MemberInfo>();
for (ISeamContextVariable var : resolvedVariables) {
- IMember member = SeamExpressionResolver.getMemberByVariable(var,
returnEqualedVariablesOnly);
+ TypeInfoCollector.MemberInfo member =
SeamExpressionResolver.getMemberInfoByVariable(var, returnEqualedVariablesOnly);
if (member != null && !members.contains(member))
members.add(member);
}
@@ -173,27 +173,23 @@
if (token.getType() == ELOperandToken.EL_SEPARATOR_TOKEN)
// proceed with next token
continue;
-
+
if (token.getType() == ELOperandToken.EL_NAME_TOKEN) {
// Find properties for the token
String name = token.getText();
- Set<IMember> newMembers = new HashSet<IMember>();
- for (IMember mbr : members) {
- try {
- IType type = (mbr instanceof IType ? (IType)mbr :
EclipseJavaUtil.findType(mbr.getJavaProject(),
EclipseJavaUtil.getMemberTypeAsString(mbr)));
- Set<IMember> properties = SeamExpressionResolver.getProperties(type);
- for (IMember property : properties) {
- StringBuffer propertyName = new StringBuffer(property.getElementName());
- if (property instanceof IMethod) { // Setter or getter
- propertyName.delete(0, 3);
- propertyName.setCharAt(0, Character.toLowerCase(propertyName.charAt(0)));
- }
- if (name.equals(propertyName.toString())) {
- newMembers.add(property);
- }
+ List<TypeInfoCollector.MemberInfo> newMembers = new
ArrayList<TypeInfoCollector.MemberInfo>();
+ for (TypeInfoCollector.MemberInfo mbr : members) {
+ TypeInfoCollector infos =
SeamExpressionResolver.collectTypeInfo(mbr.getMemberType());
+ List<TypeInfoCollector.MemberInfo> properties = infos.getProperties();
+ for (TypeInfoCollector.MemberInfo property : properties) {
+ StringBuffer propertyName = new StringBuffer(property.getName());
+ if (property instanceof TypeInfoCollector.MethodInfo) { // Setter or getter
+ propertyName.delete(0, (propertyName.charAt(0) == 'i' ? 2 : 3));
+ propertyName.setCharAt(0, Character.toLowerCase(propertyName.charAt(0)));
}
- } catch (JavaModelException ex) {
- SeamCorePlugin.getPluginLog().logError(ex);
+ if (name.equals(propertyName.toString())) {
+ newMembers.add(property);
+ }
}
}
members = newMembers;
@@ -204,18 +200,14 @@
if (name.indexOf('(') != -1) {
name = name.substring(0, name.indexOf('('));
}
- Set<IMember> newMembers = new HashSet<IMember>();
- for (IMember mbr : members) {
- try {
- IType type = (mbr instanceof IType ? (IType)mbr :
EclipseJavaUtil.findType(mbr.getJavaProject(),
EclipseJavaUtil.getMemberTypeAsString(mbr)));
- Set<IMember> methods = SeamExpressionResolver.getMethods(type);
- for (IMember method : methods) {
- if (name.equals(method.getElementName())) {
- newMembers.add(method);
- }
+ List<TypeInfoCollector.MemberInfo> newMembers = new
ArrayList<TypeInfoCollector.MemberInfo>();
+ for (TypeInfoCollector.MemberInfo mbr : members) {
+ TypeInfoCollector infos =
SeamExpressionResolver.collectTypeInfo(mbr.getMemberType());
+ List<TypeInfoCollector.MemberInfo> methods = infos.getMethods();
+ for (TypeInfoCollector.MemberInfo method : methods) {
+ if (name.equals(method.getName())) {
+ newMembers.add(method);
}
- } catch (JavaModelException ex) {
- SeamCorePlugin.getPluginLog().logError(ex);
}
}
members = newMembers;
@@ -224,32 +216,19 @@
Set<String> proposals = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
if (token.getType() == ELOperandToken.EL_SEPARATOR_TOKEN) {
// return all the methods + properties
- for (IMember mbr : members) {
- try {
- IType type = (mbr instanceof IType ? (IType)mbr :
EclipseJavaUtil.findType(mbr.getJavaProject(),
EclipseJavaUtil.getMemberTypeAsString(mbr)));
- proposals.addAll(SeamExpressionResolver.getMethodPresentations(type));
- proposals.addAll(SeamExpressionResolver.getPropertyPresentations(type,
unpairedGettersOrSetters));
- } catch (JavaModelException ex) {
- SeamCorePlugin.getPluginLog().logError(ex);
- }
+ for (TypeInfoCollector.MemberInfo mbr : members) {
+ TypeInfoCollector infos =
SeamExpressionResolver.collectTypeInfo(mbr.getMemberType());
+ proposals.addAll(infos.getMethodPresentations());
+ proposals.addAll(infos.getPropertyPresentations(unpairedGettersOrSetters));
}
} else if (token.getType() == ELOperandToken.EL_NAME_TOKEN ||
token.getType() == ELOperandToken.EL_METHOD_TOKEN) {
// return filtered methods + properties
Set<String> proposalsToFilter = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
- for (IMember mbr : members) {
- try {
- IType type = null;
- if(mbr instanceof IType) {
- type = (IType)mbr;
- } else {
- type = EclipseJavaUtil.findType(mbr.getJavaProject(),
EclipseJavaUtil.getMemberTypeAsString(mbr));
- }
- proposalsToFilter.addAll(SeamExpressionResolver.getMethodPresentations(type));
- proposalsToFilter.addAll(SeamExpressionResolver.getPropertyPresentations(type,
unpairedGettersOrSetters));
- } catch (JavaModelException ex) {
- SeamCorePlugin.getPluginLog().logError(ex);
- }
+ for (TypeInfoCollector.MemberInfo mbr : members) {
+ TypeInfoCollector infos =
SeamExpressionResolver.collectTypeInfo(mbr.getMemberType());
+ proposalsToFilter.addAll(infos.getMethodPresentations());
+ proposalsToFilter.addAll(infos.getPropertyPresentations(unpairedGettersOrSetters));
}
for (String proposal : proposalsToFilter) {
// We do expect nothing but name for method tokens (No round brackets)
@@ -259,7 +238,7 @@
if (proposal.equals(filter)) {
proposals.add(proposal);
if(unpairedGettersOrSetters!=null) {
- IMethod unpirMethod = unpairedGettersOrSetters.get(filter);
+ TypeInfoCollector.MethodInfo unpirMethod =
unpairedGettersOrSetters.get(filter);
unpairedGettersOrSetters.clear();
if(unpirMethod!=null) {
unpairedGettersOrSetters.put(filter, unpirMethod);
@@ -492,10 +471,9 @@
* @param prefix the prefix to search for
* @param position Offset of the prefix
*/
- public List<IJavaElement> getJavaElementsForExpression(ISeamProject project, IFile
file, String expression) throws BadLocationException, StringIndexOutOfBoundsException {
+ public List<IJavaElement> getJavaElementsForExpression(ISeamProject project, IFile
file, String expression) throws BadLocationException, StringIndexOutOfBoundsException {
List<IJavaElement> res= new ArrayList<IJavaElement>();
-
SeamELOperandTokenizer tokenizer = new SeamELOperandTokenizer(expression,
expression.length());
List<ELOperandToken> tokens = tokenizer.getTokens();
@@ -526,13 +504,12 @@
if (areEqualExpressions(resolvedExpressionPart, tokens)) {
// First segment is the last one
for (ISeamContextVariable var : resolvedVariables) {
-/* String varName = var.getName();
- if(expression.length()<varName.length()) {
- res.add(varName.substring(prefixString.length()));
- } else if(returnEqualedVariablesOnly) {
- res.add(varName);
- }
-*/
+// String varName = var.getName();
+// if(expression.length()<varName.length()) {
+// res.add(varName.substring(prefixString.length()));
+// } else if(returnEqualedVariablesOnly) {
+// res.add(varName);
+// }
IMember member = SeamExpressionResolver.getMemberByVariable(var, true);
if (member instanceof IJavaElement){
res.add((IJavaElement)member);
@@ -543,9 +520,9 @@
// First segment is found - proceed with next tokens
int startTokenIndex = (resolvedExpressionPart == null ? 0 :
resolvedExpressionPart.size());
- Set<IMember> members = new HashSet<IMember>();
+ List<TypeInfoCollector.MemberInfo> members = new
ArrayList<TypeInfoCollector.MemberInfo>();
for (ISeamContextVariable var : resolvedVariables) {
- IMember member = SeamExpressionResolver.getMemberByVariable(var, true);
+ TypeInfoCollector.MemberInfo member =
SeamExpressionResolver.getMemberInfoByVariable(var, true);
if (member != null && !members.contains(member))
members.add(member);
}
@@ -563,23 +540,19 @@
if (token.getType() == ELOperandToken.EL_NAME_TOKEN) {
// Find properties for the token
String name = token.getText();
- Set<IMember> newMembers = new HashSet<IMember>();
- for (IMember mbr : members) {
- try {
- IType type = (mbr instanceof IType ? (IType)mbr :
EclipseJavaUtil.findType(mbr.getJavaProject(),
EclipseJavaUtil.getMemberTypeAsString(mbr)));
- Set<IMember> properties = SeamExpressionResolver.getProperties(type);
- for (IMember property : properties) {
- StringBuffer propertyName = new StringBuffer(property.getElementName());
- if (property instanceof IMethod) { // Setter or getter
- propertyName.delete(0, 3);
- propertyName.setCharAt(0, Character.toLowerCase(propertyName.charAt(0)));
- }
- if (name.equals(propertyName.toString())) {
- newMembers.add(property);
- }
+ List<TypeInfoCollector.MemberInfo> newMembers = new
ArrayList<TypeInfoCollector.MemberInfo>();
+ for (TypeInfoCollector.MemberInfo mbr : members) {
+ TypeInfoCollector infos =
SeamExpressionResolver.collectTypeInfo(mbr.getMemberType());
+ List<TypeInfoCollector.MemberInfo> properties = infos.getProperties();
+ for (TypeInfoCollector.MemberInfo property : properties) {
+ StringBuffer propertyName = new StringBuffer(property.getName());
+ if (property instanceof TypeInfoCollector.MethodInfo) { // Setter or getter
+ propertyName.delete(0, 3);
+ propertyName.setCharAt(0, Character.toLowerCase(propertyName.charAt(0)));
}
- } catch (JavaModelException ex) {
- SeamCorePlugin.getPluginLog().logError(ex);
+ if (name.equals(propertyName.toString())) {
+ newMembers.add(property);
+ }
}
}
members = newMembers;
@@ -590,18 +563,15 @@
if (name.indexOf('(') != -1) {
name = name.substring(0, name.indexOf('('));
}
- Set<IMember> newMembers = new HashSet<IMember>();
- for (IMember mbr : members) {
- try {
- IType type = (mbr instanceof IType ? (IType)mbr :
EclipseJavaUtil.findType(mbr.getJavaProject(),
EclipseJavaUtil.getMemberTypeAsString(mbr)));
- Set<IMember> methods = SeamExpressionResolver.getMethods(type);
- for (IMember method : methods) {
- if (name.equals(method.getElementName())) {
- newMembers.add(method);
- }
+ List<TypeInfoCollector.MemberInfo> newMembers = new
ArrayList<TypeInfoCollector.MemberInfo>();
+ for (TypeInfoCollector.MemberInfo mbr : members) {
+ TypeInfoCollector infos =
SeamExpressionResolver.collectTypeInfo(mbr.getMemberType());
+ List<TypeInfoCollector.MemberInfo> methods = infos.getMethods();
+ for (TypeInfoCollector.MemberInfo method : methods) {
+ if (method instanceof TypeInfoCollector.MethodInfo
+ && name.equals(method.getName())) {
+ newMembers.add(method);
}
- } catch (JavaModelException ex) {
- SeamCorePlugin.getPluginLog().logError(ex);
}
}
members = newMembers;
@@ -611,36 +581,25 @@
if (token.getType() == ELOperandToken.EL_NAME_TOKEN ||
token.getType() == ELOperandToken.EL_METHOD_TOKEN) {
// return filtered methods + properties
- Set<IJavaElement> javaElementsToFilter = new HashSet<IJavaElement>();
- for (IMember mbr : members) {
- try {
- IType type = null;
- if(mbr instanceof IType) {
- type = (IType)mbr;
- } else {
- type = EclipseJavaUtil.findType(mbr.getJavaProject(),
EclipseJavaUtil.getMemberTypeAsString(mbr));
- }
- javaElementsToFilter.addAll(SeamExpressionResolver.getMethods(type));
- javaElementsToFilter.addAll(SeamExpressionResolver.getProperties(type));
- } catch (JavaModelException ex) {
- SeamCorePlugin.getPluginLog().logError(ex);
- }
+ Set<TypeInfoCollector.MemberInfo> javaElementInfosToFilter = new
HashSet<TypeInfoCollector.MemberInfo>();
+ for (TypeInfoCollector.MemberInfo mbr : members) {
+ TypeInfoCollector infos =
SeamExpressionResolver.collectTypeInfo(mbr.getMemberType());
+ javaElementInfosToFilter.addAll(infos.getMethods());
+ javaElementInfosToFilter.addAll(infos.getProperties());
}
- for (IJavaElement javaElement : javaElementsToFilter) {
+
+ for (TypeInfoCollector.MemberInfo info : javaElementInfosToFilter) {
// We do expect nothing but name for method tokens (No round brackets)
String filter = token.getText();
- String elementName = javaElement.getElementName();
// This is used for validation.
- if (javaElement.getElementName().equals(filter)) {
- javaElements.add(javaElement);
+ if (info.getName().equals(filter)) {
+ javaElements.add(info.getJavaElement());
} else {
- if (javaElement instanceof IMethod) {
- boolean getter = (elementName.startsWith("get") &&
!"get".equals(elementName)) || //$NON-NLS-1$ //$NON-NLS-2$
- (elementName.startsWith("is") &&
!"is".equals(elementName)); //$NON-NLS-1$ //$NON-NLS-2$
- boolean setter = elementName.startsWith("set") &&
!"set".equals(elementName); //$NON-NLS-1$ //$NON-NLS-2$
- if(getter || setter) {
- StringBuffer name = new StringBuffer(elementName);
- if(elementName.startsWith("i")) { //$NON-NLS-1$
+ if (info instanceof TypeInfoCollector.MethodInfo) {
+ TypeInfoCollector.MethodInfo methodInfo = (TypeInfoCollector.MethodInfo)info;
+ if(methodInfo.isGetter() || methodInfo.isSetter()) {
+ StringBuffer name = new StringBuffer(methodInfo.getName());
+ if(methodInfo.getName().startsWith("i")) { //$NON-NLS-1$
name.delete(0, 2);
} else {
name.delete(0, 3);
@@ -648,7 +607,7 @@
name.setCharAt(0, Character.toLowerCase(name.charAt(0)));
String propertyName = name.toString();
if (propertyName.equals(filter)) {
- javaElements.add(javaElement);
+ javaElements.add(methodInfo.getJavaElement());
}
}
}
@@ -661,4 +620,5 @@
return res;
}
+
}
\ No newline at end of file
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-01
19:50:18 UTC (rev 4647)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java 2007-11-01
19:57:36 UTC (rev 4648)
@@ -11,21 +11,12 @@
package org.jboss.tools.seam.internal.core.el;
-import java.lang.reflect.Modifier;
import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
-import java.util.TreeSet;
-import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.jboss.tools.common.model.util.EclipseJavaUtil;
import org.jboss.tools.seam.core.IBijectedAttribute;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamContextShortVariable;
@@ -36,7 +27,6 @@
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ISeamXmlFactory;
import org.jboss.tools.seam.core.ScopeType;
-import org.jboss.tools.seam.core.SeamCorePlugin;
/**
* Utility class used to resolve Seam project variables and to get the methods/properties
and their presentation strings from type
@@ -158,255 +148,63 @@
}
return member;
}
-
- /**
- * Returns the methods for the type specified
- *
- * @param type
- * @return
- */
- public static Set<IMember> getMethods(IType type) {
- Set<IMember> methods = new HashSet<IMember>();
- if (type != null) {
- try {
- IMethod[] mthds = getAllMethods(type);
- for (int i = 0; mthds != null && i < mthds.length; i++) {
- if (Modifier.isPublic(mthds[i].getFlags()) &&
- !mthds[i].isConstructor() &&
- (!mthds[i].getElementName().startsWith("get") &&
!mthds[i].getElementName().startsWith("set")) || //$NON-NLS-1$ //$NON-NLS-2$
- "get".equals(mthds[i].getElementName()) ||
"set".equals(mthds[i].getElementName())) { //$NON-NLS-1$ //$NON-NLS-2$
- methods.add(mthds[i]);
- }
- }
- } catch (JavaModelException e) {
- SeamCorePlugin.getDefault().logError(e);
- }
- }
- return methods;
- }
/**
- * Returns the method presentation strings for the type specified
+ * Returns the IMember for the variable specified
*
- * @param type
+ * @param variable
* @return
*/
- public static Set<String> getMethodPresentations(IType type) {
- Set<String> methods = new HashSet<String>();
- if (type != null) {
- try {
-// IMethod[] mthds = type.getMethods();
- IMethod[] mthds = getAllMethods(type);
- for (int i = 0; mthds != null && i < mthds.length; i++) {
- IMethod m = mthds[i];
- if (Modifier.isPublic(m.getFlags()) &&
- !m.isConstructor() &&
- (!m.getElementName().startsWith("get") &&
!m.getElementName().startsWith("set")) || //$NON-NLS-1$ //$NON-NLS-2$
- "get".equals(m.getElementName()) ||
"set".equals(m.getElementName())) { //$NON-NLS-1$ //$NON-NLS-2$
-
- StringBuffer name = new StringBuffer(m.getElementName());
-
- // Add method as 'foo'
- methods.add(name.toString());
-
- // Add method as 'foo(param1,param2)'
- name.append('(');
- String[] mParams = null;
- mParams = m.getParameterNames();
- for (int j = 0; mParams != null && j < mParams.length; j++) {
- if (j > 0) name.append(", "); //$NON-NLS-1$
- name.append(mParams[j]);
- }
- name.append(')');
-
- methods.add(name.toString());
- }
- }
- } catch (JavaModelException e) {
- SeamCorePlugin.getDefault().logError(e);
- }
+ public static TypeInfoCollector.MemberInfo getMemberInfoByVariable(ISeamContextVariable
variable, boolean onlyEqualNames) {
+ TypeInfoCollector.MemberInfo member = null;
+ if(variable instanceof ISeamContextShortVariable) {
+ return getMemberInfoByVariable(((ISeamContextShortVariable)variable).getOriginal(),
onlyEqualNames);
}
- return methods;
- }
-
- /**
- * @param type
- * @return methods of type and methods of all super classes
- */
- private static IMethod[] getAllMethods(IType type) {
- ArrayList<IMethod> result = new ArrayList<IMethod>();
- try {
- IMethod[] mthds = type.getMethods();
- for(int i=0; i<mthds.length; i++) {
- result.add(mthds[i]);
+ if (variable instanceof ISeamComponent) {
+ ISeamComponent component = (ISeamComponent)variable;
+ ISeamJavaComponentDeclaration decl = component.getJavaDeclaration();
+ if (decl != null) {
+ member = TypeInfoCollector.createMemberInfo(decl.getSourceMember());
}
- IType superType = getSuperclass(type);
- while(superType!=null) {
- mthds = superType.getMethods();
- for(int i=0; i<mthds.length; i++) {
- result.add(mthds[i]);
- }
- superType = getSuperclass(superType);
- }
- } catch (JavaModelException e) {
- SeamCorePlugin.getPluginLog().logError(e);
}
- return result.toArray(new IMethod[result.size()]);
- }
-
- /**
- * @param type
- * @return fields of type and fields of all super classes
- */
- private static IField[] getAllFields(IType type) {
- ArrayList<IField> result = new ArrayList<IField>();
- try {
- IField[] fields = type.getFields();
- for(int i=0; i<fields.length; i++) {
- result.add(fields[i]);
- }
- IType superType = getSuperclass(type);
- while(superType!=null) {
- fields = superType.getFields();
- for(int i=0; i<fields.length; i++) {
- result.add(fields[i]);
- }
- superType = getSuperclass(superType);
- }
- } catch (JavaModelException e) {
- SeamCorePlugin.getPluginLog().logError(e);
+ if (member == null && variable instanceof IBijectedAttribute) {
+ member =
TypeInfoCollector.createMemberInfo(((ISeamJavaSourceReference)variable).getSourceMember());
}
- return result.toArray(new IField[result.size()]);
- }
-
-
-
- private static IType getSuperclass(IType type) throws JavaModelException {
- String superclassName = type.getSuperclassName();
- if(superclassName!=null) {
- String fullySuperclassName = EclipseJavaUtil.resolveType(type, superclassName);
- if(fullySuperclassName!=null&&!fullySuperclassName.equals("java.lang.Object"))
{ //$NON-NLS-1$
- IType superType = type.getJavaProject().findType(fullySuperclassName);
- return superType;
- }
+ if (member == null && variable instanceof ISeamJavaSourceReference) {
+ member =
TypeInfoCollector.createMemberInfo(((ISeamJavaSourceReference)variable).getSourceMember());
}
- return null;
- }
-
- /**
- * Returns the properties for the type specified
- *
- * @param type
- * @return
- */
- public static Set<IMember> getProperties(IType type) {
- Set<IMember> properties = new HashSet<IMember>();
- if (type != null) {
- try {
- IMethod[] mthds = getAllMethods(type);
- for (int i = 0; mthds != null && i < mthds.length; i++) {
- if (Modifier.isPublic(mthds[i].getFlags()) &&
- (mthds[i].getElementName().startsWith("get") &&
!"get".equals(mthds[i].getElementName())) || //$NON-NLS-1$ //$NON-NLS-2$
- (mthds[i].getElementName().startsWith("set") &&
!"set".equals(mthds[i].getElementName()))) { //$NON-NLS-1$ //$NON-NLS-2$
- properties.add(mthds[i]);
- }
- }
- } catch (JavaModelException e) {
- SeamCorePlugin.getDefault().logError(e);
+ if (member == null && variable instanceof ISeamXmlFactory) {
+ ISeamXmlFactory factory = (ISeamXmlFactory)variable;
+ String value = factory.getValue();
+ if (value != null && value.length() > 0) {
+ if (value.startsWith("#{") || value.startsWith("${"))
//$NON-NLS-1$ //$NON-NLS-2$
+ value = value.substring(2);
+ if (value.endsWith("}")) //$NON-NLS-1$
+ value = value.substring(0, value.length() - 1);
}
-
- try {
- IField[] fields = getAllFields(type);
- for (int i = 0; fields != null && i < fields.length; i++) {
- IField f = fields[i];
- if (Modifier.isPublic(f.getFlags())) {
- properties.add(f);
+ if (value != null && value.length() > 0) {
+ // TODO: Need to make sure that it's correct way to get the project and
+ // the scope from the factory
+ ISeamProject project = ((ISeamElement)factory).getSeamProject();
+// ISeamProject project = getSeamProject(factory.getResource());
+ if (project != null) {
+ List<ISeamContextVariable> resolvedValues = resolveVariables(project, null /*
factory.getScope()*/, value, onlyEqualNames);
+ for (ISeamContextVariable var : resolvedValues) {
+ if (var.getName().equals(value)) {
+ member = getMemberInfoByVariable(var, onlyEqualNames);
+ break;
+ }
}
}
- } catch (JavaModelException e) {
- SeamCorePlugin.getDefault().logError(e);
}
}
- return properties;
+ return member;
}
- /**
- * Returns the property presentation strings for the type specified
- *
- * @param type
- * @return
- */
- public static Set<String> getPropertyPresentations(IType type) {
- return getPropertyPresentations(type, null);
+ public static TypeInfoCollector collectTypeInfo(IType type) {
+ TypeInfoCollector typeInfo = new TypeInfoCollector(type);
+ typeInfo.collectInfo();
+ return typeInfo;
}
- /**
- * Returns the property presentation strings for the type specified
- *
- * @param type
- * @param unpairedGettersOrSetters - map of unpaired getters or setters of type's
properties. 'key' is property name.
- * @return
- */
- public static Set<String> getPropertyPresentations(IType type, Map<String,
IMethod> unpairedGettersOrSetters) {
- Set<String> properties = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
- if (type != null) {
- try {
-// IMethod[] props = type.getMethods();
- IMethod[] props = getAllMethods(type);
- HashMap<String, IMethod> getters = new HashMap<String, IMethod>();
- HashMap<String, IMethod> setters = new HashMap<String, IMethod>();
- for (int i = 0; props != null && i < props.length; i++) {
- IMethod m = props[i];
- if (Modifier.isPublic(m.getFlags())) {
- String methodName = m.getElementName();
- boolean getter = (methodName.startsWith("get") &&
!"get".equals(methodName)) || //$NON-NLS-1$ //$NON-NLS-2$
- (methodName.startsWith("is") &&
!"is".equals(methodName)); //$NON-NLS-1$ //$NON-NLS-2$
- boolean setter = methodName.startsWith("set") &&
!"set".equals(methodName); //$NON-NLS-1$ //$NON-NLS-2$
- if(getter || setter) {
- StringBuffer name = new StringBuffer(methodName);
- if(methodName.startsWith("i")) { //$NON-NLS-1$
- name.delete(0, 2);
- } else {
- name.delete(0, 3);
- }
- name.setCharAt(0, Character.toLowerCase(name.charAt(0)));
- String propertyName = name.toString();
- if(!properties.contains(propertyName)) {
- properties.add(propertyName);
- }
- if(unpairedGettersOrSetters!=null) {
- IMethod previousGetter = getters.get(propertyName);
- IMethod previousSetter = setters.get(propertyName);
- if((previousGetter!=null && setter)||(previousSetter!=null &&
getter)) {
- // We have both Getter and Setter
- unpairedGettersOrSetters.remove(propertyName);
- } else if(setter) {
- setters.put(propertyName, m);
- unpairedGettersOrSetters.put(propertyName, m);
- } else if(getter) {
- getters.put(propertyName, m);
- unpairedGettersOrSetters.put(propertyName, m);
- }
- }
- }
- }
- }
- } catch (JavaModelException e) {
- SeamCorePlugin.getDefault().logError(e);
- }
-
- try {
- IField[] fields = type.getFields();
- for (int i = 0; fields != null && i < fields.length; i++) {
- IField f = fields[i];
- if (Modifier.isPublic(f.getFlags())) {
- properties.add(f.getElementName());
- }
- }
- } catch (JavaModelException e) {
- SeamCorePlugin.getDefault().logError(e);
- }
- }
- return properties;
- }
}
\ No newline at end of file
Added:
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
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/TypeInfoCollector.java 2007-11-01
19:57:36 UTC (rev 4648)
@@ -0,0 +1,669 @@
+package org.jboss.tools.seam.internal.core.el;
+
+import java.lang.reflect.Modifier;
+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.eclipse.jdt.core.ICompletionRequestor;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.jboss.tools.common.model.util.EclipseJavaUtil;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+
+public class TypeInfoCollector {
+ IType fType;
+ List<MethodInfo> fMethods;
+ List<FieldInfo> fFields;
+
+ public abstract static class MemberInfo {
+ private String fDeclaringTypeQualifiedName;
+ private String fName;
+ private int fModifiers;
+ private IType fSourceType;
+
+ protected MemberInfo (
+ IType sourceType,
+ String declaringTypeQualifiedName, String name, int modifiers) {
+ setSourceType(sourceType);
+ setDeclaringTypeQualifiedName(declaringTypeQualifiedName);
+ setName(name);
+ setModifiers(modifiers);
+ }
+
+ public void setSourceType(IType sourceType) {
+ fSourceType = sourceType;
+ }
+
+ public IType getSourceType() {
+ return fSourceType;
+ }
+
+ protected void setName (String name) {
+ this.fName = name;
+ }
+
+ public String getName() {
+ return fName;
+ }
+
+ protected void setDeclaringTypeQualifiedName (String declaringTypeQualifiedName) {
+ this.fDeclaringTypeQualifiedName = declaringTypeQualifiedName;
+ }
+
+ public String getDeclaringTypeQualifiedName() {
+ return fDeclaringTypeQualifiedName;
+ }
+
+ protected void setModifiers (int modifiers) {
+ this.fModifiers = modifiers;
+ }
+
+ public int getModifiers() {
+ return fModifiers;
+ }
+
+ public boolean isPublic() {
+ return Modifier.isPublic(fModifiers) && !isJavaLangObject();
+ }
+
+ public boolean isJavaLangObject() {
+ return "java.lang.Object".equals(getDeclaringTypeQualifiedName());
+ }
+
+ abstract public IType getMemberType();
+
+ abstract public IJavaElement getJavaElement();
+
+ }
+
+ public static class TypeInfo extends MemberInfo {
+ IType fType;
+
+ public TypeInfo(IType type) throws JavaModelException {
+ super(type.getDeclaringType(), (type.getDeclaringType() == null ? null :
type.getDeclaringType().getFullyQualifiedName()), type.getFullyQualifiedName(),
type.getFlags());
+ this.fType = type;
+ }
+
+ public IType getType() {
+ return fType;
+ }
+
+ @Override
+ public IType getMemberType() {
+ return getType();
+ }
+
+ @Override
+ public IJavaElement getJavaElement() {
+ return getType();
+ }
+ }
+
+ public static class FieldInfo extends MemberInfo {
+
+ private String fTypeQualifiedName;
+
+ public FieldInfo(IType sourceType, String declaringTypeQualifiedName, String name, int
modifiers, String typeQualifiedName) {
+ super(sourceType, declaringTypeQualifiedName, name, modifiers);
+ setTypeQualifiedName(typeQualifiedName);
+ }
+
+ public FieldInfo(IField field) throws JavaModelException {
+ this (field.getDeclaringType(), (field.getDeclaringType() == null ? null :
field.getDeclaringType().getFullyQualifiedName()),
+ field.getElementName(),
+ field.getFlags(),
+ EclipseJavaUtil.getMemberTypeAsString(field));
+ }
+
+ protected void setTypeQualifiedName(String typeQualifiedName) {
+ fTypeQualifiedName = typeQualifiedName;
+ }
+
+ public String getTypeQualifiedName() {
+ return fTypeQualifiedName;
+ }
+
+ public IType getType() {
+ try {
+ return getSourceType().getJavaProject().findType(getTypeQualifiedName());
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ return null;
+ }
+ }
+
+ public IJavaElement getJavaElement () {
+ try {
+ IType declType =
getSourceType().getJavaProject().findType(getDeclaringTypeQualifiedName());
+
+ return (declType == null ? null : declType.getField(getName()));
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ return null;
+ }
+ }
+
+ public IType getMemberType() {
+ return getType();
+ }
+
+ }
+
+ public static class MethodInfo extends MemberInfo {
+ String[] fParameterTypeQualifiedNames;
+ String[] fParameterNames;
+ String fReturnTypeQualifiedName;
+
+ public MethodInfo(IType sourceType, String declaringTypeQualifiedName, String name,
+ int modifiers, String[] parameterTypeQualifiedNames,
+ String[] parameterNames,
+ String returnTypeQualifiedName) {
+ super(sourceType, declaringTypeQualifiedName, name, modifiers);
+ setParameterTypeQualifiedNames(parameterTypeQualifiedNames);
+ setParameterNames(parameterNames);
+ setReturnTypeQualifiedName(returnTypeQualifiedName);
+ }
+
+ public MethodInfo(IMethod method) throws JavaModelException {
+ this (method.getDeclaringType(), (method.getDeclaringType() == null ? null :
method.getDeclaringType().getFullyQualifiedName()),
+ method.getElementName(),
+ method.getFlags(),
+ resolveSignatures(method.getDeclaringType(), method.getParameterTypes()),
+ method.getParameterNames(),
+ EclipseJavaUtil.getMemberTypeAsString(method));
+ }
+
+ protected void setParameterTypeQualifiedNames(String[] parameterTypeQualifiedNames) {
+ fParameterTypeQualifiedNames = (parameterTypeQualifiedNames == null ?
+ new String[0] : parameterTypeQualifiedNames);
+ }
+
+ public String[] getParameterTypeQualifiedNames() {
+ return fParameterTypeQualifiedNames;
+ }
+
+ protected void setParameterNames(String[] parameterNames) {
+ fParameterNames = (parameterNames == null ?
+ new String[0] : parameterNames);
+ }
+
+ public String[] getParameterNames() {
+ return fParameterNames;
+ }
+
+ protected void setReturnTypeQualifiedName(String returnTypeQualifiedName) {
+ fReturnTypeQualifiedName = returnTypeQualifiedName;
+ }
+
+ public String getReturnTypeQualifiedName() {
+ return fReturnTypeQualifiedName;
+ }
+
+ public int getNumberOfParameters() {
+ return (getParameterNames() == null ? 0 : getParameterNames().length);
+ }
+
+ public IType getReturnType() {
+ try {
+ return getSourceType().getJavaProject().findType(getReturnTypeQualifiedName());
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ return null;
+ }
+ }
+
+ public boolean isConstructor () {
+ return getDeclaringTypeQualifiedName().equals(getName());
+ }
+
+ public boolean isGetter() {
+ return (getName().startsWith("get") &&
!getName().equals("get")) || getName().startsWith("is");
+ }
+
+ public boolean isSetter() {
+ return (getName().startsWith("set") &&
!getName().equals("set"));
+ }
+
+ @Override
+ public IType getMemberType() {
+ return getReturnType();
+ }
+
+ @Override
+ public IJavaElement getJavaElement () {
+ try {
+ IType declType =
getSourceType().getJavaProject().findType(getDeclaringTypeQualifiedName());
+
+ IMethod[] allMethods = declType.getMethods();
+
+ // filter methods by name
+ List<IMethod> methods = new ArrayList<IMethod>();
+ for (int i = 0; allMethods != null && i < allMethods.length; i++) {
+ if (allMethods[i].getElementName().equals(getName())) {
+ methods.add(allMethods[i]);
+ }
+ }
+ if (methods.isEmpty())
+ return null;
+ if (methods.size() == 1)
+ return methods.get(0);
+
+ // filter methods by number of parameters
+ List<IMethod> filteredMethods = new ArrayList<IMethod>();
+ for (IMethod method : methods) {
+ if (method.getNumberOfParameters() == getNumberOfParameters())
+ filteredMethods.add(method);
+ }
+ if (filteredMethods.isEmpty())
+ return null;
+ if (filteredMethods.size() == 1)
+ return filteredMethods.get(0);
+
+ methods = filteredMethods;
+
+ // filter methods by parameter types
+ for(IMethod method : methods) {
+ String[] methodParameterTypes =
+ resolveSignatures(method.getDeclaringType(),
+ method.getParameterTypes());
+ String[] parameterTypes = getParameterTypeQualifiedNames();
+
+ boolean equal = true;
+ for (int i = 0; parameterTypes != null && i < parameterTypes.length; i++)
{
+ // simple types must be equal, but complex types may not
+ if (!parameterTypes[i].equals(methodParameterTypes[i])) {
+ // sure - it's Complex Type
+ if (! (parameterTypes[i].indexOf('.') != -1)
+ && (methodParameterTypes[i].indexOf('.') == -1)) {
+ equal = false;
+ break;
+ }
+ }
+ }
+ if (equal)
+ return method;
+ }
+ return null;
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ return null;
+ }
+ }
+ }
+
+ ICompletionRequestor fRequestor = new ICompletionRequestor() {
+
+ public void acceptAnonymousType(
+ char[] superTypePackageName,
+ char[] superTypeName,
+ char[][] parameterPackageNames,
+ char[][] parameterTypeNames,
+ char[][] parameterNames, char[] completionName,
+ int modifiers, int completionStart,
+ int completionEnd, int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptClass(char[] packageName,
+ char[] className, char[] completionName,
+ int modifiers, int completionStart,
+ int completionEnd, int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptError(IProblem error) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptField(
+ char[] declaringTypePackageName,
+ char[] declaringTypeName, char[] name,
+ char[] typePackageName, char[] typeName,
+ char[] completionName, int modifiers,
+ int completionStart, int completionEnd,
+ int relevance) {
+
+ FieldInfo info = new FieldInfo(TypeInfoCollector.this.fType,
+ getQualifiedClassNameFromChars(declaringTypePackageName, declaringTypeName),
+ String.valueOf(name), modifiers,
+ getQualifiedClassNameFromChars(typePackageName, typeName));
+ fFields.add(info);
+ }
+
+ public void acceptInterface(char[] packageName,
+ char[] interfaceName, char[] completionName,
+ int modifiers, int completionStart,
+ int completionEnd, int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptKeyword(char[] keywordName,
+ int completionStart, int completionEnd,
+ int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptLabel(char[] labelName,
+ int completionStart, int completionEnd,
+ int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptLocalVariable(char[] name,
+ char[] typePackageName, char[] typeName,
+ int modifiers, int completionStart,
+ int completionEnd, int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptMethod(
+ char[] declaringTypePackageName,
+ char[] declaringTypeName, char[] selector,
+ char[][] parameterPackageNames,
+ char[][] parameterTypeNames,
+ char[][] parameterNames,
+ char[] returnTypePackageName,
+ char[] returnTypeName, char[] completionName,
+ int modifiers, int completionStart,
+ int completionEnd, int relevance) {
+
+ MethodInfo info = new MethodInfo(TypeInfoCollector.this.fType,
+ getQualifiedClassNameFromChars(declaringTypePackageName, declaringTypeName),
+ String.valueOf(selector), modifiers,
+ getQualifiedClassNameFromCharArray(parameterPackageNames, parameterTypeNames),
+ convertToStringArray(parameterNames),
+ getQualifiedClassNameFromChars(returnTypePackageName, returnTypeName));
+ fMethods.add(info);
+ }
+
+ public void acceptMethodDeclaration(
+ char[] declaringTypePackageName,
+ char[] declaringTypeName, char[] selector,
+ char[][] parameterPackageNames,
+ char[][] parameterTypeNames,
+ char[][] parameterNames,
+ char[] returnTypePackageName,
+ char[] returnTypeName, char[] completionName,
+ int modifiers, int completionStart,
+ int completionEnd, int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptModifier(char[] modifierName,
+ int completionStart, int completionEnd,
+ int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptPackage(char[] packageName,
+ char[] completionName, int completionStart,
+ int completionEnd, int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptType(char[] packageName,
+ char[] typeName, char[] completionName,
+ int completionStart, int completionEnd,
+ int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void acceptVariableName(char[] typePackageName,
+ char[] typeName, char[] name,
+ char[] completionName, int completionStart,
+ int completionEnd, int relevance) {
+ // TODO Auto-generated method stub
+
+ }
+
+ };
+
+ public TypeInfoCollector(IType type) {
+ this.fType = type;
+ }
+
+ public void collectInfo() {
+ if (fMethods == null) {
+ fMethods = new ArrayList<MethodInfo>();
+ } else {
+ fMethods.clear();
+ }
+
+ if (fFields == null) {
+ fFields = new ArrayList<FieldInfo>();
+ } else {
+ fFields.clear();
+ }
+
+ if (fType == null)
+ return;
+ try {
+ fType.codeComplete("".toCharArray(), -1, 0, new char[0][0], new char[0][0],
new int[0], false, fRequestor);
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ }
+
+ public MemberInfo[] getAllMethodInfos() {
+ List<MemberInfo> methods = new ArrayList<MemberInfo>();
+ for (MethodInfo info : fMethods) {
+ if (info.isPublic() && !info.isConstructor())
+ methods.add(info);
+ }
+ return methods.toArray(new MemberInfo[0]);
+ }
+
+ /**
+ * Returns the methods for the type specified
+ *
+ * @return
+ */
+ public List<MemberInfo> getMethods() {
+ List<MemberInfo> methods = new ArrayList<MemberInfo>();
+ for (MethodInfo info : fMethods) {
+ if (info.isPublic() && !info.isConstructor()
+ && !info.isGetter() && !info.isSetter())
+ methods.add(info);
+ }
+ return methods;
+ }
+
+ /**
+ * Returns the method presentation strings for the type specified
+ *
+ * @param type
+ * @return
+ */
+ public Set<String> getMethodPresentations() {
+ Set<String> methods = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+// IMethod[] mthds = type.getMethods();
+ List<MemberInfo> mthds = getMethods();
+ for (MemberInfo info : mthds) {
+ if (!(info instanceof MethodInfo))
+ continue;
+
+ MethodInfo method = (MethodInfo)info;
+
+ StringBuffer name = new StringBuffer(method.getName());
+
+ // Add method as 'foo'
+ methods.add(name.toString());
+
+ // Add method as 'foo(param1,param2)'
+ name.append('(');
+ String[] mParams = method.getParameterNames();
+ for (int j = 0; mParams != null && j < mParams.length; j++) {
+ if (j > 0) name.append(", "); //$NON-NLS-1$
+ name.append(mParams[j]);
+ }
+ name.append(')');
+
+ methods.add(name.toString());
+ }
+ return methods;
+ }
+
+ /**
+ * Returns the properties for the type specified
+ *
+ * @return
+ */
+ public List<MemberInfo> getProperties() {
+ List<MemberInfo> properties = new ArrayList<MemberInfo>();
+ for (MethodInfo info : fMethods) {
+ if (info.isPublic() && !info.isConstructor()
+ && (info.isGetter() || info.isSetter()))
+ properties.add(info);
+ }
+ for (FieldInfo info : fFields) {
+ if (info.isPublic())
+ properties.add(info);
+ }
+
+
+ return properties;
+ }
+
+
+ /**
+ * Returns the property presentation strings for the type specified
+ *
+ * @return
+ */
+ public Set<String> getPropertyPresentations() {
+ return getPropertyPresentations(null);
+ }
+
+ /**
+ * Returns the property presentation strings for the type specified
+ *
+ * @param unpairedGettersOrSetters - map of unpaired getters or setters of type's
properties. 'key' is property name.
+ * @return
+ */
+ public Set<String> getPropertyPresentations(Map<String, MethodInfo>
unpairedGettersOrSetters) {
+ Set<String> properties = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+ List<MemberInfo> props = getProperties();
+ HashMap<String, MethodInfo> getters = new HashMap<String, MethodInfo>();
+ HashMap<String, MethodInfo> setters = new HashMap<String, MethodInfo>();
+ for (MemberInfo info : props) {
+ if (info instanceof MethodInfo) {
+ MethodInfo m = (MethodInfo)info;
+
+ if (m.isGetter() || m.isSetter()) {
+ StringBuffer name = new StringBuffer(m.getName());
+ if(m.getName().startsWith("i")) { //$NON-NLS-1$
+ name.delete(0, 2);
+ } else {
+ name.delete(0, 3);
+ }
+ name.setCharAt(0, Character.toLowerCase(name.charAt(0)));
+ String propertyName = name.toString();
+ if(!properties.contains(propertyName)) {
+ properties.add(propertyName);
+ }
+ if(unpairedGettersOrSetters!=null) {
+ MethodInfo previousGetter = getters.get(propertyName);
+ MethodInfo previousSetter = setters.get(propertyName);
+ if((previousGetter!=null && m.isSetter())||(previousSetter!=null &&
m.isGetter())) {
+ // We have both Getter and Setter
+ unpairedGettersOrSetters.remove(propertyName);
+ } else if(m.isSetter()) {
+ setters.put(propertyName, m);
+ unpairedGettersOrSetters.put(propertyName, m);
+ } else if(m.isGetter()) {
+ getters.put(propertyName, m);
+ unpairedGettersOrSetters.put(propertyName, m);
+ }
+ }
+ }
+ } else {
+ properties.add(info.getName());
+ }
+ }
+ return properties;
+ }
+
+ public static MemberInfo createMemberInfo(IMember member) {
+
+ try {
+ if (member instanceof IType)
+ return new TypeInfo((IType)member);
+ else if (member instanceof IField)
+ return new FieldInfo((IField)member);
+ else if (member instanceof IMethod)
+ return new MethodInfo((IMethod)member);
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+
+ return null;
+ }
+
+ static String[] resolveSignatures (IType type, String[] signatures) {
+ if (signatures == null || signatures.length == 0)
+ return new String[0];
+
+ String[] resolvedSignatures = new String[signatures.length];
+ for (int i = 0; i < signatures.length; i++) {
+ resolvedSignatures[i] = EclipseJavaUtil.resolveTypeAsString(type, signatures[i]);
+ }
+ return resolvedSignatures;
+ }
+
+ static String[] convertToStringArray(char[][] names) {
+ if (names == null || names.length == 0)
+ return new String[0];
+ String[] sNames = new String[names.length];
+ for (int i = 0; i < sNames.length; i++) {
+ sNames[i] = String.valueOf(names[i]);
+ }
+ return sNames;
+ }
+
+ static String[] getQualifiedClassNameFromCharArray (char[][] packageNames, char[][]
classNames) {
+ if (packageNames == null || packageNames.length == 0)
+ return new String[0];
+ String[] qualifiedNames = new String[packageNames.length];
+ for (int i = 0; i < qualifiedNames.length; i++) {
+ qualifiedNames[i] = getQualifiedClassNameFromChars(packageNames[i], classNames[i]);
+ }
+ return qualifiedNames;
+ }
+
+ public static String getQualifiedClassNameFromChars (char[] packageName, char[]
className) {
+ StringBuffer qualifiedName = new StringBuffer();
+ if (packageName != null && packageName.length > 0)
+ qualifiedName.append(packageName).append('.');
+ qualifiedName.append(className);
+ return qualifiedName.toString();
+ }
+
+ public static String getQualifiedClassName (String packageName, String className) {
+ StringBuffer qualifiedName = new StringBuffer();
+ if (packageName != null && packageName.length() > 0)
+ qualifiedName.append(packageName).append('.');
+ qualifiedName.append(className);
+ return qualifiedName.toString();
+ }
+
+}
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/TypeInfoCollector.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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 2007-11-01
19:50:18 UTC (rev 4647)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamELValidator.java 2007-11-01
19:57:36 UTC (rev 4648)
@@ -54,6 +54,7 @@
import org.jboss.tools.seam.internal.core.el.SeamELCompletionEngine;
import org.jboss.tools.seam.internal.core.el.SeamELOperandTokenizer;
import org.jboss.tools.seam.internal.core.el.SeamELTokenizer;
+import org.jboss.tools.seam.internal.core.el.TypeInfoCollector;
/**
* EL Validator
@@ -277,7 +278,7 @@
}
Set<ISeamContextVariable> usedVariables = new
HashSet<ISeamContextVariable>();
- Map<String, IMethod> unpairedGettersOrSetters = new HashMap<String,
IMethod>();
+ Map<String, TypeInfoCollector.MethodInfo> unpairedGettersOrSetters = new
HashMap<String, TypeInfoCollector.MethodInfo>();
List<String> suggestions = engine.getCompletions(project, file, operand,
prefix, position, true, usedVariables, unpairedGettersOrSetters);
@@ -293,8 +294,8 @@
// Check pair for getter/setter
if(unpairedGettersOrSetters.size()>0) {
- IMethod unpairedMethod = unpairedGettersOrSetters.values().iterator().next();
- String methodName = unpairedMethod.getElementName();
+ TypeInfoCollector.MethodInfo unpairedMethod =
unpairedGettersOrSetters.values().iterator().next();
+ String methodName = unpairedMethod.getName();
String propertyName = unpairedGettersOrSetters.keySet().iterator().next();
String missingMethodName = SeamCoreMessages.SEAM_EL_VALIDATOR_SETTER;
String existedMethodName = SeamCoreMessages.SEAM_EL_VALIDATOR_GETTER;