mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
IDEA-83600: pull up for local classes
This commit is contained in:
@@ -192,10 +192,14 @@ public class PullUpDialog extends RefactoringDialog {
|
||||
protected void doAction() {
|
||||
if (!myCallback.checkConflicts(this)) return;
|
||||
JavaRefactoringSettings.getInstance().PULL_UP_MEMBERS_JAVADOC = myJavaDocPanel.getPolicy();
|
||||
StatisticsManager
|
||||
.getInstance().incUseCount(new StatisticsInfo(PULL_UP_STATISTICS_KEY + myClass.getQualifiedName(), getSuperClass().getQualifiedName()));
|
||||
final PsiClass superClass = getSuperClass();
|
||||
String name = superClass.getQualifiedName();
|
||||
if (name != null) {
|
||||
StatisticsManager
|
||||
.getInstance().incUseCount(new StatisticsInfo(PULL_UP_STATISTICS_KEY + myClass.getQualifiedName(), name));
|
||||
}
|
||||
|
||||
invokeRefactoring(new PullUpHelper(myClass, getSuperClass(), getSelectedMemberInfos(),
|
||||
invokeRefactoring(new PullUpHelper(myClass, superClass, getSelectedMemberInfos(),
|
||||
new DocCommentPolicy(getJavaDocPolicy())));
|
||||
close(OK_EXIT_CODE);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
package com.intellij.refactoring.util;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.PsiElementProcessor;
|
||||
import com.intellij.psi.search.PsiElementProcessorAdapter;
|
||||
@@ -129,7 +130,13 @@ public class RefactoringHierarchyUtil {
|
||||
Collections.sort(
|
||||
basesList, new Comparator<PsiClass>() {
|
||||
public int compare(PsiClass c1, PsiClass c2) {
|
||||
return c1.getQualifiedName().compareTo(c2.getQualifiedName());
|
||||
final String fqn1 = c1.getQualifiedName();
|
||||
final String fqn2 = c2.getQualifiedName();
|
||||
if (fqn1 != null && fqn2 != null) return fqn1.compareTo(fqn2);
|
||||
if (fqn1 == null && fqn2 == null) {
|
||||
return Comparing.compare(c1.getName(), c2.getName());
|
||||
}
|
||||
return fqn1 == null ? 1 : -1;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// "Pull method 'foo' to 'Foo' and make it abstract" "true"
|
||||
public class Test {
|
||||
void bar() {
|
||||
abstract class Foo {
|
||||
abstract void foo();
|
||||
}
|
||||
class FooImpl extends Foo {
|
||||
@Override
|
||||
void foo(){}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Pull method 'foo' to 'Foo' and make it abstract" "true"
|
||||
public class Test {
|
||||
void bar() {
|
||||
class Foo {}
|
||||
class FooImpl extends Foo {
|
||||
@Overr<caret>ide
|
||||
void foo(){}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,10 @@ public class PullOverrideMethodUpFixTest extends LightQuickFixTestCase {
|
||||
doSingleTest("4.java");
|
||||
}
|
||||
|
||||
public void test6() throws Exception {
|
||||
doSingleTest("6.java");
|
||||
}
|
||||
|
||||
public void testRefactoringIntentionsAvailable() throws Exception {
|
||||
doTestActionAvailable(5, "Pull members up");
|
||||
doTestActionAvailable(5, "Extract interface");
|
||||
|
||||
Reference in New Issue
Block a user