Author: dazarov
Date: 2009-10-16 09:50:15 -0400 (Fri, 16 Oct 2009)
New Revision: 18132
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/RefactorSearcher.java
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4856
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/RefactorSearcher.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/RefactorSearcher.java 2009-10-16
12:45:51 UTC (rev 18131)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/RefactorSearcher.java 2009-10-16
13:50:15 UTC (rev 18132)
@@ -379,7 +379,7 @@
}
// TODO: move to util class
- public boolean isGetter(IMethod method) {
+ public static boolean isGetter(IMethod method) {
String name = method.getElementName();
int numberOfParameters = method.getNumberOfParameters();
@@ -387,13 +387,31 @@
}
// TODO: move to util class
- public boolean isSetter(IMethod method) {
+ public static boolean isSetter(IMethod method) {
String name = method.getElementName();
int numberOfParameters = method.getNumberOfParameters();
return ((name.startsWith(SET) && !name.equals(SET)) &&
numberOfParameters == 1);
}
+ // TODO: move to util class
+ public static String getPropertyName(IMethod method, String methodName){
+ if (isGetter(method) || isSetter(method)) {
+ StringBuffer name = new StringBuffer(methodName);
+ if(methodName.startsWith("i")) { //$NON-NLS-1$
+ name.delete(0, 2);
+ } else {
+ name.delete(0, 3);
+ }
+ if(name.length()<2 || Character.isLowerCase(name.charAt(1))) {
+ name.setCharAt(0, Character.toLowerCase(name.charAt(0)));
+ }
+ String propertyName = name.toString();
+ return propertyName;
+ }
+ return methodName;
+ }
+
private boolean containsInSearchScope(IProject project){
if(searchScope == null)
return true;
Modified:
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java 2009-10-16
12:45:51 UTC (rev 18131)
+++
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameMethodParticipant.java 2009-10-16
13:50:15 UTC (rev 18132)
@@ -90,7 +90,7 @@
oldName = method.getElementName();
- newName = getArguments().getNewName();
+ newName = RefactorSearcher.getPropertyName(method, getArguments().getNewName());
searcher = new SeamRenameMethodSearcher((IFile)method.getResource(), oldName);
added = false;
return true;