use of com.intellij.codeInspection.ex.GlobalInspectionContextImpl in project intellij-community by JetBrains.
the class SuppressActionSequentialTask method suppress.
private void suppress(@NotNull final PsiElement element, @Nullable final CommonProblemDescriptor descriptor, @NotNull final SuppressIntentionAction action, @NotNull final RefEntity refEntity, InspectionToolWrapper wrapper, @NotNull final SuppressableInspectionTreeNode node) {
if (action instanceof SuppressIntentionActionFromFix && !(descriptor instanceof ProblemDescriptor)) {
LOG.info("local suppression fix for specific problem descriptor: " + wrapper.getTool().getClass().getName());
}
final Project project = element.getProject();
ApplicationManager.getApplication().runWriteAction(() -> {
PsiDocumentManager.getInstance(project).commitAllDocuments();
try {
PsiElement container = null;
if (action instanceof SuppressIntentionActionFromFix) {
container = ((SuppressIntentionActionFromFix) action).getContainer(element);
}
if (container == null) {
container = element;
}
if (action.isAvailable(project, null, element)) {
action.invoke(project, null, element);
}
final Set<GlobalInspectionContextImpl> globalInspectionContexts = ((InspectionManagerEx) InspectionManager.getInstance(element.getProject())).getRunningContexts();
for (GlobalInspectionContextImpl context : globalInspectionContexts) {
context.ignoreElement(wrapper.getTool(), container);
if (descriptor != null) {
context.getPresentation(wrapper).ignoreCurrentElementProblem(refEntity, descriptor);
}
}
final RefElement containerRef = refEntity.getRefManager().getReference(container);
final Set<Object> suppressedNodes = myContext.getView().getSuppressedNodes(wrapper.getShortName());
if (containerRef != null) {
Queue<RefEntity> toIgnoreInView = new Queue<>(1);
toIgnoreInView.addLast(containerRef);
while (!toIgnoreInView.isEmpty()) {
final RefEntity entity = toIgnoreInView.pullFirst();
if (node instanceof ProblemDescriptionNode) {
final CommonProblemDescriptor[] descriptors = myContext.getPresentation(wrapper).getIgnoredElements().get(entity);
if (descriptors != null) {
Collections.addAll(suppressedNodes, descriptors);
}
} else {
suppressedNodes.add(entity);
}
final List<RefEntity> children = entity.getChildren();
for (RefEntity child : children) {
toIgnoreInView.addLast(child);
}
}
}
if (node instanceof ProblemDescriptionNode) {
suppressedNodes.add(descriptor);
}
} catch (IncorrectOperationException e1) {
LOG.error(e1);
}
});
node.removeSuppressActionFromAvailable(mySuppressAction);
}
use of com.intellij.codeInspection.ex.GlobalInspectionContextImpl in project intellij-community by JetBrains.
the class CodeInspectionOnEditorAction method analyze.
protected static void analyze(Project project, PsiFile psiFile) {
FileDocumentManager.getInstance().saveAllDocuments();
final InspectionManagerEx inspectionManagerEx = (InspectionManagerEx) InspectionManager.getInstance(project);
final AnalysisScope scope = new AnalysisScope(psiFile);
final GlobalInspectionContextImpl inspectionContext = inspectionManagerEx.createNewGlobalContext(false);
inspectionContext.setCurrentScope(scope);
inspectionContext.setExternalProfile(InspectionProjectProfileManager.getInstance(project).getCurrentProfile());
inspectionContext.doInspections(scope);
}
use of com.intellij.codeInspection.ex.GlobalInspectionContextImpl in project intellij-community by JetBrains.
the class ExportHTMLAction method getWorkedTools.
@NotNull
private Set<InspectionToolWrapper> getWorkedTools(@NotNull InspectionNode node) {
final Set<InspectionToolWrapper> result = new HashSet<>();
final InspectionToolWrapper wrapper = node.getToolWrapper();
if (myView.getCurrentProfileName() == null) {
result.add(wrapper);
return result;
}
final String shortName = wrapper.getShortName();
final GlobalInspectionContextImpl context = myView.getGlobalInspectionContext();
final Tools tools = context.getTools().get(shortName);
if (tools != null) {
//dummy entry points tool
for (ScopeToolState state : tools.getTools()) {
InspectionToolWrapper toolWrapper = state.getTool();
result.add(toolWrapper);
}
}
return result;
}
use of com.intellij.codeInspection.ex.GlobalInspectionContextImpl in project intellij-community by JetBrains.
the class ViewOfflineResultsAction method showOfflineView.
@NotNull
public static InspectionResultsView showOfflineView(@NotNull Project project, @NotNull Map<String, Map<String, Set<OfflineProblemDescriptor>>> resMap, @NotNull InspectionProfileImpl inspectionProfile, @NotNull String title) {
final AnalysisScope scope = new AnalysisScope(project);
final InspectionManagerEx managerEx = (InspectionManagerEx) InspectionManager.getInstance(project);
final GlobalInspectionContextImpl context = managerEx.createNewGlobalContext(false);
context.setExternalProfile(inspectionProfile);
context.setCurrentScope(scope);
context.initializeTools(new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
final InspectionResultsView view = new InspectionResultsView(context, new OfflineInspectionRVContentProvider(resMap, project));
((RefManagerImpl) context.getRefManager()).startOfflineView();
context.addView(view, title, true);
view.update();
return view;
}
use of com.intellij.codeInspection.ex.GlobalInspectionContextImpl in project intellij-community by JetBrains.
the class CodeInspectionAction method runInspections.
protected void runInspections(Project project, AnalysisScope scope) {
scope.setSearchInLibraries(false);
FileDocumentManager.getInstance().saveAllDocuments();
final GlobalInspectionContextImpl inspectionContext = getGlobalInspectionContext(project);
inspectionContext.setExternalProfile(myExternalProfile);
inspectionContext.setCurrentScope(scope);
inspectionContext.doInspections(scope);
}
Aggregations