Bug 78714

Summary: "Convert local to field" should know about prefixes
Product: [Eclipse Project] JDT Reporter: Guillaume Pothier <gpothier>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: markus.kell.r
Version: 3.1   
Target Milestone: 3.1 M4   
Hardware: All   
OS: All   
Whiteboard:

Description Guillaume Pothier CLA 2004-11-16 06:36:53 EST
Preferences are set up so that local variables have prefix "the" and fields have
prefix "its".
The "Convert local to field" refactoring should strip the local variable prefix,
and replace it by the field prefix. Current behaviour is only to prepend the
field prefix.
For instance if in a method I have this variable: String theName = "name";
Invoking the refactoring proposes the following name is suggested: "itsTheName".
Comment 1 Dirk Baeumer CLA 2004-11-16 08:48:39 EST
Agree.

Markus, please fix for 3.1
Comment 2 Markus Keller CLA 2004-11-17 03:23:47 EST
Moving to jdt.core.

The bug is in org.eclipse.jdt.core.NamingConventions:

public static char[] removePrefixAndSuffixForLocalVariableName(
    IJavaProject javaProject, char[] localName) {
  AssistOptions assistOptions = new AssistOptions(javaProject.getOptions(true));
  return removePrefixAndSuffix(
    localName,
    assistOptions.argumentPrefixes,
    assistOptions.argumentSuffixes);
}

=> Should be *local*Prefixes/Suffixes.
Comment 3 Olivier Thomann CLA 2004-11-17 12:51:59 EST
Thanks, Markus.
That fixed it.
Added regression test.
Fixed and released in HEAD.
Comment 4 Jerome Lanneluc CLA 2004-12-14 10:03:34 EST
Could not find regression test. Olivier what is the regression test ?
Comment 5 Olivier Thomann CLA 2004-12-14 10:27:56 EST
The test is NamingConventionTests.testRemovePrefixAndSuffixForLocalName001()
Comment 6 Jerome Lanneluc CLA 2004-12-14 10:56:04 EST
Verified (in I200412140800) that the test ensures that the prefix and suffix are
correctly removed.