mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extract method: do not suggest to replace duplicates if candidates intersects with extracted method
This commit is contained in:
@@ -164,7 +164,9 @@ public class DuplicatesFinder {
|
||||
|
||||
@Nullable
|
||||
private Match isDuplicateFragment(PsiElement candidate, boolean ignoreParameterTypes) {
|
||||
if (PsiTreeUtil.isAncestor(myPattern[0], candidate, false)) return null;
|
||||
for (PsiElement pattern : myPattern) {
|
||||
if (PsiTreeUtil.isAncestor(pattern, candidate, false)) return null;
|
||||
}
|
||||
PsiElement sibling = candidate;
|
||||
ArrayList<PsiElement> candidates = new ArrayList<PsiElement>();
|
||||
for (final PsiElement element : myPattern) {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
<selection>System.out.println("hello");
|
||||
System.out.println("hello");</selection>
|
||||
System.out.println("hello");
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
newMethod();
|
||||
System.out.println("hello");
|
||||
}
|
||||
|
||||
private static void newMethod() {
|
||||
System.out.println("hello");
|
||||
System.out.println("hello");
|
||||
}
|
||||
}
|
||||
@@ -561,7 +561,11 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
public void testFinalParams4LocalClasses() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
public void testTwoFromThreeEqStatements() throws Exception {
|
||||
doDuplicatesTest();
|
||||
}
|
||||
|
||||
private void doTestDisabledParam() throws PrepareFailedException {
|
||||
final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
|
||||
settings.ELSE_ON_NEW_LINE = true;
|
||||
|
||||
Reference in New Issue
Block a user