Promise<Object> (@NotNull PlaybackContext context) { ActionCallback actionCallback = new ActionCallbackProfilerStopper(); ApplicationManager.getApplication().invokeAndWait(Context.current().wrap(() -> { boolean highlightErrorElements = true; boolean runAnnotators = true; Project project = context.getProject(); final Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); if (editor == null) { actionCallback.reject("Editor is not open"); return; } PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (psiFile == null) { actionCallback.reject("Missing PSI file in the editor"); return; } getInstance(project).dropPsiCaches(); ReadAction.nonBlocking(Context.current().wrap((Callable<Void>)() -> { long start = System.nanoTime(); TraceUtil.runWithSpanThrows(PerformanceTestSpan.TRACER, SPAN_NAME, span -> { GlobalInspectionTool tool = new HighlightVisitorBasedInspection() .setHighlightErrorElements(highlightErrorElements).setRunAnnotators(runAnnotators).setRunVisitors(false); InspectionManager inspectionManager = InspectionManager.getInstance(project); GlobalInspectionContext globalContext = inspectionManager.createNewGlobalContext(); InspectionEngine.runInspectionOnFile(psiFile, new GlobalInspectionToolWrapper(tool), globalContext); span.setAttribute("lines", editor.getDocument().getLineCount()); long stop = System.nanoTime(); span.setAttribute("timeToLines", (double)(stop - start) / MILLIS_IN_NANO / (Math.max(1, editor.getDocument().getLineCount()))); }); actionCallback.setDone(); return null; })).wrapProgress(new DaemonProgressIndicator()).submit(AppExecutorUtil.getAppExecutorService()); })); return Promises.toPromise(actionCallback); }