mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
add single static import: ensure not available when conflict(IDEA-174983)
when methods (> 1) with same name exist in the containing class
This commit is contained in:
@@ -104,6 +104,9 @@ public class AddSingleMemberStaticImportAction extends BaseElementAtCaretIntenti
|
||||
else return null;
|
||||
}
|
||||
}
|
||||
else if (method == null && call.getMethodExpression().multiResolve(false).length > 0) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
final PsiJavaCodeReferenceElement copy = (PsiJavaCodeReferenceElement)refExpr.copy();
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import foo.*;
|
||||
class MyTest {
|
||||
{
|
||||
Assert.assert<caret>True(false);
|
||||
}
|
||||
|
||||
static void assertTrue() {}
|
||||
static void assertTrue(String message, boolean flag) {}
|
||||
}
|
||||
@@ -131,6 +131,13 @@ public class AddSingleStaticImportActionTest extends JavaCodeInsightFixtureTestC
|
||||
}
|
||||
}
|
||||
|
||||
public void testConflictingNamesInScope() throws Exception {
|
||||
myFixture.addClass("package foo; public class Assert {public static void assertTrue(boolean b) {}}");
|
||||
myFixture.configureByFile(getTestName(false) + ".java");
|
||||
IntentionAction intention = myFixture.getAvailableIntention("Add static import for 'foo.Assert.assertTrue'");
|
||||
assertNull(intention);
|
||||
}
|
||||
|
||||
public void testProhibitWhenMethodWithIdenticalSignatureAlreadyImportedFromAnotherClass() throws Exception {
|
||||
myFixture.addClass("package foo; class Foo {public static void foo(int i){}}");
|
||||
myFixture.addClass("package foo; class Bar {public static void foo(int i){}}");
|
||||
|
||||
Reference in New Issue
Block a user