InspectionTool killed

This commit is contained in:
Alexey Kudravtsev
2013-06-26 10:43:31 +04:00
parent b9b31b299c
commit f4fdbda57a
33 changed files with 182 additions and 292 deletions
@@ -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;
}
@@ -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<EntryPoint> 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;
@@ -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();
@@ -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<Tools> 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);
}
@@ -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
@@ -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
@@ -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<Tools>(), new ArrayList<Tools>(), new ArrayList<Tools>(), new ArrayList<Tools>());
GlobalInspectionContextImpl context = RunInspectionIntention.createContext(toolWrapper, instance, file);
context.initializeTools(new ArrayList<Tools>(), new ArrayList<Tools>(), new ArrayList<Tools>());
assertEquals(1, context.getTools().size());
return;
}
@@ -266,7 +266,7 @@ public class InspectionProfileTest extends LightIdeaTestCase {
GlobalInspectionContextImpl context = ((InspectionManagerEx)InspectionManager.getInstance(getProject())).createNewGlobalContext(false);
context.setExternalProfile(profile);
context.initializeTools(new ArrayList<Tools>(), new ArrayList<Tools>(), new ArrayList<Tools>(), new ArrayList<Tools>());
context.initializeTools(new ArrayList<Tools>(), new ArrayList<Tools>(), new ArrayList<Tools>());
}
public void testInspectionsInitialization() throws Exception {
@@ -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() {
@@ -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) {
@@ -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));
@@ -197,4 +197,7 @@ public abstract class GlobalInspectionTool extends InspectionProfileEntry {
public boolean worksInBatchModeOnly() {
return true;
}
public void initialize(@NotNull GlobalInspectionContext context) {
}
}
@@ -54,6 +54,7 @@ public class GlobalInspectionToolWrapper extends InspectionToolWrapper<GlobalIns
if (annotator != null) {
refManager.registerGraphAnnotator(annotator);
}
getTool().initialize(context);
}
@Override
@@ -218,7 +218,7 @@ public class InspectionApplication {
if (myErrorCodeRequired) System.exit(1);
return;
}
inspectionContext.launchInspectionsOffline(scope, resultsDataPath, myRunGlobalToolsOnly, im, inspectionsResults);
inspectionContext.launchInspectionsOffline(scope, resultsDataPath, myRunGlobalToolsOnly, inspectionsResults);
logMessageLn(1, "\n" +
InspectionsBundle.message("inspection.capitalized.done") +
"\n");
@@ -73,7 +73,7 @@ public class InspectionRunningUtil {
finally {
refManager.inspectionReadActionFinished();
toolWrapper.cleanup();
context.cleanup(managerEx);
context.cleanup();
}
}
}
@@ -58,11 +58,10 @@ public class CodeInspectionAction extends BaseAnalysisAction {
try {
scope.setSearchInLibraries(false);
FileDocumentManager.getInstance().saveAllDocuments();
final InspectionManagerEx inspectionManagerEx = (InspectionManagerEx)InspectionManager.getInstance(project);
final GlobalInspectionContextImpl inspectionContext = getGlobalInspectionContext(project);
inspectionContext.setExternalProfile(myExternalProfile);
inspectionContext.setCurrentScope(scope);
inspectionContext.doInspections(scope, inspectionManagerEx);
inspectionContext.doInspections(scope);
}
finally {
myGlobalInspectionContext = null;
@@ -51,7 +51,7 @@ public class CodeInspectionOnEditorAction extends AnAction {
final InspectionProfile inspectionProfile =
InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
inspectionContext.setExternalProfile(inspectionProfile);
inspectionContext.doInspections(scope, inspectionManagerEx);
inspectionContext.doInspections(scope);
}
@Override
@@ -89,14 +89,16 @@ public class RunInspectionAction extends GotoActionBase {
private static void runInspection(@NotNull Project project,
@NotNull InspectionToolWrapper toolWrapper,
@Nullable VirtualFile virtualFile,
PsiElement psiElement, PsiFile psiFile) {
PsiElement psiElement,
PsiFile psiFile) {
final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(project);
final Module module = virtualFile != null ? ModuleUtilCore.findModuleForFile(virtualFile, project) : null;
AnalysisScope analysisScope = null;
if (psiFile != null) {
analysisScope = new AnalysisScope(psiFile);
} else {
}
else {
if (virtualFile != null && virtualFile.isDirectory()) {
final PsiDirectory psiDirectory = PsiManager.getInstance(project).findDirectory(virtualFile);
if (psiDirectory != null) {
@@ -114,7 +116,7 @@ public class RunInspectionAction extends GotoActionBase {
final FileFilterPanel fileFilterPanel = new FileFilterPanel();
fileFilterPanel.init();
final BaseAnalysisActionDialog dlg = new BaseAnalysisActionDialog(
final BaseAnalysisActionDialog dialog = new BaseAnalysisActionDialog(
AnalysisScopeBundle.message("specify.analysis.scope", InspectionsBundle.message("inspection.action.title")),
AnalysisScopeBundle.message("analysis.scope.title", InspectionsBundle.message("inspection.action.noun")),
project,
@@ -135,11 +137,11 @@ public class RunInspectionAction extends GotoActionBase {
}
};
AnalysisScope scope = analysisScope;
dlg.show();
if (!dlg.isOK()) return;
dialog.show();
if (!dialog.isOK()) return;
final AnalysisUIOptions uiOptions = AnalysisUIOptions.getInstance(project);
scope = dlg.getScope(uiOptions, scope, project, module);
RunInspectionIntention.rerunInspection(toolWrapper, managerEx, scope, psiFile);
AnalysisScope scope = dialog.getScope(uiOptions, analysisScope, project, module);
PsiElement element = psiFile == null ? psiElement : psiFile;
RunInspectionIntention.rerunInspection(toolWrapper, managerEx, scope, element);
}
}
@@ -29,6 +29,8 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.profile.codeInspection.InspectionProfileManager;
import com.intellij.psi.PsiElement;
@@ -93,14 +95,17 @@ public class RunInspectionIntention implements IntentionAction, HighPriorityActi
rerunInspection(LocalInspectionToolWrapper.findTool2RunInBatch(project, file, myShortName), managerEx, analysisScope, file);
}
public static void rerunInspection(final InspectionToolWrapper toolWrapper,
final InspectionManagerEx managerEx, final AnalysisScope scope,
public static void rerunInspection(@NotNull InspectionToolWrapper toolWrapper,
@NotNull InspectionManagerEx managerEx,
@NotNull AnalysisScope scope,
PsiElement psiElement) {
GlobalInspectionContextImpl inspectionContext = createContext(toolWrapper, managerEx, psiElement);
inspectionContext.doInspections(scope, managerEx);
inspectionContext.doInspections(scope);
}
public static GlobalInspectionContextImpl createContext(final InspectionToolWrapper toolWrapper, InspectionManagerEx managerEx, PsiElement psiElement) {
public static GlobalInspectionContextImpl createContext(@NotNull InspectionToolWrapper toolWrapper,
@NotNull InspectionManagerEx managerEx,
PsiElement psiElement) {
final InspectionProfileImpl rootProfile = (InspectionProfileImpl)InspectionProfileManager.getInstance().getRootProfile();
LinkedHashSet<InspectionToolWrapper> allWrappers = new LinkedHashSet<InspectionToolWrapper>();
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);
@@ -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<Tools>(), new ArrayList<Tools>(), new ArrayList<Tools>(), new ArrayList<Tools>());
context.initializeTools(new ArrayList<Tools>(), new ArrayList<Tools>(), new ArrayList<Tools>());
final InspectionResultsView view = new InspectionResultsView(project, inspectionProfile, scope, context,
new OfflineInspectionRVContentProvider(resMap, project));
((RefManagerImpl)context.getRefManager()).inspectionReadActionStarted();
@@ -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<InspectionTool, InspectionEP> {
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);
}
}
@@ -110,7 +110,6 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G
private InspectionProfile myExternalProfile = null;
private final Map<Key, GlobalInspectionContextExtension> myExtensions = new HashMap<Key, GlobalInspectionContextExtension>();
private boolean RUN_GLOBAL_TOOLS_ONLY = false;
private final Map<String, Tools> myTools = new THashMap<String, Tools>();
@@ -119,7 +118,7 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G
private boolean myUseProgressIndicatorInTests = false;
public GlobalInspectionContextImpl(Project project, NotNullLazyValue<ContentManager> contentManager) {
public GlobalInspectionContextImpl(@NotNull Project project, @NotNull NotNullLazyValue<ContentManager> 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<File> 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<Element, Tools> globalTools = new HashMap<Element, Tools>();
for (Map.Entry<String,Tools> 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<Tools> globalTools = new ArrayList<Tools>();
final List<Tools> localTools = new ArrayList<Tools>();
final List<Tools> globalSimpleTools = new ArrayList<Tools>();
List<Tools> specialTools = new ArrayList<Tools>();
initializeTools(globalTools, localTools, globalSimpleTools, specialTools);
initializeTools(globalTools, localTools, globalSimpleTools);
final List<InspectionToolWrapper> needRepeatSearchRequest = new ArrayList<InspectionToolWrapper>();
((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<VirtualFile> localScopeFiles = scope.toSearchScope() instanceof LocalSearchScope ? new THashSet<VirtualFile>() : 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<String, InspectionToolWrapper> 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<Tools>() {
@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<Tools> outGlobalTools,
@NotNull List<Tools> outLocalTools,
@NotNull List<Tools> outGlobalSimpleTools,
@NotNull List<Tools> outSpecialTools
) {
@NotNull List<Tools> outGlobalSimpleTools) {
myJobDescriptors = new ArrayList<JobDescriptor>();
final List<Tools> 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<Tools>(set);
}
private void classifyTool(@NotNull List<Tools> outGlobalTools,
@NotNull List<Tools> outLocalTools,
@NotNull List<Tools> outGlobalSimpleTools,
@NotNull List<Tools> outSpecialTools,
@NotNull Tools currentTools,
@NotNull InspectionToolWrapper toolWrapper) {
private static void classifyTool(@NotNull List<Tools> outGlobalTools,
@NotNull List<Tools> outLocalTools,
@NotNull List<Tools> 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<String, Tools> 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() {
@@ -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<InspectionEP> 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<InspectionToolWrapper>() {
@Override
public InspectionToolWrapper create() {
return new CommonInspectionToolWrapper(ep);
}
}, true);
}
}
}
@@ -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;
@@ -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);
}
}
}
@@ -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();
@@ -285,9 +285,6 @@
beanClass="com.intellij.codeInspection.InspectionEP">
<with attribute="implementationClass" implements="com.intellij.codeInspection.GlobalInspectionTool"/>
</extensionPoint>
<!-- please use localInspection or globalInspection instead-->
<extensionPoint name="specialTool"
beanClass="com.intellij.codeInspection.InspectionEP"/>
<extensionPoint name="inspectionToolProvider"
interface="com.intellij.codeInspection.InspectionToolProvider"/>
<extensionPoint name="inspectionToolsFactory"
@@ -30,7 +30,6 @@
serviceImplementation="com.intellij.codeInsight.TargetElementUtilBase"/>
<applicationService serviceInterface="com.intellij.profile.codeInspection.InspectionProfileManager"
serviceImplementation="com.intellij.profile.codeInspection.InspectionProfileManagerImpl"/>
<applicationService serviceImplementation="com.intellij.codeInspection.ex.SpecialToolsManager"/>
<exportable serviceInterface="com.intellij.profile.codeInspection.InspectionProfileManager"/>
<schemeOwner serviceInterface="com.intellij.profile.codeInspection.InspectionProfileManager"/>
@@ -154,6 +154,6 @@ expected:
HighlightDisplayKey.register(shortName);
}
globalContext.doInspections(scope, inspectionManager);
globalContext.doInspections(scope);
}
}
@@ -440,7 +440,6 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
final List<InspectionEP> 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<String, InspectionToolWrapper> availableLocalTools, @NotNull InspectionToolWrapper wrapper) {
final String shortName = wrapper.getShortName();
private static void enableInspectionTool(@NotNull Map<String, InspectionToolWrapper> 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
@@ -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);
+1 -2
View File
@@ -462,7 +462,7 @@
<externalProjectDataService implementation="com.intellij.externalSystem.JavaProjectDataService"/>
<specialTool shortName="UnusedDeclaration" displayName="Unused declaration" groupBundle="messages.InspectionsBundle"
<globalInspection shortName="UnusedDeclaration" displayName="Unused declaration" groupBundle="messages.InspectionsBundle"
groupKey="group.names.declaration.redundancy" enabledByDefault="true" level="WARNING"
implementationClass="com.intellij.codeInspection.deadCode.UnusedDeclarationInspection"/>
<globalInspection shortName="UnusedLibrary" bundle="messages.InspectionsBundle" key="unused.library.display.name"
@@ -1354,7 +1354,6 @@
<applicationService serviceInterface="com.intellij.profile.codeInspection.InspectionProfileManager"
serviceImplementation="com.intellij.profile.codeInspection.JavaAwareInspectionProfileManager"/>
<applicationService serviceImplementation="com.intellij.codeInspection.ex.SpecialToolsManager"/>
<resolveScopeEnlarger implementation="com.intellij.psi.NonClasspathResolveScopeEnlarger"/>
@@ -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()) {