mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
copy reference: fix isReferenceTo check (IDEA-152601)
This commit is contained in:
@@ -281,8 +281,11 @@ public class JavaQualifiedNameProvider implements QualifiedNameProvider {
|
||||
PsiElement resolved = referenceExpression.advancedResolve(true).getElement();
|
||||
if (!(resolved instanceof PsiMember)) return false;
|
||||
PsiClass aClass = ((PsiMember)resolved).getContainingClass();
|
||||
if (aClass instanceof PsiAnonymousClass) aClass = ((PsiAnonymousClass)aClass).getBaseClassType().resolve();
|
||||
return aClass == targetElement.getContainingClass();
|
||||
if (aClass instanceof PsiAnonymousClass) {
|
||||
aClass = ((PsiAnonymousClass)aClass).getBaseClassType().resolve();
|
||||
return aClass == targetElement.getContainingClass();
|
||||
}
|
||||
return resolved == targetElement;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
class XXX {
|
||||
void f() {
|
||||
new
|
||||
}
|
||||
}
|
||||
class C2 {
|
||||
public <caret>C2(int i) {
|
||||
}
|
||||
|
||||
@@ -38,6 +38,15 @@ public class CopyReferenceActionTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testIdentifierSeparator() throws Exception { doTest(); }
|
||||
public void testMethodFromAnonymousClass() throws Exception { doTest(); }
|
||||
|
||||
public void testSameClassNames() throws Exception {
|
||||
myFixture.addClass("package p; public class Foo {}")
|
||||
myFixture.configureByText("Foo.java", "package p1; public class Fo<caret>o {}")
|
||||
performCopy()
|
||||
myFixture.configureByText("a.java", "import p.Foo; class Bar { <caret>}")
|
||||
performPaste()
|
||||
myFixture.checkResult """import p.Foo; class Bar {p1.Foo}"""
|
||||
}
|
||||
|
||||
public void testAddImport() {
|
||||
myFixture.addClass("package foo; public class Foo {}")
|
||||
myFixture.configureByText "a.java", "import foo.F<caret>oo;"
|
||||
|
||||
Reference in New Issue
Block a user