Commit 219311f8 authored by Alexandr Suhinin's avatar Alexandr Suhinin Committed by intellij-monorepo-bot
Browse files

IDEA-262792 in-place extract method: keep new method name after duplicates extraction

(cherry picked from commit 6d52e885f5d42374a149ce074d4b1c9203d89b3e)

IJ-CR-6529

GitOrigin-RevId: 673652da04c8a2e75aadcfb08eedd13e7a6c704d
parent 3c6db5dc
Showing with 31 additions and 0 deletions
+31 -0
...@@ -410,10 +410,18 @@ public final class ParametrizedDuplicates { ...@@ -410,10 +410,18 @@ public final class ParametrizedDuplicates {
return myParametrizedMethod; return myParametrizedMethod;
} }
public void setParametrizedMethod(PsiMethod parametrizedMethod) {
myParametrizedMethod = parametrizedMethod;
}
PsiMethodCallExpression getParametrizedCall() { PsiMethodCallExpression getParametrizedCall() {
return myParametrizedCall; return myParametrizedCall;
} }
public void setParametrizedCall(PsiMethodCallExpression parametrizedCall) {
myParametrizedCall = parametrizedCall;
}
VariableData[] getVariableDatum() { VariableData[] getVariableDatum() {
return myVariableDatum; return myVariableDatum;
} }
......
...@@ -48,6 +48,9 @@ class LegacyMethodExtractor: InplaceExtractMethodProvider { ...@@ -48,6 +48,9 @@ class LegacyMethodExtractor: InplaceExtractMethodProvider {
val methodCall = findSingleMethodCall(method) ?: return val methodCall = findSingleMethodCall(method) ?: return
handler.extractedMethod = method handler.extractedMethod = method
handler.methodCall = methodCall handler.methodCall = methodCall
handler.methodName = method.name
handler.parametrizedDuplicates.setParametrizedMethod(method)
handler.parametrizedDuplicates.setParametrizedCall(methodCall)
DuplicatesImpl.processDuplicates(handler, project, editor) DuplicatesImpl.processDuplicates(handler, project, editor)
} }
......
class Test {
void test() {
<selection>System.out.println();</selection>
System.out.println();
}
}
\ No newline at end of file
class Test {
void test() {
renamed();
renamed();
}
private void renamed() {
System.out.println();
}
}
\ No newline at end of file
...@@ -52,6 +52,10 @@ class ExtractMethodInplaceTest: LightJavaCodeInsightTestCase() { ...@@ -52,6 +52,10 @@ class ExtractMethodInplaceTest: LightJavaCodeInsightTestCase() {
doTest() doTest()
} }
fun testRenamedExactDuplicate(){
doTest(changedName = "renamed")
}
private fun doTest(checkResults: Boolean = true, changedName: String? = null){ private fun doTest(checkResults: Boolean = true, changedName: String? = null){
templateTest { templateTest {
configureByFile("$BASE_PATH/${getTestName(false)}.java") configureByFile("$BASE_PATH/${getTestName(false)}.java")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment