From 2713ffd669707e0c0121af1f8151debc726bda8f Mon Sep 17 00:00:00 2001 From: Alexey Kryuchkov Date: Mon, 7 Apr 2025 15:15:40 +0400 Subject: [PATCH] Simplify StoreHighlightingResultsCommand - An unnecessary loop for all severities was removed - Added storing of toolId - Added assertion document length is still greater than highlightInfo actualStartOffset GitOrigin-RevId: e6dfc645a2c8323df3bf3f940a3159c1f1d39595 --- .../commands/StoreHighlightingResultsCommand.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/StoreHighlightingResultsCommand.kt b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/StoreHighlightingResultsCommand.kt index ee5941d8ea0c..bdeadff879e8 100644 --- a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/StoreHighlightingResultsCommand.kt +++ b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/StoreHighlightingResultsCommand.kt @@ -1,7 +1,6 @@ package com.jetbrains.performancePlugin.commands import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl -import com.intellij.codeInsight.daemon.impl.SeverityRegistrar import com.intellij.openapi.application.EDT import com.intellij.openapi.application.PathManager import com.intellij.openapi.application.writeIntentReadAction @@ -17,6 +16,7 @@ import org.jetbrains.annotations.NonNls import java.io.File import kotlin.io.path.div +@Suppress("MISSING_DEPENDENCY_SUPERCLASS_IN_TYPE_ARGUMENT") class StoreHighlightingResultsCommand(text: String, line: Int) : PlaybackCommandCoroutineAdapter(text, line) { @@ -42,11 +42,13 @@ class StoreHighlightingResultsCommand(text: String, line: Int) : PlaybackCommand writeIntentReadAction { val psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.document) require(psiFile != null) - for (severity in SeverityRegistrar.getSeverityRegistrar(project).allSeverities) { - val highlights = DaemonCodeAnalyzerImpl.getHighlights(editor.document, severity, project) - highlights.forEach { highlight -> - fileForStoringHighlights.appendText("${severity}☆${highlight.description}☆${editor.document.getLineNumber(highlight.actualStartOffset)}" + "\n") + val highlights = DaemonCodeAnalyzerImpl.getHighlights(editor.document, null, project) + highlights.forEach { highlight -> + assert(editor.document.textLength > highlight.actualStartOffset) { + "Highlight start offset ${editor.document.textLength} less than document text length ${highlight.actualStartOffset}" } + fileForStoringHighlights + .appendText("${highlight.severity}☆${highlight.description}☆${editor.document.getLineNumber(highlight.actualStartOffset)}☆${highlight.toolId}" + "\n") } } }