mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
show conflict on invert boolean and method references (IDEA-112572)
This commit is contained in:
@@ -33,6 +33,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.Query;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -69,6 +70,18 @@ public class InvertBooleanProcessor extends BaseRefactoringProcessor {
|
||||
|
||||
@Override
|
||||
protected boolean preprocessUsages(Ref<UsageInfo[]> refUsages) {
|
||||
final MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
|
||||
for (UsageInfo info : myToInvert.keySet()) {
|
||||
final PsiElement element = info.getElement();
|
||||
if (element instanceof PsiMethodReferenceExpression) {
|
||||
conflicts.putValue(element, "Method is used in method reference expression");
|
||||
}
|
||||
}
|
||||
|
||||
if (!conflicts.isEmpty()) {
|
||||
return showConflicts(conflicts, null);
|
||||
}
|
||||
|
||||
if (myRenameProcessor.preprocessUsages(refUsages)) {
|
||||
prepareSuccessful();
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
abstract class A{
|
||||
static boolean isB<caret>ool() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
interface I {
|
||||
boolean b();
|
||||
}
|
||||
|
||||
{
|
||||
I i = A::isBool;
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,15 @@ public class InvertBooleanTest extends LightRefactoringTestCase {
|
||||
|
||||
public void testInnerClasses() throws Exception {doTest();}
|
||||
public void testAnonymousClasses() throws Exception {doTest();}
|
||||
public void testMethodRefs() throws Exception {
|
||||
try {
|
||||
doTest();
|
||||
fail("Conflict expected.");
|
||||
}
|
||||
catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
|
||||
assertEquals("Method is used in method reference expression", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
configureByFile(TEST_ROOT + getTestName(true) + ".java");
|
||||
|
||||
Reference in New Issue
Block a user