Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanIntrospector.java6
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanPropertyWorkingCopy.java64
2 files changed, 52 insertions, 18 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanIntrospector.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanIntrospector.java
index 526d717ff..5175158cf 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanIntrospector.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanIntrospector.java
@@ -49,6 +49,7 @@ public class JDTBeanIntrospector
private final static String IS_PREFIX = "is"; //$NON-NLS-1$
private final IType _type;
+ private final HashMap<String, String> _resolvedSignatures;
/**
* @param type
@@ -56,6 +57,7 @@ public class JDTBeanIntrospector
public JDTBeanIntrospector(IType type)
{
_type = type;
+ _resolvedSignatures = new HashMap<String, String>();
}
/**
@@ -65,6 +67,8 @@ public class JDTBeanIntrospector
*/
public Map<String, JDTBeanProperty> getProperties()
{
+ _resolvedSignatures.clear();
+
final Map<String, JDTBeanProperty> propertiesWorkingCopy =
new HashMap<String, JDTBeanProperty>();
final IMethod[] methods = getAllMethods();
@@ -138,7 +142,7 @@ public class JDTBeanIntrospector
if (workingCopy == null)
{
- workingCopy = new JDTBeanPropertyWorkingCopy(_type);
+ workingCopy = new JDTBeanPropertyWorkingCopy(_type, _resolvedSignatures);
properties.put(propertyName, workingCopy);
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanPropertyWorkingCopy.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanPropertyWorkingCopy.java
index f3bdf1408..4179f0901 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanPropertyWorkingCopy.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanPropertyWorkingCopy.java
@@ -11,8 +11,10 @@
package org.eclipse.jst.jsf.common.util;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
@@ -35,8 +37,20 @@ public class JDTBeanPropertyWorkingCopy extends JDTBeanProperty
* the IMethod for the boolean "is" accessor method
*/
private IMethod _isGetter;
+
+ private final Map<String, String> _resolvedSignatureMap;
/**
+ * @param type
+ * @param resolvedSignatureMap
+ */
+ public JDTBeanPropertyWorkingCopy(IType type, Map<String, String> resolvedSignatureMap)
+ {
+ super(type);
+ _setters = new ArrayList();
+ _resolvedSignatureMap = resolvedSignatureMap;
+ }
+ /**
* Constructor
* @param type
*/
@@ -44,6 +58,7 @@ public class JDTBeanPropertyWorkingCopy extends JDTBeanProperty
{
super(type);
_setters = new ArrayList();
+ _resolvedSignatureMap = new HashMap<String, String>();
}
/**
@@ -80,36 +95,39 @@ public class JDTBeanPropertyWorkingCopy extends JDTBeanProperty
beanProp.setGetter(getter);
beanProp.setSetter(matchedSetter);
return beanProp;
+
}
private IMethod determineMatchedSetter(IMethod getter)
{
IMethod matchedSetter = null;
- try
+ // if there are no setters, there is no point in proceeding
+ if (_setters.size() < 1)
{
- final String getterSig =
- TypeUtil.resolveTypeSignature(_type, getter.getReturnType());
+ return null;
+ }
+ try
+ {
+ final String getterSig = getResolvedSignature(_type, getter.getReturnType());
FIND_MATCHING_SETTER:for
(final Iterator it = _setters.iterator(); it.hasNext();)
{
final IMethod setter = (IMethod) it.next();
- if (setter.getNumberOfParameters() == 1)
+ assert (setter.getNumberOfParameters() == 1);
+ final String paramSig =
+ getResolvedSignature
+ (_type,setter.getParameterTypes()[0]);
+
+ if (paramSig.equals(getterSig))
{
- final String paramSig =
- TypeUtil.resolveTypeSignature
- (_type,setter.getParameterTypes()[0]);
-
- if (paramSig.equals(getterSig))
- {
- // we've found our match since only one
- // setter with the same name as the getter
- // can have the same matching type for a
- // single arg method
- matchedSetter = setter;
- break FIND_MATCHING_SETTER;
- }
+ // we've found our match since only one
+ // setter with the same name as the getter
+ // can have the same matching type for a
+ // single arg method
+ matchedSetter = setter;
+ break FIND_MATCHING_SETTER;
}
}
}
@@ -160,4 +178,16 @@ public class JDTBeanPropertyWorkingCopy extends JDTBeanProperty
public IMethod getIsGetter() {
return _isGetter;
}
+
+ private String getResolvedSignature(final IType type, final String unresolved)
+ {
+ String resolved = _resolvedSignatureMap.get(unresolved);
+
+ if (resolved == null)
+ {
+ resolved = TypeUtil.resolveTypeSignature(_type, unresolved);
+ _resolvedSignatureMap.put(unresolved, resolved);
+ }
+ return resolved;
+ }
}

Back to the top