provide fix all intention for local inspections paired to global tools (IDEA-162507)

This commit is contained in:
Anna.Kozlova
2016-10-18 10:30:52 +02:00
parent 0dbc270ac7
commit b815947ac2
4 changed files with 30 additions and 0 deletions
@@ -0,0 +1,8 @@
// "Fix all 'Member access can be tightened' problems in file" "true"
class Test {
private int myCounter;
public static void main(String[] args) {
System.out.println(new Test().myCounter);
}
}
@@ -0,0 +1,8 @@
// "Fix all 'Member access can be tightened' problems in file" "true"
class Test {
<caret>public int myCounter;
public static void main(String[] args) {
System.out.println(new Test().myCounter);
}
}
@@ -6,6 +6,9 @@ package com.intellij.codeInsight.daemon.quickFix;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.dataFlow.DataFlowInspection;
import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper;
import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.codeInspection.visibility.VisibilityInspection;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -18,6 +21,12 @@ public class FixAllQuickfixTest extends LightQuickFixParameterizedTestCase {
};
}
@Override
protected void setUp() throws Exception {
super.setUp();
enableInspectionTool(new GlobalInspectionToolWrapper(new VisibilityInspection()));
}
public void test() throws Exception { doAllTests(); }
@Override
@@ -189,6 +189,11 @@ public class IntentionManagerImpl extends IntentionManager implements Disposable
@Nullable
@Override
public IntentionAction createFixAllIntention(InspectionToolWrapper toolWrapper, IntentionAction action) {
if (toolWrapper instanceof GlobalInspectionToolWrapper) {
final LocalInspectionToolWrapper localWrapper = ((GlobalInspectionToolWrapper)toolWrapper).getSharedLocalInspectionToolWrapper();
if (localWrapper != null) return createFixAllIntention(localWrapper, action);
}
if (toolWrapper instanceof LocalInspectionToolWrapper) {
Class aClass = action.getClass();
if (action instanceof QuickFixWrapper) {