Bug 78714 - "Convert local to field" should know about prefixes
Summary: "Convert local to field" should know about prefixes
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.1 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-16 06:36 EST by Guillaume Pothier CLA
Modified: 2004-12-14 10:56 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.