mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
invert boolean for anonymous classes (IDEA-71076)
This commit is contained in:
+6
-2
@@ -110,8 +110,12 @@ public class InvertBooleanProcessor extends BaseRefactoringProcessor {
|
||||
final Query<PsiReference> methodQuery = MethodReferencesSearch.search(method);
|
||||
final Collection<PsiReference> methodRefs = methodQuery.findAll();
|
||||
for (PsiReference ref : methodRefs) {
|
||||
if (ref.getElement().getParent() instanceof PsiCall) {
|
||||
final PsiCall call = (PsiCall)ref.getElement().getParent();
|
||||
PsiElement parent = ref.getElement().getParent();
|
||||
if (parent instanceof PsiAnonymousClass) {
|
||||
parent = parent.getParent();
|
||||
}
|
||||
if (parent instanceof PsiCall) {
|
||||
final PsiCall call = (PsiCall)parent;
|
||||
final PsiReferenceExpression methodExpression = call instanceof PsiMethodCallExpression ?
|
||||
((PsiMethodCallExpression)call).getMethodExpression() :
|
||||
null;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
abstract class DemoInvertBoolean {
|
||||
|
||||
boolean b;
|
||||
|
||||
DemoInvertBoolean(boolean <caret>b) {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
DemoInvertBoolean() {
|
||||
this(true);//this true will be inverted
|
||||
}
|
||||
|
||||
abstract void f1();
|
||||
|
||||
public static void main(String[] args) {
|
||||
DemoInvertBoolean demo = new DemoInvertBoolean(true) {//this true will not be inverted
|
||||
@Override
|
||||
public void f1() {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
abstract class DemoInvertBoolean {
|
||||
|
||||
boolean b;
|
||||
|
||||
DemoInvertBoolean(boolean <caret>bInverted) {
|
||||
this.b = !bInverted;
|
||||
}
|
||||
|
||||
DemoInvertBoolean() {
|
||||
this(false);//this true will be inverted
|
||||
}
|
||||
|
||||
abstract void f1();
|
||||
|
||||
public static void main(String[] args) {
|
||||
DemoInvertBoolean demo = new DemoInvertBoolean(false) {//this true will not be inverted
|
||||
@Override
|
||||
public void f1() {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ public class InvertBooleanTest extends LightCodeInsightTestCase {
|
||||
public void testUnusedReturnValue() throws Exception { doTest(); }
|
||||
|
||||
public void testInnerClasses() throws Exception {doTest();}
|
||||
public void testAnonymousClasses() throws Exception {doTest();}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
configureByFile(TEST_ROOT + getTestName(true) + ".java");
|
||||
|
||||
Reference in New Issue
Block a user