mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inplace introduce param: no need to correct caret position with or without conflict
This commit is contained in:
-3
@@ -166,16 +166,13 @@ public class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroduce
|
||||
public void run() {
|
||||
final Runnable performRefactoring = new Runnable() {
|
||||
public void run() {
|
||||
final boolean[] conflictsFound = new boolean[]{true};
|
||||
processor.setPrepareSuccessfulSwingThreadCallback(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
conflictsFound[0] = processor.hasConflicts();
|
||||
}
|
||||
});
|
||||
processor.run();
|
||||
normalizeParameterIdxAccordingToRemovedParams(parametersToRemove);
|
||||
InplaceIntroduceParameterPopup.super.moveOffsetAfter(!conflictsFound[0]);
|
||||
final PsiParameter parameter = getParameter();
|
||||
if (parameter != null) {
|
||||
InplaceIntroduceParameterPopup.super.saveSettings(parameter);
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class Test {
|
||||
|
||||
void foo(int p) {
|
||||
int i<caret>i = 4 + 2;
|
||||
//comment
|
||||
String var = "";
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class Test {
|
||||
|
||||
void foo() {
|
||||
int i<caret>i = 4 + 2;
|
||||
//comment
|
||||
String var = "";
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
|
||||
void foo(int ii) {
|
||||
<caret>//comment
|
||||
String var = "";
|
||||
}
|
||||
}
|
||||
@@ -91,9 +91,6 @@ public abstract class AbstractInplaceIntroduceTest extends LightCodeInsightTestC
|
||||
state.gotoEnd(false);
|
||||
checkResultByFile(getBasePath() + name + "_after.java");
|
||||
}
|
||||
catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
myEditor.getSettings().setVariableInplaceRenameEnabled(enabled);
|
||||
templateManager.setTemplateTesting(false);
|
||||
|
||||
@@ -65,6 +65,29 @@ public class InplaceIntroduceParameterTest extends AbstractInplaceIntroduceTest
|
||||
doTestEscape();
|
||||
}
|
||||
|
||||
public void testExtractParamOverLocal() throws Exception {
|
||||
doTest(new Pass<AbstractInplaceIntroducer>() {
|
||||
@Override
|
||||
public void pass(AbstractInplaceIntroducer abstractInplaceIntroducer) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testExtractConflictingParamOverLocal() throws Exception {
|
||||
try {
|
||||
doTest(new Pass<AbstractInplaceIntroducer>() {
|
||||
@Override
|
||||
public void pass(AbstractInplaceIntroducer abstractInplaceIntroducer) {
|
||||
type("p");
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
|
||||
assertEquals("There is already a parameter <b><code>p</code></b>. It will conflict with an introduced parameter", e.getMessage());
|
||||
return;
|
||||
}
|
||||
fail("Conflict expected");
|
||||
}
|
||||
|
||||
private static class MyIntroduceParameterHandler extends IntroduceParameterHandler implements MyIntroduceHandler {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user