mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
IDEA-66266 (add/remove modifier quick fix to work on explicit ones only)
This commit is contained in:
@@ -54,6 +54,7 @@ public class ModifierFix extends IntentionAndQuickFixAction {
|
||||
myShouldHave = shouldHave;
|
||||
myShowContainingClass = showContainingClass;
|
||||
}
|
||||
|
||||
public ModifierFix(@NotNull PsiModifierListOwner owner, @Modifier @NotNull String modifier, boolean shouldHave, boolean showContainingClass) {
|
||||
this(owner.getModifierList(), modifier, shouldHave, showContainingClass);
|
||||
if (owner instanceof PsiVariable) {
|
||||
@@ -79,8 +80,9 @@ public class ModifierFix extends IntentionAndQuickFixAction {
|
||||
else if (parent instanceof PsiClassInitializer) {
|
||||
PsiClass containingClass = ((PsiClassInitializer)parent).getContainingClass();
|
||||
String className = containingClass instanceof PsiAnonymousClass
|
||||
? QuickFixBundle.message("anonymous.class.presentation", ((PsiAnonymousClass)containingClass).getBaseClassType().getPresentableText())
|
||||
: containingClass.getName();
|
||||
? QuickFixBundle.message("anonymous.class.presentation",
|
||||
((PsiAnonymousClass)containingClass).getBaseClassType().getPresentableText())
|
||||
: containingClass != null ? containingClass.getName() : "unknown";
|
||||
name = QuickFixBundle.message("class.initializer.presentation", className);
|
||||
}
|
||||
}
|
||||
@@ -99,7 +101,7 @@ public class ModifierFix extends IntentionAndQuickFixAction {
|
||||
return myModifierList != null &&
|
||||
myModifierList.isValid() &&
|
||||
myModifierList.getManager().isInProject(myModifierList) &&
|
||||
myModifierList.hasModifierProperty(myModifier) != myShouldHave &&
|
||||
myModifierList.hasExplicitModifier(myModifier) != myShouldHave &&
|
||||
(myVariable == null || myVariable.isValid());
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Make 'e' not final" "false"
|
||||
|
||||
class C {
|
||||
static {
|
||||
try {
|
||||
throw new Exception();
|
||||
}
|
||||
catch (RuntimeException | IOException e) {
|
||||
<caret>e = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Make 'r' not final" "false"
|
||||
|
||||
class C {
|
||||
void m() throws Exception {
|
||||
try (AutoCloseable r = null) {
|
||||
<caret>r = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// "Make 'e' final" "false"
|
||||
|
||||
class C {
|
||||
static {
|
||||
try {
|
||||
throw new Exception();
|
||||
}
|
||||
catch (RuntimeException | IOException e) {
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
System.out.println(<caret>e);
|
||||
}
|
||||
}.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// "Make 'r' final" "false"
|
||||
|
||||
class C {
|
||||
void m() throws Exception {
|
||||
try (AutoCloseable r = null) {
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
System.out.println(<caret>r);
|
||||
}
|
||||
}.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,4 +8,3 @@ public class ModifierTest extends LightQuickFixTestCase {
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/modifier";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user