mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
preserve static imports if overloaded methods are still used (IDEA-128873)
This commit is contained in:
@@ -448,7 +448,12 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
if (element instanceof PsiReferenceExpression) {
|
||||
refExprList.add((PsiReferenceExpression)element);
|
||||
} else if (element instanceof PsiImportStaticReferenceElement) {
|
||||
imports2Delete.add(PsiTreeUtil.getParentOfType(element, PsiImportStaticStatement.class));
|
||||
final JavaResolveResult[] resolveResults = ((PsiImportStaticReferenceElement)element).multiResolve(false);
|
||||
if (resolveResults.length < 2) {
|
||||
//no overloads available: ensure broken import are deleted and
|
||||
//unused overloaded imports are deleted by optimize imports helper
|
||||
imports2Delete.add(PsiTreeUtil.getParentOfType(element, PsiImportStaticStatement.class));
|
||||
}
|
||||
}
|
||||
else if (JavaLanguage.INSTANCE != element.getLanguage()) {
|
||||
GenericInlineHandler.inlineReference(usage, myMethod, myInliners);
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import static Foo.foo;
|
||||
public class Bar {
|
||||
void bar() {
|
||||
foo(1);
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
public class Foo {
|
||||
public static void foo(int i){}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import static Foo.foo;
|
||||
public class Bar {
|
||||
void bar() {
|
||||
foo();
|
||||
foo(1);
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
public class Foo {
|
||||
public static void foo(){}
|
||||
public static void foo(int i){}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
public class Bar {
|
||||
void bar() {
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
public class Foo {
|
||||
public static void foo(int i){}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import static Foo.foo;
|
||||
public class Bar {
|
||||
void bar() {
|
||||
foo();
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
public class Foo {
|
||||
public static void foo(){}
|
||||
public static void foo(int i){}
|
||||
}
|
||||
@@ -42,6 +42,9 @@ public class InlineMethodMultifileTest extends RefactoringTestCase {
|
||||
public void testRemoveStaticImports() throws Exception {
|
||||
doTest("Foo", "foo");
|
||||
}
|
||||
public void testPreserveStaticImportsIfOverloaded() throws Exception {
|
||||
doTest("Foo", "foo");
|
||||
}
|
||||
|
||||
private void doTest(String className, String methodName) throws Exception {
|
||||
String rootBefore = getRoot() + "/before";
|
||||
|
||||
Reference in New Issue
Block a user