mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 06:50:54 +07:00
IDEA-111362 Generate constructor removes "m" from variable name
This commit is contained in:
@@ -748,8 +748,11 @@ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager {
|
||||
String suffix = getSuffixByVariableKind(variableKind);
|
||||
boolean doDecapitalize = false;
|
||||
|
||||
if (name.startsWith(prefix) && name.length() > prefix.length()) {
|
||||
name = name.substring(prefix.length());
|
||||
int pLength = prefix.length();
|
||||
if (pLength > 0 && name.startsWith(prefix) && name.length() > pLength &&
|
||||
// check it's not just a long camel word that happens to begin with the specified prefix
|
||||
(!Character.isJavaIdentifierPart(prefix.charAt(pLength - 1)) || Character.isUpperCase(name.charAt(pLength)))) {
|
||||
name = name.substring(pLength);
|
||||
doDecapitalize = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
class Parent {
|
||||
Object menu;
|
||||
|
||||
Parent(Object menu) {
|
||||
this.menu = menu;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class Parent {
|
||||
Object menu;
|
||||
<caret>
|
||||
}
|
||||
|
||||
@@ -50,6 +50,11 @@ public class GenerateConstructorTest extends LightCodeInsightTestCase {
|
||||
public void testFinalFieldPreselection() throws Exception { doTest(true); }
|
||||
public void testSubstitution() throws Exception { doTest(true); }
|
||||
|
||||
public void testFieldPrefixCoincidence() throws Exception {
|
||||
CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings().FIELD_NAME_PREFIX = "m";
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user