diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractLocalVariable.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractLocalVariable.rts index eb3fedd2b09..e90a4012b24 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractLocalVariable.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractLocalVariable.rts @@ -506,8 +506,8 @@ class Foo { Foo getFoo(); int main() { - Foo getFoo0 = getFoo(); - getFoo0; + Foo foo = getFoo(); + foo; return 0; } @@ -540,8 +540,8 @@ class Foo { bar::Foo getFoo(); int main() { - bar::Foo getFoo0 = getFoo(); - getFoo0; + bar::Foo foo = getFoo(); + foo; return 0; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java index dbc0537e502..8655223c408 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java @@ -317,10 +317,24 @@ public class ExtractLocalVariableRefactoring extends CRefactoring { public String guessTempName() { String[] proposals= guessTempNames(); - if (proposals.length == 0) + if (proposals.length == 0) { return info.getName(); - else - return proposals[0]; + } else { + String name = getLastCamelCasePart(proposals[proposals.length - 1]); + return name; + } + } + + private String getLastCamelCasePart(String string) { + if (string.length() == 0) { + return string; + } + int index = string.length() - 1; + while (index > 0 + && (Character.isLowerCase(string.charAt(index)) || Character.isDigit(string.charAt(index)))) { + --index; + } + return string.substring(index).toLowerCase(); } /** @@ -394,7 +408,7 @@ public class ExtractLocalVariableRefactoring extends CRefactoring { tmpName[len++] = c; } } - name = new String(tmpName, 0, len); + name = getLastCamelCasePart(new String(tmpName, 0, len)); if (name.length() > 0) { if (nameAvailable(name, guessedTempNames, scope)) { guessedTempNames.add(name);