mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
create subclass: restore caret position after delegate constructors are inserted (IDEA-105566)
This commit is contained in:
+1
-1
@@ -96,7 +96,7 @@ public class CreateConstructorMatchingSuperFix extends BaseIntentionAction {
|
||||
|
||||
LOG.assertTrue(constructors.length >=1); // Otherwise we won't have been messing with all this stuff
|
||||
boolean isCopyJavadoc = true;
|
||||
if (constructors.length > 1) {
|
||||
if (constructors.length > 1 && !ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
MemberChooser<PsiMethodMember> chooser = new MemberChooser<PsiMethodMember>(constructors, false, true, project);
|
||||
chooser.setTitle(QuickFixBundle.message("super.class.constructors.chooser.title"));
|
||||
chooser.show();
|
||||
|
||||
+3
-1
@@ -245,7 +245,7 @@ public class CreateSubclassAction extends BaseIntentionAction {
|
||||
}
|
||||
if (psiClass.hasTypeParameters() || includeClassName) {
|
||||
final Editor editor = CodeInsightUtil.positionCursor(project, targetClass.getContainingFile(), targetClass.getLBrace());
|
||||
final TemplateBuilderImpl templateBuilder = editor != null && !ApplicationManager.getApplication().isUnitTestMode()
|
||||
final TemplateBuilderImpl templateBuilder = editor != null
|
||||
? (TemplateBuilderImpl)TemplateBuilderFactory.getInstance().createTemplateBuilder(targetClass) : null;
|
||||
|
||||
if (includeClassName && templateBuilder != null) {
|
||||
@@ -319,9 +319,11 @@ public class CreateSubclassAction extends BaseIntentionAction {
|
||||
baseConstructors.add(new PsiMethodMember(baseConstr, substitutor));
|
||||
}
|
||||
}
|
||||
final int offset = editor.getCaretModel().getOffset();
|
||||
CreateConstructorMatchingSuperFix.chooseConstructor2Delegate(project, editor,
|
||||
substitutor,
|
||||
baseConstructors, constructors, targetClass);
|
||||
editor.getCaretModel().moveToOffset(offset);
|
||||
}
|
||||
|
||||
OverrideImplementUtil.chooseAndImplementMethods(project, editor, targetClass);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
public class Test {
|
||||
private interface Inner {}
|
||||
|
||||
public class InnerImpl implements Inner {
|
||||
}
|
||||
public class InnerImpl implements Inner { }
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
public class Test {
|
||||
private abstract class Inner {
|
||||
Inner(String s){}
|
||||
abstract void bar();
|
||||
}
|
||||
|
||||
public class InnerImpl extends Inner {
|
||||
InnerImpl(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
void bar() {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
public class Test {
|
||||
private abstract class Inner {
|
||||
Inner(String s){}
|
||||
abstract void bar();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.intellij.codeInsight.intention;
|
||||
|
||||
import com.intellij.codeInsight.intention.impl.CreateSubclassAction;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.search.ProjectScope;
|
||||
import com.intellij.refactoring.MultiFileTestCase;
|
||||
import com.intellij.codeInsight.intention.impl.CreateSubclassAction;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -14,8 +14,16 @@ public class CreateSubclassTest extends MultiFileTestCase {
|
||||
public void testGenerics() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testInnerClassImplement() throws Exception {
|
||||
doTestInner();
|
||||
}
|
||||
|
||||
public void testInnerClass() throws Exception {
|
||||
doTestInner();
|
||||
}
|
||||
|
||||
private void doTestInner() throws Exception {
|
||||
doTest(new PerformAction() {
|
||||
@Override
|
||||
public void performAction(final VirtualFile rootDir, final VirtualFile rootAfter) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user