platform: ignore ast loading for current file

"inspect all" can call inspections for file without loaded ast
This commit is contained in:
anstarovoyt
2018-10-22 20:07:48 +03:00
parent 14ac7ba521
commit 127a3aa4f2
@@ -253,13 +253,14 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
final List<InspectionContext> init = new ArrayList<>();
List<Map.Entry<LocalInspectionToolWrapper, Set<String>>> entries = new ArrayList<>(toolToSpecifiedLanguageIds.entrySet());
PsiFile file = session.getFile();
Processor<Map.Entry<LocalInspectionToolWrapper, Set<String>>> processor = pair ->
AstLoadingFilter.disallowTreeLoading(() -> {
AstLoadingFilter.disallowTreeLoading(() -> AstLoadingFilter.<Boolean, RuntimeException>forceAllowTreeLoading(file, () -> {
LocalInspectionToolWrapper toolWrapper = pair.getKey();
Set<String> dialectIdsSpecifiedForTool = pair.getValue();
runToolOnElements(toolWrapper, dialectIdsSpecifiedForTool, iManager, isOnTheFly, indicator, elements, session, init, elementDialectIds);
return true;
});
}));
boolean result = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(entries, indicator, processor);
if (!result) throw new ProcessCanceledException();
return init;