mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: Preserve comments when extracting method with duplicates (IDEA-194463)
This commit is contained in:
+2
-2
@@ -57,8 +57,8 @@ public class ParametrizedDuplicates {
|
||||
|
||||
private ParametrizedDuplicates(@NotNull PsiElement[] pattern,
|
||||
@NotNull ExtractMethodProcessor originalProcessor) {
|
||||
pattern = getFilteredElements(pattern);
|
||||
PsiElement firstElement = pattern.length != 0 ? pattern[0] : null;
|
||||
PsiElement[] filteredPattern = getFilteredElements(pattern);
|
||||
PsiElement firstElement = filteredPattern.length != 0 ? filteredPattern[0] : null;
|
||||
if (firstElement instanceof PsiStatement) {
|
||||
PsiElement[] copy = copyElements(pattern);
|
||||
myElements = wrapWithCodeBlock(copy, originalProcessor.getInputVariables());
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
class C {
|
||||
void foo() {
|
||||
<selection>/*a*/ // b
|
||||
System.out.println(1);
|
||||
/*c*/ // d</selection>
|
||||
}
|
||||
|
||||
void bar() {
|
||||
/*x*/
|
||||
System.out.println(1);
|
||||
/*z*/
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
class C {
|
||||
void foo() {
|
||||
newMethod();
|
||||
}
|
||||
|
||||
private void newMethod() {
|
||||
/*a*/ // b
|
||||
System.out.println(1);
|
||||
/*c*/ // d
|
||||
}
|
||||
|
||||
void bar() {
|
||||
/*x*/
|
||||
newMethod();
|
||||
/*z*/
|
||||
}
|
||||
}
|
||||
@@ -1287,6 +1287,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
doDuplicatesTest();
|
||||
}
|
||||
|
||||
public void testDuplicatePreserveComments() throws Exception {
|
||||
doDuplicatesTest();
|
||||
}
|
||||
|
||||
public void testBeforeCommentAfterSelectedFragment() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user