IPP: refer to methods including parentheses () in intention text

GitOrigin-RevId: 2578135cbf75767e296f6bc48db3b5a56aa6acd1
This commit is contained in:
Bas Leijdekkers
2022-08-17 15:12:43 +02:00
committed by intellij-monorepo-bot
parent 807b88c707
commit 790d7872ae
4 changed files with 14 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
// "Make 'f' public" "true"
// "Make 'f()' public" "true"
import java.io.*;
class a {

View File

@@ -1,4 +1,4 @@
// "Make 'f' public" "true"
// "Make 'f()' public" "true"
import java.io.*;
class a {

View File

@@ -72,6 +72,7 @@ public class ChangeModifierIntention extends BaseElementAtCaretIntentionAction {
private AccessModifier myTarget;
// Necessary to register an extension
@SuppressWarnings("unused")
public ChangeModifierIntention() {
this(false);
}
@@ -91,11 +92,13 @@ public class ChangeModifierIntention extends BaseElementAtCaretIntentionAction {
if (modifiers.isEmpty()) return false;
if (!myErrorFix && !ContainerUtil.exists(modifiers, mod -> mod.hasModifier(member))) return false;
modifiers.removeIf(mod -> mod.hasModifier(member));
AccessModifier target = null;
if (modifiers.isEmpty()) return false;
AccessModifier target = null;
if (modifiers.size() == 1) {
target = modifiers.get(0);
setText(IntentionPowerPackBundle.message("change.modifier.text", identifier.getText(), target));
String name = identifier.getText();
if (member instanceof PsiMethod) name += "()";
setText(IntentionPowerPackBundle.message("change.modifier.text", name, target));
}
else {
setText(getFamilyName());

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.siyeh.ipp.modifiers;
import com.intellij.openapi.diagnostic.DefaultLogger;
@@ -24,16 +24,16 @@ public class ChangeModifierIntentionTest extends IPPTestCase {
public void testMyClass() { assertIntentionNotAvailable(); }
public void testMyInterface() { assertIntentionNotAvailable(); }
public void testMyInterfaceJava9() {
IdeaTestUtil.withLevel(myFixture.getModule(), LanguageLevel.JDK_1_9, () -> assertIntentionNotAvailable("Make 'm' private"));
IdeaTestUtil.withLevel(myFixture.getModule(), LanguageLevel.JDK_1_9, () -> assertIntentionNotAvailable("Make 'm()' private"));
}
public void testMyInterfaceDefaultJava9() {
IdeaTestUtil.withLevel(myFixture.getModule(), LanguageLevel.JDK_1_9, () -> doTest("Make 'm' private"));
IdeaTestUtil.withLevel(myFixture.getModule(), LanguageLevel.JDK_1_9, () -> doTest("Make 'm()' private"));
}
public void testMyInterfacePrivateJava9() {
IdeaTestUtil.withLevel(myFixture.getModule(), LanguageLevel.JDK_1_9, () -> doTest("Make 'm' public"));
IdeaTestUtil.withLevel(myFixture.getModule(), LanguageLevel.JDK_1_9, () -> doTest("Make 'm()' public"));
}
public void testMyInterfacePrivateStaticJava9() {
IdeaTestUtil.withLevel(myFixture.getModule(), LanguageLevel.JDK_1_9, () -> doTest("Make 'm' public"));
IdeaTestUtil.withLevel(myFixture.getModule(), LanguageLevel.JDK_1_9, () -> doTest("Make 'm()' public"));
}
public void testEnumConstructor() { assertIntentionNotAvailable(); }
public void testLocalClass() { assertIntentionNotAvailable(); }
@@ -43,7 +43,7 @@ public class ChangeModifierIntentionTest extends IPPTestCase {
public void testClass() { doTestWithChooser("protected"); }
public void testInDefaultPackage() { doTest("Make 'Test' package-private"); }
public void testInheritance() {
BaseRefactoringProcessor.ConflictsInTestsException.withIgnoredConflicts(() -> doTest("Make 'foo' public"));
BaseRefactoringProcessor.ConflictsInTestsException.withIgnoredConflicts(() -> doTest("Make 'foo()' public"));
}
public void testTypeParameter() {
@@ -68,7 +68,7 @@ public class ChangeModifierIntentionTest extends IPPTestCase {
}
public void testRecordConstructor1() {
IdeaTestUtil.withLevel(myFixture.getModule(), LanguageLevel.HIGHEST, () -> doTest("Make 'Foo' protected"));
IdeaTestUtil.withLevel(myFixture.getModule(), LanguageLevel.HIGHEST, () -> doTest("Make 'Foo()' protected"));
}
public void testRecordConstructor2() {