Author: scabanovich
Date: 2008-04-22 12:00:25 -0400 (Tue, 22 Apr 2008)
New Revision: 7689
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBean.java
Log:
JBIDE-2060
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBean.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBean.java 2008-04-22
16:00:18 UTC (rev 7688)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBean.java 2008-04-22
16:00:25 UTC (rev 7689)
@@ -121,10 +121,10 @@
if(!Flags.isPublic(ms[i].getFlags())) continue;
String n = ms[i].getElementName();
boolean isProperty = false;
- if((n.startsWith("get") || n.startsWith("set")) &&
n.length() > 3) {
+ if((isGetter(ms[i], "get") || isSetter(ms[i])) && n.length() >
3) {
n = n.substring(3, 4).toLowerCase() + n.substring(4);
isProperty = true;
- } else if(n.startsWith("is") && n.length() > 2) {
+ } else if(isGetter(ms[i], "is")) {
String typeName = EclipseJavaUtil.getMemberTypeAsString(ms[i]);
if("boolean".equals(typeName) ||
"java.lang.Boolean".equals(typeName)) {
n = n.substring(2, 3).toLowerCase() + n.substring(3);
@@ -197,5 +197,35 @@
if(isLoading) addChild_0(c); else addChild(c);
return c;
}
+
+ private boolean isGetter(IMethod method, String pref) {
+ if(method == null) return false;
+ String name = method.getElementName();
+ if(!name.startsWith(pref) || name.length() <= pref.length()) return false;
+ try {
+ String[] ps = method.getParameterNames();
+ if(ps == null || ps.length != 0) return false;
+ String t = EclipseJavaUtil.getMemberTypeAsString(method);
+ if(t == null || t.equals("void")) return false;
+ } catch (JavaModelException e) {
+ return false;
+ }
+
+ return true;
+ }
+ private boolean isSetter(IMethod method) {
+ if(method == null) return false;
+ String name = method.getElementName();
+ if(!name.startsWith("set") || name.length() <= 3) return false;
+ try {
+ String[] ps = method.getParameterNames();
+ if(ps == null || ps.length != 1) return false;
+ } catch (JavaModelException e) {
+ return false;
+ }
+
+ return true;
+ }
+
}
Show replies by date