mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-79290 Inline Local Variable does not qualify accesses to obscured types
This commit is contained in:
@@ -221,7 +221,8 @@ public class ReferenceAdjuster {
|
||||
private static boolean isSafeToShortenReference(final String referenceText, final PsiElement psiReference, final PsiClass refClass) {
|
||||
final PsiManager manager = refClass.getManager();
|
||||
final JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject());
|
||||
return manager.areElementsEquivalent(refClass, facade.getResolveHelper().resolveReferencedClass(referenceText, psiReference));
|
||||
final PsiResolveHelper helper = facade.getResolveHelper();
|
||||
return manager.areElementsEquivalent(refClass, helper.resolveReferencedClass(referenceText, psiReference)) && helper.resolveReferencedVariable(referenceText, psiReference) == null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
public class A {
|
||||
int f = 23;
|
||||
|
||||
static class B {
|
||||
static int f = 42;
|
||||
}
|
||||
|
||||
int foo() {
|
||||
int r = B.f;
|
||||
A B = this;
|
||||
return r<caret>;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(new A().foo());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
public class A {
|
||||
int f = 23;
|
||||
|
||||
static class B {
|
||||
static int f = 42;
|
||||
}
|
||||
|
||||
int foo() {
|
||||
A B = this;
|
||||
return A.B.f;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(new A().foo());
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,6 @@ import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.TargetElementUtilBase;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiLocalVariable;
|
||||
import com.intellij.psi.PsiReference;
|
||||
@@ -130,6 +128,11 @@ public class InlineLocalTest extends LightCodeInsightTestCase {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testQualified() throws Exception {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
|
||||
private void doTest(final boolean inlineDef, String conflictMessage) throws Exception {
|
||||
try {
|
||||
doTest(inlineDef);
|
||||
|
||||
Reference in New Issue
Block a user