mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Remove the doHighlight command and its corresponding tests.
The initial purpose of doHighlight was to measure the time it takes to apply different text attributes (color, style, etc.) to tokens. However, there hasn't been (and still isn't) a generic way to achieve this effectively. Currently, this command triggers HighlightVisitorBasedInspection, which is essentially a "mock" inspection used in Global Analysis tools (such as inspect.sh, Qodana, etc.). This inspection combines three functionalities—syntax error, annotator, and generic error—into one. As a result, the highlighting produced by this command is a very rough estimation, if not just random values. Highlighting in general is handled by the editor, which leverages information from the parser, annotators, additional passes, and specific inspections (e.g., dead code, which has a unique severity that makes the code appear grey). At this point, we do not have a clear way to make doHighlight work correctly, nor are we certain it's needed at all. GitOrigin-RevId: 8c821f456e867395bb6de55a142a000cfc3a50a9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7ced30d45f
commit
1d1d3d2238
-8
@@ -361,14 +361,6 @@ fun <T : CommandChain> T.doComplete(times: Int): T = apply {
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : CommandChain> T.doHighlightingWarmup(): T = apply {
|
||||
addCommand("${CMD_PREFIX}doHighlight", WARMUP)
|
||||
}
|
||||
|
||||
fun <T : CommandChain> T.doHighlighting(): T = apply {
|
||||
addCommand("${CMD_PREFIX}doHighlight")
|
||||
}
|
||||
|
||||
fun <T : CommandChain> T.openProjectView(): T = apply {
|
||||
addCommand("${CMD_PREFIX}openProjectView")
|
||||
}
|
||||
|
||||
-1
@@ -60,7 +60,6 @@ public final class BaseCommandProvider implements CommandProvider {
|
||||
Map.entry(SearchEverywhereCommand.PREFIX, SearchEverywhereCommand::new),
|
||||
Map.entry(SelectFileInProjectViewCommand.PREFIX, SelectFileInProjectViewCommand::new),
|
||||
Map.entry(ExpandProjectMenuCommand.PREFIX, ExpandProjectMenuCommand::new),
|
||||
Map.entry(DoHighlighting.PREFIX, DoHighlighting::new),
|
||||
Map.entry(ReloadFilesCommand.PREFIX, ReloadFilesCommand::new),
|
||||
Map.entry(AddFileCommand.PREFIX, AddFileCommand::new),
|
||||
Map.entry(RenameFileCommand.PREFIX, RenameFileCommand::new),
|
||||
|
||||
-90
@@ -1,90 +0,0 @@
|
||||
package com.jetbrains.performancePlugin.commands;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightVisitorBasedInspection;
|
||||
import com.intellij.codeInspection.GlobalInspectionContext;
|
||||
import com.intellij.codeInspection.GlobalInspectionTool;
|
||||
import com.intellij.codeInspection.InspectionEngine;
|
||||
import com.intellij.codeInspection.InspectionManager;
|
||||
import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.playback.PlaybackContext;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.platform.diagnostic.telemetry.helpers.TraceKt;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.concurrency.AppExecutorUtil;
|
||||
import com.jetbrains.performancePlugin.PerformanceTestSpan;
|
||||
import com.jetbrains.performancePlugin.utils.ActionCallbackProfilerStopper;
|
||||
import io.opentelemetry.context.Context;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.concurrency.Promise;
|
||||
import org.jetbrains.concurrency.Promises;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import static com.intellij.psi.PsiManager.getInstance;
|
||||
|
||||
/**
|
||||
* Command runs highlighting pass.
|
||||
* Runs all highlighting passes. Can't be invoked multiple times in a row since it drops caches before run.
|
||||
* Example: %doHighlighting
|
||||
*/
|
||||
public final class DoHighlighting extends PerformanceCommand {
|
||||
public static final String NAME = "doHighlight";
|
||||
public static final String PREFIX = CMD_PREFIX + NAME;
|
||||
|
||||
public static final String SPAN_NAME = "highlighting";
|
||||
public static final int MILLIS_IN_NANO = 1000000;
|
||||
|
||||
public DoHighlighting(@NotNull String text, int line) {
|
||||
super(text, line);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Promise<Object> _execute(@NotNull PlaybackContext context) {
|
||||
ActionCallback actionCallback = new ActionCallbackProfilerStopper();
|
||||
ApplicationManager.getApplication().invokeAndWait(Context.current().wrap(() -> {
|
||||
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();
|
||||
TraceKt.use(PerformanceTestSpan.TRACER.spanBuilder(SPAN_NAME), span -> {
|
||||
GlobalInspectionTool tool = new HighlightVisitorBasedInspection()
|
||||
.setHighlightErrorElements(true).setRunAnnotators(true).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())));
|
||||
return null;
|
||||
});
|
||||
actionCallback.setDone();
|
||||
return null;
|
||||
})).wrapProgress(new DaemonProgressIndicator()).submit(AppExecutorUtil.getAppExecutorService());
|
||||
}));
|
||||
return Promises.toPromise(actionCallback);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user