Fixed KT-2488 Optimizing imports removes references to enum constants when they are referred via short name in code
This commit is contained in:
@@ -133,7 +133,11 @@ public class JetPsiUtil {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public static FqName getFQName(JetNamedDeclaration namedDeclaration) {
|
public static FqName getFQName(JetNamedDeclaration namedDeclaration) {
|
||||||
if (namedDeclaration instanceof JetObjectDeclarationName) {
|
if (namedDeclaration instanceof JetObjectDeclarationName) {
|
||||||
JetObjectDeclaration objectDeclaration = PsiTreeUtil.getParentOfType(namedDeclaration, JetObjectDeclaration.class);
|
JetNamedDeclaration objectDeclaration = PsiTreeUtil.getParentOfType(namedDeclaration, JetObjectDeclaration.class);
|
||||||
|
if (objectDeclaration == null) {
|
||||||
|
objectDeclaration = PsiTreeUtil.getParentOfType(namedDeclaration, JetEnumEntry.class);
|
||||||
|
}
|
||||||
|
|
||||||
if (objectDeclaration == null) {
|
if (objectDeclaration == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
import test.MyEnum.ONE
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
println(ONE)
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum class MyEnum {
|
||||||
|
ONE
|
||||||
|
TWO
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
import test.MyEnum.ONE
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
println(ONE)
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum class MyEnum {
|
||||||
|
ONE
|
||||||
|
TWO
|
||||||
|
}
|
||||||
@@ -52,6 +52,10 @@ public class OptimizeImportsTest extends LightCodeInsightTestCase {
|
|||||||
doTest();
|
doTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testKt2488() throws Exception {
|
||||||
|
doTest();
|
||||||
|
}
|
||||||
|
|
||||||
public void doTest() throws Exception {
|
public void doTest() throws Exception {
|
||||||
configureByFile(fileName());
|
configureByFile(fileName());
|
||||||
invokeFormatFile();
|
invokeFormatFile();
|
||||||
|
|||||||
Reference in New Issue
Block a user