mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: Fixed comparing potential matches when detecting duplicates of the extracted method (IDEA-182275)
This commit is contained in:
+1
-1
@@ -564,7 +564,7 @@ public class DuplicatesFinder {
|
||||
PsiElement child2 = children2[i];
|
||||
if (!matchPattern(child1, child2, candidates, match)) {
|
||||
matchedExtractablePart = matchExtractableExpression(child1, child2, candidates, match, true);
|
||||
return matchedExtractablePart != null && matchedExtractablePart;
|
||||
if (matchedExtractablePart == null || !matchedExtractablePart) return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
class WriteDifferentFieldsDuplicate {
|
||||
Runnable x;
|
||||
Runnable y;
|
||||
|
||||
private void foo() {
|
||||
<selection>
|
||||
if (x != null) {
|
||||
x.run();
|
||||
x = null;
|
||||
}</selection>
|
||||
|
||||
if (y != null) {
|
||||
y.run();
|
||||
y = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
class WriteDifferentFieldsDuplicate {
|
||||
Runnable x;
|
||||
Runnable y;
|
||||
|
||||
private void foo() {
|
||||
|
||||
newMethod();
|
||||
|
||||
if (y != null) {
|
||||
y.run();
|
||||
y = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void newMethod() {
|
||||
if (x != null) {
|
||||
x.run();
|
||||
x = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1177,6 +1177,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testWriteDifferentFieldsDuplicate() 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