mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
introduce constant: resolve name conflict caused by static import (IDEA-235318)
GitOrigin-RevId: 3da9946d105c483e95b26cf46a6a23bfce97322e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
458e66b69f
commit
56f5c96346
+2
-1
@@ -296,9 +296,10 @@ class IntroduceConstantDialog extends DialogWrapper {
|
||||
codeStyleManager.suggestVariableName(VariableKind.STATIC_FINAL_FIELD, propertyName, psiExpression, type);
|
||||
if (psiExpression != null) {
|
||||
String[] names = nameInfo.names;
|
||||
PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(psiExpression.getProject()).getResolveHelper();
|
||||
for (int i = 0, namesLength = names.length; i < namesLength; i++) {
|
||||
String name = names[i];
|
||||
if (parentClass.findFieldByName(name, false) != null) {
|
||||
if (resolveHelper.resolveAccessibleReferencedVariable(name, parentClass) != null) {
|
||||
names[i] = codeStyleManager.suggestUniqueVariableName(name, psiExpression, true);
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package p;
|
||||
import static p.Foo.FOO;
|
||||
class Foo {
|
||||
public static final String FOO = "foo";
|
||||
}
|
||||
class Test {
|
||||
public void method() {
|
||||
String f<caret>oo = new String(FOO);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package p;
|
||||
import static p.Foo.FOO;
|
||||
class Foo {
|
||||
public static final String FOO = "foo";
|
||||
}
|
||||
class Test {
|
||||
|
||||
public static final String FOO1 = new String(FOO);
|
||||
|
||||
public void method() {
|
||||
}
|
||||
}
|
||||
+4
@@ -70,6 +70,10 @@ public class InplaceIntroduceConstantTest extends AbstractJavaInplaceIntroduceTe
|
||||
doTest(null);
|
||||
}
|
||||
|
||||
public void testConflictingConstantNameStaticallyImported() {
|
||||
doTest(null);
|
||||
}
|
||||
|
||||
public void testNoConflictingConstantName() {
|
||||
doTest(null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user