mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-151861 ExtractMethodObject should not move static methods into created inner class - honor make static
This commit is contained in:
+2
-2
@@ -131,8 +131,8 @@ public class ExtractMethodObjectProcessor extends BaseRefactoringProcessor {
|
||||
|
||||
|
||||
for (PsiMethod usedMethod : usedMethods) {
|
||||
PsiModifierList modifiers = usedMethod.getModifierList();
|
||||
if (modifiers.hasModifierProperty(PsiModifier.PRIVATE) && !modifiers.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
if (usedMethod.hasModifierProperty(PsiModifier.PRIVATE) &&
|
||||
(!usedMethod.hasModifierProperty(PsiModifier.STATIC) || myExtractProcessor.isStatic())) {
|
||||
PsiMethod toMove = usedMethod;
|
||||
for (PsiReference reference : ReferencesSearch.search(usedMethod)) {
|
||||
if (!PsiTreeUtil.isAncestor(getMethod(), reference.getElement(), false)) {
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class XXX {
|
||||
static void f<caret>oo() {
|
||||
int i = 0 ;
|
||||
bar(i);
|
||||
System.out.println(i);
|
||||
}
|
||||
|
||||
private static void bar(int i){}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
public class XXX {
|
||||
static void foo() {
|
||||
InnerClass.invoke();
|
||||
}
|
||||
|
||||
private static class InnerClass {
|
||||
private static void invoke() {
|
||||
int i = 0 ;
|
||||
bar(i);
|
||||
System.out.println(i);
|
||||
}
|
||||
|
||||
private static void bar(int i){}
|
||||
}
|
||||
}
|
||||
@@ -137,6 +137,10 @@ public class ExtractMethodObjectTest extends LightRefactoringTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testWithPrivateStaticMethodUsed2() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testWithPrivateMethodWhichCantBeMoved() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user