use of com.intellij.codeInspection.lang.GlobalInspectionContextExtension in project intellij-community by JetBrains.
the class GlobalInspectionContextBase method cleanupTools.
void cleanupTools() {
myProgressIndicator.cancel();
for (GlobalInspectionContextExtension extension : myExtensions.values()) {
extension.cleanup();
}
for (Tools tools : myTools.values()) {
for (ScopeToolState state : tools.getTools()) {
InspectionToolWrapper toolWrapper = state.getTool();
toolWrapper.cleanup(myProject);
}
}
myTools.clear();
EntryPointsManager entryPointsManager = EntryPointsManager.getInstance(getProject());
if (entryPointsManager != null) {
entryPointsManager.cleanup();
}
if (myRefManager != null) {
((RefManagerImpl) myRefManager).cleanup();
myRefManager = null;
if (myCurrentScope != null) {
myCurrentScope.invalidate();
myCurrentScope = null;
}
}
myJobDescriptors.clear();
}
use of com.intellij.codeInspection.lang.GlobalInspectionContextExtension in project intellij-community by JetBrains.
the class GlobalInspectionContextBase method initializeTools.
public void initializeTools(@NotNull List<Tools> outGlobalTools, @NotNull List<Tools> outLocalTools, @NotNull List<Tools> outGlobalSimpleTools) {
final List<Tools> usedTools = getUsedTools();
for (Tools currentTools : usedTools) {
final String shortName = currentTools.getShortName();
myTools.put(shortName, currentTools);
InspectionToolWrapper toolWrapper = currentTools.getTool();
classifyTool(outGlobalTools, outLocalTools, outGlobalSimpleTools, currentTools, toolWrapper);
for (ScopeToolState state : currentTools.getTools()) {
state.getTool().initialize(this);
}
JobDescriptor[] jobDescriptors = toolWrapper.getJobDescriptors(this);
for (JobDescriptor jobDescriptor : jobDescriptors) {
appendJobDescriptor(jobDescriptor);
}
}
for (GlobalInspectionContextExtension extension : myExtensions.values()) {
extension.performPreRunActivities(outGlobalTools, outLocalTools, this);
}
}
use of com.intellij.codeInspection.lang.GlobalInspectionContextExtension in project intellij-community by JetBrains.
the class GlobalInspectionContextImpl method runGlobalTools.
private void runGlobalTools(@NotNull final AnalysisScope scope, @NotNull final InspectionManager inspectionManager, @NotNull List<Tools> globalTools, boolean isOfflineInspections) {
LOG.assertTrue(!ApplicationManager.getApplication().isReadAccessAllowed() || isOfflineInspections, "Must not run under read action, too unresponsive");
final List<InspectionToolWrapper> needRepeatSearchRequest = new ArrayList<>();
final boolean canBeExternalUsages = !(scope.getScopeType() == AnalysisScope.PROJECT && scope.isIncludeTestSource());
for (Tools tools : globalTools) {
for (ScopeToolState state : tools.getTools()) {
final InspectionToolWrapper toolWrapper = state.getTool();
final GlobalInspectionTool tool = (GlobalInspectionTool) toolWrapper.getTool();
final InspectionToolPresentation toolPresentation = getPresentation(toolWrapper);
try {
if (tool.isGraphNeeded()) {
try {
((RefManagerImpl) getRefManager()).findAllDeclarations();
} catch (Throwable e) {
getStdJobDescriptors().BUILD_GRAPH.setDoneAmount(0);
throw e;
}
}
ApplicationManager.getApplication().runReadAction(() -> {
tool.runInspection(scope, inspectionManager, this, toolPresentation);
//skip phase when we are sure that scope already contains everything, unused declaration though needs to proceed with its suspicious code
if ((canBeExternalUsages || tool.getAdditionalJobs(this) != null) && tool.queryExternalUsagesRequests(inspectionManager, this, toolPresentation)) {
needRepeatSearchRequest.add(toolWrapper);
}
});
} catch (ProcessCanceledException | IndexNotReadyException e) {
throw e;
} catch (Throwable e) {
LOG.error(e);
}
}
}
for (GlobalInspectionContextExtension extension : myExtensions.values()) {
try {
extension.performPostRunActivities(needRepeatSearchRequest, this);
} catch (ProcessCanceledException | IndexNotReadyException e) {
throw e;
} catch (Throwable e) {
LOG.error(e);
}
}
addProblemsToView(globalTools);
}
Aggregations