use of com.intellij.codeInspection.ui.InspectionToolPresentation 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);
}
use of com.intellij.codeInspection.ui.InspectionToolPresentation in project intellij-community by JetBrains.
the class LocalQuickFixWrapper method ignore.
private void ignore(@NotNull Collection<PsiElement> ignoredElements, @NotNull CommonProblemDescriptor descriptor, @Nullable QuickFix fix, @NotNull GlobalInspectionContextImpl context) {
if (fix != null) {
InspectionToolPresentation presentation = context.getPresentation(myToolWrapper);
presentation.ignoreProblem(descriptor, fix);
}
if (descriptor instanceof ProblemDescriptor) {
PsiElement element = ((ProblemDescriptor) descriptor).getPsiElement();
if (element != null) {
ignoredElements.add(element);
}
}
}
use of com.intellij.codeInspection.ui.InspectionToolPresentation in project intellij-community by JetBrains.
the class GlobalJavaInspectionContextImpl method performPostRunActivities.
@Override
public void performPostRunActivities(@NotNull List<InspectionToolWrapper> needRepeatSearchRequest, @NotNull final GlobalInspectionContext context) {
JobDescriptor progress = context.getStdJobDescriptors().FIND_EXTERNAL_USAGES;
progress.setTotalAmount(getRequestCount());
do {
processSearchRequests(context);
InspectionToolWrapper[] requestors = needRepeatSearchRequest.toArray(new InspectionToolWrapper[needRepeatSearchRequest.size()]);
InspectionManager inspectionManager = InspectionManager.getInstance(context.getProject());
for (InspectionToolWrapper toolWrapper : requestors) {
boolean result = false;
if (toolWrapper instanceof GlobalInspectionToolWrapper) {
InspectionToolPresentation presentation = ((GlobalInspectionContextImpl) context).getPresentation(toolWrapper);
result = ((GlobalInspectionToolWrapper) toolWrapper).getTool().queryExternalUsagesRequests(inspectionManager, context, presentation);
}
if (!result) {
needRepeatSearchRequest.remove(toolWrapper);
}
}
int oldSearchRequestCount = progress.getTotalAmount();
int oldDoneAmount = progress.getDoneAmount();
int totalAmount = oldSearchRequestCount + getRequestCount();
progress.setTotalAmount(totalAmount);
progress.setDoneAmount(oldDoneAmount);
} while (!needRepeatSearchRequest.isEmpty());
}
Aggregations