diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/DummyEntryPointsTool.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/DummyEntryPointsTool.java index fcf375fd9194..524f3338fad1 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deadCode/DummyEntryPointsTool.java +++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/DummyEntryPointsTool.java @@ -19,11 +19,13 @@ import com.intellij.analysis.AnalysisScope; import com.intellij.codeInspection.GlobalInspectionContext; import com.intellij.codeInspection.InspectionManager; import com.intellij.codeInspection.InspectionsBundle; +import com.intellij.codeInspection.ProblemDescriptionsProcessor; import com.intellij.codeInspection.ex.InspectionPresentationProvider; import com.intellij.codeInspection.ex.InspectionToolWrapper; import com.intellij.codeInspection.ex.JobDescriptor; import com.intellij.codeInspection.ui.InspectionToolPresentation; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author max @@ -33,11 +35,15 @@ public class DummyEntryPointsTool extends UnusedDeclarationInspection implements } @Override - public void runInspection(@NotNull AnalysisScope scope, @NotNull final InspectionManager manager) {} + public void runInspection(@NotNull AnalysisScope scope, + @NotNull InspectionManager manager, + @NotNull GlobalInspectionContext globalContext, + @NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor) { + } + @Nullable @Override - @NotNull - public JobDescriptor[] getJobDescriptors(@NotNull GlobalInspectionContext globalInspectionContext) { + public JobDescriptor[] getAdditionalJobs() { return JobDescriptor.EMPTY_ARRAY; } diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java index 9e2ca63a6585..7799cc205f67 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java @@ -64,7 +64,7 @@ import java.awt.event.ActionListener; import java.util.*; import java.util.List; -public class UnusedDeclarationInspection extends InspectionTool implements InspectionPresentationProvider { +public class UnusedDeclarationInspection extends GlobalInspectionTool implements InspectionPresentationProvider { public boolean ADD_MAINS_TO_ENTRIES = true; public boolean ADD_APPLET_TO_ENTRIES = true; @@ -79,6 +79,7 @@ public class UnusedDeclarationInspection extends InspectionTool implements Inspe public final EntryPoint[] myExtensions; private static final Logger LOG = Logger.getInstance("#" + UnusedDeclarationInspection.class.getName()); + private GlobalInspectionContextImpl myContext; public UnusedDeclarationInspection() { ExtensionPoint point = Extensions.getRootArea().getExtensionPoint(ExtensionPoints.DEAD_CODE_TOOL); @@ -336,8 +337,11 @@ public class UnusedDeclarationInspection extends InspectionTool implements Inspe } @Override - public void runInspection(@NotNull final AnalysisScope scope, @NotNull final InspectionManager manager) { - getContext().getRefManager().iterate(new RefJavaVisitor() { + public void runInspection(@NotNull final AnalysisScope scope, + @NotNull InspectionManager manager, + @NotNull final GlobalInspectionContext globalContext, + @NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor) { + globalContext.getRefManager().iterate(new RefJavaVisitor() { @Override public void visitElement(@NotNull final RefEntity refEntity) { if (refEntity instanceof RefJavaElement) { @@ -348,7 +352,7 @@ public class UnusedDeclarationInspection extends InspectionTool implements Inspe if (file == null) return; final boolean isSuppressed = refElement.isSuppressed(getShortName(), ALTERNATIVE_ID); - if (!getContext().isToCheckFile(file, UnusedDeclarationInspection.this) || isSuppressed) { + if (!((GlobalInspectionContextImpl)globalContext).isToCheckFile(file, UnusedDeclarationInspection.this) || isSuppressed) { if (isSuppressed || !scope.contains(file)) { getEntryPointsManager().addEntryPoint(refElement, false); } @@ -377,12 +381,13 @@ public class UnusedDeclarationInspection extends InspectionTool implements Inspe if (isAddNonJavaUsedEnabled()) { checkForReachables(); - final StrictUnreferencedFilter strictUnreferencedFilter = new StrictUnreferencedFilter(this, myContext); + final StrictUnreferencedFilter strictUnreferencedFilter = new StrictUnreferencedFilter(this, + (GlobalInspectionContextImpl)globalContext); ProgressManager.getInstance().runProcess(new Runnable() { @Override public void run() { - final PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(getContext().getRefManager().getProject()); - getContext().getRefManager().iterate(new RefJavaVisitor() { + final PsiSearchHelper helper = PsiSearchHelper.SERVICE.getInstance(globalContext.getRefManager().getProject()); + globalContext.getRefManager().iterate(new RefJavaVisitor() { @Override public void visitElement(@NotNull final RefEntity refEntity) { if (refEntity instanceof RefClass && strictUnreferencedFilter.accepts((RefClass)refEntity)) { @@ -408,7 +413,7 @@ public class UnusedDeclarationInspection extends InspectionTool implements Inspe return false; } }, - GlobalSearchScope.projectScope(getContext().getProject())); + GlobalSearchScope.projectScope(globalContext.getProject())); } } }); @@ -501,12 +506,15 @@ public class UnusedDeclarationInspection extends InspectionTool implements Inspe } @Override - public boolean queryExternalUsagesRequests(@NotNull final InspectionManager manager) { + public boolean queryExternalUsagesRequests(@NotNull InspectionManager manager, + @NotNull GlobalInspectionContext globalContext, + @NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor) { checkForReachables(); - final RefFilter filter = myPhase == 1 ? new StrictUnreferencedFilter(this, getContext()) : new RefUnreachableFilter(this, getContext()); + final RefFilter filter = myPhase == 1 ? new StrictUnreferencedFilter(this, (GlobalInspectionContextImpl)globalContext) : + new RefUnreachableFilter(this, (GlobalInspectionContextImpl)globalContext); final boolean[] requestAdded = {false}; - getContext().getRefManager().iterate(new RefJavaVisitor() { + globalContext.getRefManager().iterate(new RefJavaVisitor() { @Override public void visitElement(@NotNull RefEntity refEntity) { if (!(refEntity instanceof RefJavaElement)) return; @@ -621,12 +629,10 @@ public class UnusedDeclarationInspection extends InspectionTool implements Inspe return getContext().getExtension(GlobalJavaInspectionContext.CONTEXT); } - - @NotNull + @Nullable @Override - public JobDescriptor[] getJobDescriptors(@NotNull GlobalInspectionContext context) { - return new JobDescriptor[]{context.getStdJobDescriptors().BUILD_GRAPH, - context.getStdJobDescriptors().FIND_EXTERNAL_USAGES}; + public JobDescriptor[] getAdditionalJobs() { + return new JobDescriptor[]{getContext().getStdJobDescriptors().BUILD_GRAPH, getContext().getStdJobDescriptors().FIND_EXTERNAL_USAGES}; } @@ -792,10 +798,21 @@ public class UnusedDeclarationInspection extends InspectionTool implements Inspe @NotNull @Override public InspectionToolPresentation createPresentation(@NotNull InspectionToolWrapper toolWrapper) { - myContext = (GlobalInspectionContextImpl)toolWrapper.getContext(); return new UnusedDeclarationPresentation(toolWrapper); } + @Override + public void initialize(@NotNull GlobalInspectionContext context) { + super.initialize(context); + myContext = (GlobalInspectionContextImpl)context; + } + + @Override + public void cleanup() { + super.cleanup(); + myContext = null; + } + @Override public boolean isGraphNeeded() { return true; diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java index 4602c3f09755..a4d649ce0b8e 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java +++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java @@ -320,7 +320,7 @@ public class UnusedDeclarationPresentation extends DefaultInspectionToolPresenta @NotNull InspectionRVContentProvider provider, @NotNull InspectionTreeNode parentNode, boolean showStructure) { - final EntryPointsNode entryPointsNode = new EntryPointsNode(getTool(), context); + final EntryPointsNode entryPointsNode = new EntryPointsNode(context); InspectionToolWrapper dummyToolWrapper = entryPointsNode.getToolWrapper(); InspectionToolPresentation presentation = context.getPresentation(dummyToolWrapper); presentation.updateContent(); diff --git a/java/java-impl/src/com/intellij/codeInspection/ex/GlobalJavaInspectionContextImpl.java b/java/java-impl/src/com/intellij/codeInspection/ex/GlobalJavaInspectionContextImpl.java index 6cd6599e452b..cd706652c019 100644 --- a/java/java-impl/src/com/intellij/codeInspection/ex/GlobalJavaInspectionContextImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/ex/GlobalJavaInspectionContextImpl.java @@ -23,6 +23,7 @@ package com.intellij.codeInspection.ex; import com.intellij.CommonBundle; import com.intellij.analysis.AnalysisScope; import com.intellij.codeInspection.*; +import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; import com.intellij.codeInspection.reference.*; import com.intellij.codeInspection.ui.InspectionToolPresentation; import com.intellij.lang.StdLanguages; @@ -101,7 +102,7 @@ public class GlobalJavaInspectionContextImpl extends GlobalJavaInspectionContext } @SuppressWarnings({"UseOfSystemOutOrSystemErr"}) - public static boolean isInspectionsEnabled(final boolean online, Project project) { + public static boolean isInspectionsEnabled(final boolean online, @NotNull Project project) { final Module[] modules = ModuleManager.getInstance(project).getModules(); if (online) { if (modules.length == 0) { @@ -417,6 +418,14 @@ public class GlobalJavaInspectionContextImpl extends GlobalJavaInspectionContext @NotNull final List localTools, @NotNull final GlobalInspectionContext context) { getEntryPointsManager(context.getRefManager()).resolveEntryPoints(context.getRefManager()); + // UnusedDeclarationInspection should run first + for (int i = 0; i < globalTools.size(); i++) { + InspectionToolWrapper toolWrapper = globalTools.get(i).getTool(); + if (UnusedDeclarationInspection.SHORT_NAME.equals(toolWrapper.getShortName())) { + Collections.swap(globalTools, i, 0); + break; + } + } } @@ -436,9 +445,6 @@ public class GlobalJavaInspectionContextImpl extends GlobalJavaInspectionContext InspectionToolPresentation presentation = ((GlobalInspectionContextImpl)context).getPresentation(toolWrapper); result = ((GlobalInspectionToolWrapper)toolWrapper).getTool().queryExternalUsagesRequests(inspectionManager, context, presentation); } - else if (toolWrapper instanceof CommonInspectionToolWrapper) { - result = ((CommonInspectionToolWrapper)toolWrapper).getTool().queryExternalUsagesRequests(inspectionManager); - } if (!result) { needRepeatSearchRequest.remove(toolWrapper); } diff --git a/java/java-impl/src/com/intellij/codeInspection/ui/EntryPointsNode.java b/java/java-impl/src/com/intellij/codeInspection/ui/EntryPointsNode.java index 78db5438a869..7363d43c104b 100644 --- a/java/java-impl/src/com/intellij/codeInspection/ui/EntryPointsNode.java +++ b/java/java-impl/src/com/intellij/codeInspection/ui/EntryPointsNode.java @@ -16,9 +16,9 @@ package com.intellij.codeInspection.ui; import com.intellij.codeInspection.deadCode.DummyEntryPointsTool; -import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; -import com.intellij.codeInspection.ex.CommonInspectionToolWrapper; import com.intellij.codeInspection.ex.GlobalInspectionContextImpl; +import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper; +import com.intellij.codeInspection.ex.InspectionToolWrapper; import com.intellij.icons.AllIcons; import org.jetbrains.annotations.NotNull; @@ -28,14 +28,14 @@ import javax.swing.*; * @author max */ public class EntryPointsNode extends InspectionNode { - public EntryPointsNode(@NotNull UnusedDeclarationInspection tool, @NotNull GlobalInspectionContextImpl context) { - super(createDummyWrapper(tool, context)); + public EntryPointsNode(@NotNull GlobalInspectionContextImpl context) { + super(createDummyWrapper(context)); } - private static CommonInspectionToolWrapper createDummyWrapper(UnusedDeclarationInspection tool, GlobalInspectionContextImpl context) { - CommonInspectionToolWrapper wrapper = new CommonInspectionToolWrapper(new DummyEntryPointsTool()); - wrapper.initialize(context); - return wrapper; + private static InspectionToolWrapper createDummyWrapper(@NotNull GlobalInspectionContextImpl context) { + InspectionToolWrapper toolWrapper = new GlobalInspectionToolWrapper(new DummyEntryPointsTool()); + toolWrapper.initialize(context); + return toolWrapper; } @Override diff --git a/java/java-impl/src/com/intellij/profile/codeInspection/JavaAwareInspectionProfileManager.java b/java/java-impl/src/com/intellij/profile/codeInspection/JavaAwareInspectionProfileManager.java index e0cb4a029538..e1d50a769090 100644 --- a/java/java-impl/src/com/intellij/profile/codeInspection/JavaAwareInspectionProfileManager.java +++ b/java/java-impl/src/com/intellij/profile/codeInspection/JavaAwareInspectionProfileManager.java @@ -23,12 +23,11 @@ package com.intellij.profile.codeInspection; import com.intellij.codeInsight.daemon.InspectionProfileConvertor; import com.intellij.codeInsight.daemon.JavaAwareInspectionProfileCoverter; import com.intellij.codeInspection.ex.InspectionToolRegistrar; -import com.intellij.codeInspection.ex.SpecialToolsManager; import com.intellij.openapi.options.SchemesManagerFactory; public class JavaAwareInspectionProfileManager extends InspectionProfileManagerImpl { - public JavaAwareInspectionProfileManager(InspectionToolRegistrar registrar, SchemesManagerFactory schemesManagerFactory, SpecialToolsManager specialToolsManager) { - super(registrar, schemesManagerFactory,specialToolsManager); + public JavaAwareInspectionProfileManager(InspectionToolRegistrar registrar, SchemesManagerFactory schemesManagerFactory) { + super(registrar, schemesManagerFactory); } @Override diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/GlobalInspectionContextTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/GlobalInspectionContextTest.java index babdcff488a0..2cdf8a2de416 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/GlobalInspectionContextTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/GlobalInspectionContextTest.java @@ -22,6 +22,7 @@ import com.intellij.codeInspection.actions.RunInspectionIntention; import com.intellij.codeInspection.ex.*; import com.intellij.codeInspection.ui.InspectionToolPresentation; import com.intellij.codeInspection.visibility.VisibilityInspection; +import com.intellij.psi.PsiFile; import java.util.ArrayList; import java.util.Arrays; @@ -43,14 +44,14 @@ public class GlobalInspectionContextTest extends CodeInsightTestCase { configureByFile("Foo.java"); AnalysisScope scope = new AnalysisScope(getFile()); - context.doInspections(scope, InspectionManager.getInstance(getProject())); + context.doInspections(scope); Tools tools = context.getTools().get(shortName); GlobalInspectionToolWrapper toolWrapper = (GlobalInspectionToolWrapper)tools.getTool(); InspectionToolPresentation presentation = context.getPresentation(toolWrapper); assertEquals(1, presentation.getProblemDescriptors().size()); - context.doInspections(scope, InspectionManager.getInstance(getProject())); + context.doInspections(scope); tools = context.getTools().get(shortName); toolWrapper = (GlobalInspectionToolWrapper)tools.getTool(); presentation = context.getPresentation(toolWrapper); @@ -60,11 +61,12 @@ public class GlobalInspectionContextTest extends CodeInsightTestCase { public void testRunInspectionContext() throws Exception { InspectionProfile profile = new InspectionProfileImpl("foo"); InspectionToolWrapper[] tools = profile.getInspectionTools(null); + PsiFile file = createDummyFile("xx.txt", "xxx"); for (InspectionToolWrapper toolWrapper : tools) { if (!toolWrapper.isEnabledByDefault()) { InspectionManagerEx instance = (InspectionManagerEx)InspectionManager.getInstance(myProject); - GlobalInspectionContextImpl context = RunInspectionIntention.createContext(toolWrapper, instance, null); - context.initializeTools(new ArrayList(), new ArrayList(), new ArrayList(), new ArrayList()); + GlobalInspectionContextImpl context = RunInspectionIntention.createContext(toolWrapper, instance, file); + context.initializeTools(new ArrayList(), new ArrayList(), new ArrayList()); assertEquals(1, context.getTools().size()); return; } diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java index d0276c2fc3d0..ed2db874ef46 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/InspectionProfileTest.java @@ -266,7 +266,7 @@ public class InspectionProfileTest extends LightIdeaTestCase { GlobalInspectionContextImpl context = ((InspectionManagerEx)InspectionManager.getInstance(getProject())).createNewGlobalContext(false); context.setExternalProfile(profile); - context.initializeTools(new ArrayList(), new ArrayList(), new ArrayList(), new ArrayList()); + context.initializeTools(new ArrayList(), new ArrayList(), new ArrayList()); } public void testInspectionsInitialization() throws Exception { diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/UnusedDeclarationTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/UnusedDeclarationTest.java index 452083ed507f..10604a1f1965 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/UnusedDeclarationTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/UnusedDeclarationTest.java @@ -17,8 +17,8 @@ package com.intellij.codeInspection; import com.intellij.JavaTestUtil; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; -import com.intellij.codeInspection.ex.CommonInspectionToolWrapper; import com.intellij.codeInspection.ex.EntryPointsManagerImpl; +import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper; import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.pom.java.LanguageLevel; import com.intellij.testFramework.InspectionTestCase; @@ -41,7 +41,7 @@ public class UnusedDeclarationTest extends InspectionTestCase { } private void doTest() { - doTest("deadCode/" + getTestName(true), new CommonInspectionToolWrapper(myTool)); + doTest("deadCode/" + getTestName(true), new GlobalInspectionToolWrapper(myTool)); } public void testSCR6067() { diff --git a/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java b/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java index 6deb5a411ae2..6d648780d0ed 100644 --- a/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java @@ -194,7 +194,7 @@ public abstract class DaemonAnalyzerTestCase extends CodeInsightTestCase { } protected void enableInspectionTool(@NotNull InspectionProfileEntry tool){ - InspectionToolWrapper toolWrapper = tool instanceof InspectionTool ? new CommonInspectionToolWrapper((InspectionTool)tool) : InspectionToolRegistrar.wrapTool(tool); + InspectionToolWrapper toolWrapper = InspectionToolRegistrar.wrapTool(tool); final String shortName = toolWrapper.getShortName(); final HighlightDisplayKey key = HighlightDisplayKey.find(shortName); if (key == null) { diff --git a/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java b/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java index 63e979249af4..bfeac047278e 100644 --- a/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java +++ b/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java @@ -132,7 +132,7 @@ public abstract class InspectionTestCase extends PsiTestCase { AnalysisScope scope = createAnalysisScope(sourceDir[0].getParent()); InspectionManagerEx inspectionManager = (InspectionManagerEx)InspectionManager.getInstance(getProject()); - InspectionToolWrapper[] toolWrappers = runDeadCodeFirst ? new InspectionToolWrapper []{new CommonInspectionToolWrapper(new UnusedDeclarationInspection()), toolWrapper} : new InspectionToolWrapper []{toolWrapper}; + InspectionToolWrapper[] toolWrappers = runDeadCodeFirst ? new InspectionToolWrapper []{new GlobalInspectionToolWrapper(new UnusedDeclarationInspection()), toolWrapper} : new InspectionToolWrapper []{toolWrapper}; toolWrappers = ArrayUtil.mergeArrays(toolWrappers, additional); final GlobalInspectionContextImpl globalContext = CodeInsightTestFixtureImpl.createGlobalContextForTool(scope, getProject(), inspectionManager, toolWrappers); @@ -140,6 +140,7 @@ public abstract class InspectionTestCase extends PsiTestCase { InspectionTestUtil.runTool(toolWrapper, scope, globalContext, inspectionManager); } + @NotNull protected AnalysisScope createAnalysisScope(VirtualFile sourceDir) { PsiManager psiManager = PsiManager.getInstance(myProject); return new AnalysisScope(psiManager.findDirectory(sourceDir)); diff --git a/platform/analysis-api/src/com/intellij/codeInspection/GlobalInspectionTool.java b/platform/analysis-api/src/com/intellij/codeInspection/GlobalInspectionTool.java index 807eca1ffb04..5e72c932b71c 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/GlobalInspectionTool.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/GlobalInspectionTool.java @@ -197,4 +197,7 @@ public abstract class GlobalInspectionTool extends InspectionProfileEntry { public boolean worksInBatchModeOnly() { return true; } + + public void initialize(@NotNull GlobalInspectionContext context) { + } } diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java index 36264656690f..5fb8e9442308 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java @@ -54,6 +54,7 @@ public class GlobalInspectionToolWrapper extends InspectionToolWrapper allWrappers = new LinkedHashSet(); allWrappers.add(toolWrapper); @@ -109,14 +114,16 @@ public class RunInspectionIntention implements IntentionAction, HighPriorityActi final InspectionProfileImpl model = InspectionProfileImpl.createSimple(toolWrapper.getDisplayName(), managerEx.getProject(), toolWrappers); try { Element element = new Element("toCopy"); - - for (InspectionToolWrapper wrapper : allWrappers) { + for (InspectionToolWrapper wrapper : toolWrappers) { wrapper.getTool().writeSettings(element); - model.getInspectionTool(wrapper.getShortName(), psiElement).getTool().readSettings(element); + InspectionToolWrapper tw = psiElement == null ? model.getInspectionTool(wrapper.getShortName(), managerEx.getProject()) + : model.getInspectionTool(wrapper.getShortName(), psiElement); + tw.getTool().readSettings(element); } } - catch (Exception e) { - //skip + catch (WriteExternalException ignored) { + } + catch (InvalidDataException ignored) { } model.setEditable(toolWrapper.getDisplayName()); final GlobalInspectionContextImpl inspectionContext = managerEx.createNewGlobalContext(false); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/actions/ViewOfflineResultsAction.java b/platform/lang-impl/src/com/intellij/codeInspection/actions/ViewOfflineResultsAction.java index d3a484878117..82eb30685183 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/actions/ViewOfflineResultsAction.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/actions/ViewOfflineResultsAction.java @@ -221,7 +221,7 @@ public class ViewOfflineResultsAction extends AnAction implements DumbAware { final GlobalInspectionContextImpl context = managerEx.createNewGlobalContext(false); context.setExternalProfile(inspectionProfile); context.setCurrentScope(scope); - context.initializeTools(new ArrayList(), new ArrayList(), new ArrayList(), new ArrayList()); + context.initializeTools(new ArrayList(), new ArrayList(), new ArrayList()); final InspectionResultsView view = new InspectionResultsView(project, inspectionProfile, scope, context, new OfflineInspectionRVContentProvider(resMap, project)); ((RefManagerImpl)context.getRefManager()).inspectionReadActionStarted(); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/CommonInspectionToolWrapper.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/CommonInspectionToolWrapper.java deleted file mode 100644 index 95d7ccca0aaf..000000000000 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/CommonInspectionToolWrapper.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.codeInspection.ex; - -import com.intellij.codeInspection.GlobalInspectionContext; -import com.intellij.codeInspection.InspectionEP; -import org.jetbrains.annotations.NotNull; - -public class CommonInspectionToolWrapper extends InspectionToolWrapper { - public CommonInspectionToolWrapper(@NotNull InspectionEP ep) { - super(ep); - } - - public CommonInspectionToolWrapper(@NotNull InspectionTool tool) { - super(tool); - } - - private CommonInspectionToolWrapper(@NotNull CommonInspectionToolWrapper other) { - super(other); - } - - @NotNull - @Override - public CommonInspectionToolWrapper createCopy() { - return new CommonInspectionToolWrapper(this); - } - - @NotNull - @Override - public JobDescriptor[] getJobDescriptors(@NotNull GlobalInspectionContext context) { - return getTool().getJobDescriptors(context); - } - - @Override - public void initialize(@NotNull GlobalInspectionContext context) { - super.initialize(context); - getTool().initialize(context); - } -} diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java index 51cca6a2a0c6..badab0027db4 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java @@ -110,7 +110,6 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G private InspectionProfile myExternalProfile = null; private final Map myExtensions = new HashMap(); - private boolean RUN_GLOBAL_TOOLS_ONLY = false; private final Map myTools = new THashMap(); @@ -119,7 +118,7 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G private boolean myUseProgressIndicatorInTests = false; - public GlobalInspectionContextImpl(Project project, NotNullLazyValue contentManager) { + public GlobalInspectionContextImpl(@NotNull Project project, @NotNull NotNullLazyValue contentManager) { myProject = project; myUIOptions = AnalysisUIOptions.getInstance(myProject).copy(); @@ -151,9 +150,10 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G if (myExternalProfile != null) return myExternalProfile; InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(myProject); final InspectionProjectProfileManager inspectionProfileManager = InspectionProjectProfileManager.getInstance(myProject); - Profile profile = inspectionProfileManager.getProfile(managerEx.getCurrentProfile(), false); + String currentProfile = managerEx.getCurrentProfile(); + Profile profile = inspectionProfileManager.getProfile(currentProfile, false); if (profile == null) { - profile = InspectionProfileManager.getInstance().getProfile(managerEx.getCurrentProfile()); + profile = InspectionProfileManager.getInstance().getProfile(currentProfile); if (profile != null) return (InspectionProfile)profile; final String[] availableProfileNames = inspectionProfileManager.getAvailableProfileNames(); @@ -239,7 +239,7 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G } - private void cleanup() { + private void cleanupTools() { myProgressIndicator = null; for (GlobalInspectionContextExtension extension : myExtensions.values()) { @@ -266,14 +266,14 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G } } - public void setCurrentScope(AnalysisScope currentScope) { + public void setCurrentScope(@NotNull AnalysisScope currentScope) { myCurrentScope = currentScope; } - public void doInspections(@NotNull final AnalysisScope scope, @NotNull final InspectionManager manager) { + public void doInspections(@NotNull final AnalysisScope scope) { if (!InspectionManagerEx.canRunInspections(myProject, true)) return; - cleanup(); + cleanupTools(); if (myContent != null) { getContentManager().removeContent(myContent, true); } @@ -282,7 +282,7 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G @Override public void run() { myCurrentScope = scope; - launchInspections(scope, manager); + launchInspections(scope); } }; @@ -312,19 +312,16 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G public void launchInspectionsOffline(final AnalysisScope scope, @Nullable final String outputPath, final boolean runGlobalToolsOnly, - final InspectionManager manager, @NotNull final List inspectionsResults) { - cleanup(); + cleanupTools(); myCurrentScope = scope; DefaultInspectionToolPresentation.setOutputPath(outputPath); - final boolean oldToolsSettings = RUN_GLOBAL_TOOLS_ONLY; - RUN_GLOBAL_TOOLS_ONLY = runGlobalToolsOnly; try { ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { - performInspectionsWithProgress(scope, manager); + performInspectionsWithProgress(scope, runGlobalToolsOnly); @NonNls final String ext = ".xml"; final Map globalTools = new HashMap(); for (Map.Entry stringSetEntry : myTools.entrySet()) { @@ -407,7 +404,6 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G } finally { DefaultInspectionToolPresentation.setOutputPath(null); - RUN_GLOBAL_TOOLS_ONLY = oldToolsSettings; } } @@ -473,7 +469,7 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G return myUIOptions.getAutoScrollToSourceHandler().createToggleAction(); } - private void launchInspections(@NotNull final AnalysisScope scope, @NotNull final InspectionManager manager) { + private void launchInspections(@NotNull final AnalysisScope scope) { myUIOptions = AnalysisUIOptions.getInstance(myProject).copy(); PsiDocumentManager.getInstance(myProject).commitAllDocuments(); @@ -483,7 +479,7 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G new PerformAnalysisInBackgroundOption(myProject)) { @Override public void run(@NotNull ProgressIndicator indicator) { - performInspectionsWithProgress(scope, manager); + performInspectionsWithProgress(scope, false); } @Override @@ -514,7 +510,7 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G }); } - private void performInspectionsWithProgress(@NotNull final AnalysisScope scope, @NotNull final InspectionManager manager) { + private void performInspectionsWithProgress(@NotNull final AnalysisScope scope, final boolean runGlobalToolsOnly) { final PsiManager psiManager = PsiManager.getInstance(myProject); myProgressIndicator = getProgressIndicator(); //init manager in read action @@ -529,16 +525,16 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G ((ProgressManagerImpl)ProgressManager.getInstance()).executeProcessUnderProgress(new Runnable() { @Override public void run() { - runTools(scope, manager); + runTools(scope, runGlobalToolsOnly); } }, ProgressWrapper.wrap(myProgressIndicator)); } catch (ProcessCanceledException e) { - cleanup((InspectionManagerEx)manager); + cleanup(); throw e; } catch (IndexNotReadyException e) { - cleanup((InspectionManagerEx)manager); + cleanup(); DumbService.getInstance(myProject).showDumbModeNotification("Usage search is not available until indices are ready"); throw new ProcessCanceledException(); } @@ -561,39 +557,14 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G myUseProgressIndicatorInTests = useProgressIndicatorInTests; } - private void runTools(@NotNull AnalysisScope scope, @NotNull final InspectionManager manager) { + private void runTools(@NotNull AnalysisScope scope, boolean runGlobalToolsOnly) { + final InspectionManagerEx inspectionManager = (InspectionManagerEx)InspectionManager.getInstance(myProject); List globalTools = new ArrayList(); final List localTools = new ArrayList(); final List globalSimpleTools = new ArrayList(); - List specialTools = new ArrayList(); - initializeTools(globalTools, localTools, globalSimpleTools, specialTools); + initializeTools(globalTools, localTools, globalSimpleTools); final List needRepeatSearchRequest = new ArrayList(); ((RefManagerImpl)getRefManager()).initializeAnnotators(); - // run special tools first - for (Tools tools : specialTools) { - for (ScopeToolState state : tools.getTools()) { - InspectionToolWrapper toolWrapper = state.getTool(); - InspectionTool tool = (InspectionTool)toolWrapper.getTool(); - try { - if (tool.isGraphNeeded()) { - ((RefManagerImpl)getRefManager()).findAllDeclarations(); - } - tool.runInspection(scope, manager); - if (tool.queryExternalUsagesRequests(manager)) { - needRepeatSearchRequest.add(toolWrapper); - } - } - catch (ProcessCanceledException e) { - throw e; - } - catch (IndexNotReadyException e) { - throw e; - } - catch (Exception e) { - LOG.error(e); - } - } - } for (Tools tools : globalTools) { for (ScopeToolState state : tools.getTools()) { @@ -604,8 +575,8 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G if (tool.isGraphNeeded()) { ((RefManagerImpl)getRefManager()).findAllDeclarations(); } - tool.runInspection(scope, manager, this, toolPresentation); - if (tool.queryExternalUsagesRequests(manager,this, toolPresentation)) { + tool.runInspection(scope, inspectionManager, this, toolPresentation); + if (tool.queryExternalUsagesRequests(inspectionManager, this, toolPresentation)) { needRepeatSearchRequest.add(toolWrapper); } } @@ -634,14 +605,14 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G LOG.error(e); } } - if (RUN_GLOBAL_TOOLS_ONLY) return; + if (runGlobalToolsOnly) return; final PsiManager psiManager = PsiManager.getInstance(myProject); final Set localScopeFiles = scope.toSearchScope() instanceof LocalSearchScope ? new THashSet() : null; for (Tools tools : globalSimpleTools) { GlobalInspectionToolWrapper toolWrapper = (GlobalInspectionToolWrapper)tools.getTool(); GlobalSimpleInspectionTool tool = (GlobalSimpleInspectionTool)toolWrapper.getTool(); - tool.inspectionStarted(manager, this, getPresentation(toolWrapper)); + tool.inspectionStarted(inspectionManager, this, getPresentation(toolWrapper)); } final Map map = getInspectionWrappersMap(localTools); @@ -669,16 +640,16 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G lTools.add(enabledTool); } } - pass.doInspectInBatch((InspectionManagerEx)manager, lTools); + pass.doInspectInBatch(inspectionManager, lTools); JobLauncher.getInstance().invokeConcurrentlyUnderProgress(globalSimpleTools, myProgressIndicator, false, new Processor() { @Override public boolean process(Tools tools) { GlobalInspectionToolWrapper toolWrapper = (GlobalInspectionToolWrapper)tools.getTool(); GlobalSimpleInspectionTool tool = (GlobalSimpleInspectionTool)toolWrapper.getTool(); - ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, false); + ProblemsHolder problemsHolder = new ProblemsHolder(inspectionManager, file, false); ProblemDescriptionsProcessor problemDescriptionProcessor = getProblemDescriptionProcessor(toolWrapper, map); - tool.checkFile(file, manager, problemsHolder, GlobalInspectionContextImpl.this, problemDescriptionProcessor); + tool.checkFile(file, inspectionManager, problemsHolder, GlobalInspectionContextImpl.this, problemDescriptionProcessor); InspectionToolPresentation toolPresentation = getPresentation(toolWrapper); LocalDescriptorsUtil.addProblemDescriptors(problemsHolder.getResults(), false, GlobalInspectionContextImpl.this, null, CONVERT, toolPresentation); @@ -707,7 +678,7 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G GlobalInspectionToolWrapper toolWrapper = (GlobalInspectionToolWrapper)tools.getTool(); GlobalSimpleInspectionTool tool = (GlobalSimpleInspectionTool)toolWrapper.getTool(); ProblemDescriptionsProcessor problemDescriptionProcessor = getProblemDescriptionProcessor(toolWrapper, map); - tool.inspectionFinished(manager, this, problemDescriptionProcessor); + tool.inspectionFinished(inspectionManager, this, problemDescriptionProcessor); } } @@ -734,14 +705,7 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G } ProblemGroup problemGroup = ((ProblemDescriptor)problemDescriptor).getProblemGroup(); - InspectionToolWrapper targetWrapper; - if (problemGroup == null) { - targetWrapper = toolWrapper; - } - else { - targetWrapper = wrappersMap.get(problemGroup.getProblemName()); - - } + InspectionToolWrapper targetWrapper = problemGroup == null ? toolWrapper : wrappersMap.get(problemGroup.getProblemName()); if (targetWrapper != null) { // Else it's switched off InspectionToolPresentation toolPresentation = getPresentation(targetWrapper); toolPresentation.addProblemElement(refEntity, problemDescriptor); @@ -786,20 +750,22 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G public void initializeTools(@NotNull List outGlobalTools, @NotNull List outLocalTools, - @NotNull List outGlobalSimpleTools, - @NotNull List outSpecialTools - ) { + @NotNull List outGlobalSimpleTools) { myJobDescriptors = new ArrayList(); final List usedTools = getUsedTools(); for (Tools currentTools : usedTools) { final String shortName = currentTools.getShortName(); myTools.put(shortName, currentTools); - InspectionToolWrapper toolWrapper1 = currentTools.getTool(); - classifyTool(outGlobalTools, outLocalTools, outGlobalSimpleTools, outSpecialTools, currentTools, toolWrapper1); + InspectionToolWrapper toolWrapper = currentTools.getTool(); + classifyTool(outGlobalTools, outLocalTools, outGlobalSimpleTools, currentTools, toolWrapper); for (ScopeToolState state : currentTools.getTools()) { - InspectionToolWrapper toolWrapper = state.getTool(); - toolWrapper.initialize(this); + state.getTool().initialize(this); + } + + JobDescriptor[] jobDescriptors = toolWrapper.getJobDescriptors(this); + for (JobDescriptor jobDescriptor : jobDescriptors) { + appendJobDescriptor(jobDescriptor); } } for (GlobalInspectionContextExtension extension : myExtensions.values()) { @@ -828,12 +794,11 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G return new ArrayList(set); } - private void classifyTool(@NotNull List outGlobalTools, - @NotNull List outLocalTools, - @NotNull List outGlobalSimpleTools, - @NotNull List outSpecialTools, - @NotNull Tools currentTools, - @NotNull InspectionToolWrapper toolWrapper) { + private static void classifyTool(@NotNull List outGlobalTools, + @NotNull List outLocalTools, + @NotNull List outGlobalSimpleTools, + @NotNull Tools currentTools, + @NotNull InspectionToolWrapper toolWrapper) { if (toolWrapper instanceof LocalInspectionToolWrapper) { outLocalTools.add(currentTools); } @@ -844,23 +809,13 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G else if (toolWrapper.getTool() instanceof GlobalInspectionTool) { outGlobalTools.add(currentTools); } - else if (toolWrapper.getTool() instanceof InspectionTool) { - outSpecialTools.add(currentTools); - } else { throw new RuntimeException("unknown global tool " + toolWrapper); } } - else if (toolWrapper.getTool() instanceof InspectionTool) { - outSpecialTools.add(currentTools); - } else { throw new RuntimeException("unknown tool " + toolWrapper); } - JobDescriptor[] jobDescriptors = toolWrapper.getJobDescriptors(this); - for (JobDescriptor jobDescriptor : jobDescriptors) { - appendJobDescriptor(jobDescriptor); - } } public Map getTools() { @@ -876,8 +831,7 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G public void close(boolean noSuspisiousCodeFound) { if (!noSuspisiousCodeFound && (myView == null || myView.isRerun())) return; - final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(myProject); - cleanup(managerEx); + cleanup(); AnalysisUIOptions.getInstance(myProject).save(myUIOptions); if (myContent != null) { final ContentManager contentManager = getContentManager(); @@ -888,15 +842,15 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G myView = null; } - public void cleanup(@NotNull InspectionManagerEx managerEx) { - managerEx.closeRunningContext(this); + public void cleanup() { + ((InspectionManagerEx)InspectionManager.getInstance(getProject())).closeRunningContext(this); for (Tools tools : myTools.values()) { for (ScopeToolState state : tools.getTools()) { InspectionToolWrapper toolWrapper = state.getTool(); getPresentation(toolWrapper).finalCleanup(); } } - cleanup(); + cleanupTools(); } public void refreshViews() { diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/SpecialToolsManager.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/SpecialToolsManager.java deleted file mode 100644 index f7c3c1adf8f8..000000000000 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/SpecialToolsManager.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.codeInspection.ex; - -import com.intellij.codeInspection.InspectionEP; -import com.intellij.openapi.extensions.ExtensionPointName; -import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.util.Factory; - -public class SpecialToolsManager { - public SpecialToolsManager(InspectionToolRegistrar inspectionToolRegistrar) { - registerSpecialTools(inspectionToolRegistrar); - } - - private static final ExtensionPointName SPECIAL_TOOL = ExtensionPointName.create("com.intellij.specialTool"); - - private static void registerSpecialTools(InspectionToolRegistrar inspectionToolRegistrar) { - InspectionEP[] specials = Extensions.getExtensions(SPECIAL_TOOL); - if (specials.length == 0) return; - for (final InspectionEP ep : specials) { - inspectionToolRegistrar.registerInspectionToolFactory(new Factory() { - @Override - public InspectionToolWrapper create() { - return new CommonInspectionToolWrapper(ep); - } - }, true); - } - } -} diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java index f5333d614700..cd9dbf337bbf 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/Browser.java @@ -124,20 +124,13 @@ class Browser extends JPanel { private void showPageFromHistory(@NotNull RefEntity newEntity) { InspectionToolWrapper toolWrapper = getToolWrapper(newEntity); try { - if (!(toolWrapper instanceof CommonInspectionToolWrapper)) { - showEmpty(); - } - else { - try { - String html = generateHTML(newEntity, toolWrapper); - myHTMLViewer.read(new StringReader(html), null); - setupStyle(); - myHTMLViewer.setCaretPosition(0); - } - catch (Exception e) { - showEmpty(); - } - } + String html = generateHTML(newEntity, toolWrapper); + myHTMLViewer.read(new StringReader(html), null); + setupStyle(); + myHTMLViewer.setCaretPosition(0); + } + catch (Exception e) { + showEmpty(); } finally { myCurrentEntity = newEntity; diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java index 4b6cfbe19ed0..5d0c4b9bc3f5 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java @@ -884,7 +884,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren myRerun = true; if (myScope.isValid()) { AnalysisUIOptions.getInstance(myProject).save(myGlobalInspectionContext.getUIOptions()); - myGlobalInspectionContext.doInspections(myScope, InspectionManager.getInstance(myProject)); + myGlobalInspectionContext.doInspections(myScope); } } } diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java index e62dfafa2c31..711501b3f0d6 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java @@ -25,7 +25,6 @@ import com.intellij.codeInsight.daemon.impl.analysis.HighlightingSettingsPerFile import com.intellij.codeInspection.InspectionsBundle; import com.intellij.codeInspection.ex.InspectionProfileImpl; import com.intellij.codeInspection.ex.InspectionToolRegistrar; -import com.intellij.codeInspection.ex.SpecialToolsManager; import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; @@ -82,7 +81,7 @@ public class InspectionProfileManagerImpl extends InspectionProfileManager imple return (InspectionProfileManagerImpl)ServiceManager.getService(InspectionProfileManager.class); } - public InspectionProfileManagerImpl(InspectionToolRegistrar registrar, SchemesManagerFactory schemesManagerFactory, SpecialToolsManager specialToolsManager) { + public InspectionProfileManagerImpl(InspectionToolRegistrar registrar, SchemesManagerFactory schemesManagerFactory) { myRegistrar = registrar; mySeverityRegistrar = new SeverityRegistrar(); registerProvidedSeverities(); diff --git a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml index a82a32e81fdb..c54003036c81 100644 --- a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml @@ -285,9 +285,6 @@ beanClass="com.intellij.codeInspection.InspectionEP"> - - - diff --git a/platform/testFramework/src/com/intellij/testFramework/InspectionTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/InspectionTestUtil.java index f98bc51a6c6e..612f35c9108a 100644 --- a/platform/testFramework/src/com/intellij/testFramework/InspectionTestUtil.java +++ b/platform/testFramework/src/com/intellij/testFramework/InspectionTestUtil.java @@ -154,6 +154,6 @@ expected: HighlightDisplayKey.register(shortName); } - globalContext.doInspections(scope, inspectionManager); + globalContext.doInspections(scope); } } diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java index 2bd7ed67092e..79c0a98003e2 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java @@ -440,7 +440,6 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da final List eps = ContainerUtil.newArrayList(); ContainerUtil.addAll(eps, Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION)); ContainerUtil.addAll(eps, Extensions.getExtensions(InspectionEP.GLOBAL_INSPECTION)); - ContainerUtil.addAll(eps, (InspectionEP[])Extensions.getExtensions("com.intellij.specialTool")); next: for (int i = 0; i < classes.length; i++) { @@ -462,23 +461,25 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da } } - protected void enableInspectionTool(@NotNull InspectionToolWrapper wrapper) { - enableInspectionTool(myAvailableInspectionTools, wrapper); + protected void enableInspectionTool(@NotNull InspectionToolWrapper toolWrapper) { + enableInspectionTool(myAvailableInspectionTools, toolWrapper); } protected void enableInspectionTool(@NotNull InspectionProfileEntry tool) { - InspectionToolWrapper toolWrapper = tool instanceof InspectionTool ? new CommonInspectionToolWrapper((InspectionTool)tool) : InspectionToolRegistrar.wrapTool(tool); + InspectionToolWrapper toolWrapper = InspectionToolRegistrar.wrapTool(tool); enableInspectionTool(myAvailableInspectionTools, toolWrapper); } - private static void enableInspectionTool(@NotNull Map availableLocalTools, @NotNull InspectionToolWrapper wrapper) { - final String shortName = wrapper.getShortName(); + private static void enableInspectionTool(@NotNull Map availableLocalTools, + @NotNull InspectionToolWrapper toolWrapper) { + final String shortName = toolWrapper.getShortName(); final HighlightDisplayKey key = HighlightDisplayKey.find(shortName); if (key == null) { - HighlightDisplayKey.register(shortName, wrapper.getDisplayName(), wrapper instanceof LocalInspectionToolWrapper - ? ((LocalInspectionToolWrapper)wrapper).getTool().getID() - : wrapper.getShortName()); + String id = toolWrapper instanceof LocalInspectionToolWrapper + ? ((LocalInspectionToolWrapper)toolWrapper).getTool().getID() + : toolWrapper.getShortName(); + HighlightDisplayKey.register(shortName, toolWrapper.getDisplayName(), id); } - availableLocalTools.put(shortName, wrapper); + availableLocalTools.put(shortName, toolWrapper); } @NotNull diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index cbe97417d3cb..070fb7ec898e 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -1136,7 +1136,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig } private void enableInspectionTool(@NotNull InspectionProfileEntry tool) { - InspectionToolWrapper toolWrapper = tool instanceof InspectionTool ? new CommonInspectionToolWrapper((InspectionTool)tool) : InspectionToolRegistrar.wrapTool(tool); + InspectionToolWrapper toolWrapper = InspectionToolRegistrar.wrapTool(tool); final String shortName = tool.getShortName(); final HighlightDisplayKey key = HighlightDisplayKey.find(shortName); diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index 0d488df28c43..0d97ff2ac34e 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -462,7 +462,7 @@ - - diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java index f2941afeef74..e96d2e40a325 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java @@ -22,7 +22,6 @@ import com.intellij.codeInspection.InspectionToolProvider; import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.codeInspection.ex.InspectionToolRegistrar; import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; -import com.intellij.codeInspection.ex.SpecialToolsManager; import com.intellij.lang.annotation.Annotation; import com.intellij.mock.MockInspectionProfile; import com.intellij.profile.codeInspection.InspectionProfileManager; @@ -56,7 +55,7 @@ public class DomHighlightingLiteTest extends DomTestCase { final InspectionToolRegistrar registrar = new InspectionToolRegistrar(); registrar.registerTools(new InspectionToolProvider[0]); - final InspectionProfileManager inspectionProfileManager = new InspectionProfileManagerImpl(registrar, new MockSchemesManagerFactory(), new SpecialToolsManager(registrar)); + final InspectionProfileManager inspectionProfileManager = new InspectionProfileManagerImpl(registrar, new MockSchemesManagerFactory()); myInspectionProfile = new MockInspectionProfile(); myAnnotationsManager = new DomElementAnnotationsManagerImpl(getProject()) {