diff --git a/src/main/java/org/sonarlint/intellij/editor/EditorDecorator.kt b/src/main/java/org/sonarlint/intellij/editor/EditorDecorator.kt index 7e40f4453..cd4fab27c 100644 --- a/src/main/java/org/sonarlint/intellij/editor/EditorDecorator.kt +++ b/src/main/java/org/sonarlint/intellij/editor/EditorDecorator.kt @@ -23,6 +23,7 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfo import com.intellij.codeInsight.daemon.impl.HighlightInfoType import com.intellij.codeInsight.daemon.impl.UpdateHighlightersUtil import com.intellij.lang.annotation.HighlightSeverity +import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.components.Service import com.intellij.openapi.editor.Document import com.intellij.openapi.editor.Editor @@ -51,22 +52,15 @@ class EditorDecorator(private val project: Project) { private var blinker: RangeBlinker? = null fun removeHighlights() { - runOnUiThread(project) { - currentHighlightedDoc.forEach { - clearSecondaryLocationNumbers(it) - UpdateHighlightersUtil.setHighlightersToEditor( - project, - it, - 0, - it.textLength, - emptyList(), - null, - HIGHLIGHT_GROUP_ID - ) - } - currentHighlightedDoc.clear() - stopBlinking() + ApplicationManager.getApplication().assertIsDispatchThread() + currentHighlightedDoc.forEach { + clearSecondaryLocationNumbers(it) + UpdateHighlightersUtil.setHighlightersToEditor( + project, it, 0, it.textLength, emptyList(), null, HIGHLIGHT_GROUP_ID + ) } + currentHighlightedDoc.clear() + stopBlinking() } private fun stopBlinking() { @@ -123,12 +117,14 @@ class EditorDecorator(private val project: Project) { } private fun updateHighlights(highlights: List) { - removeHighlights() - highlights.groupBy({ it.document }, { it.highlightInfo }) - .forEach { (doc, hs) -> - highlightInDocument(hs, doc) - blinkLocations(hs, doc) - } + runOnUiThread(project) { + removeHighlights() + highlights.groupBy({ it.document }, { it.highlightInfo }) + .forEach { (doc, hs) -> + highlightInDocument(hs, doc) + blinkLocations(hs, doc) + } + } } private fun highlightInDocument(highlights: List, document: Document) { @@ -152,8 +148,14 @@ class EditorDecorator(private val project: Project) { return } val marker = location.range!! - getEditors(marker.document) - .forEach { it.inlayModel.addInlineElement(marker.startOffset, SecondaryLocationIndexRenderer(location, index, selected)) } + runOnUiThread(project) { + getEditors(marker.document).forEach { + it.inlayModel.addInlineElement( + marker.startOffset, + SecondaryLocationIndexRenderer(location, index, selected) + ) + } + } } private fun getEditors(document: Document): List { diff --git a/src/main/java/org/sonarlint/intellij/ui/AbstractIssuesPanel.java b/src/main/java/org/sonarlint/intellij/ui/AbstractIssuesPanel.java index 2f769bdcc..8d26b05df 100644 --- a/src/main/java/org/sonarlint/intellij/ui/AbstractIssuesPanel.java +++ b/src/main/java/org/sonarlint/intellij/ui/AbstractIssuesPanel.java @@ -83,30 +83,6 @@ private void createFindingDetailsPanel() { findingDetailsPanel = new FindingDetailsPanel(project, this, FindingKind.ISSUE); } - private void issueTreeSelectionChanged() { - var selectedNodes = tree.getSelectedNodes(IssueNode.class, null); - if (selectedNodes.length > 0) { - var issue = selectedNodes[0].issue(); - findingDetailsPanel.show(issue); - } else { - findingDetailsPanel.clear(); - var highlighting = SonarLintUtils.getService(project, EditorDecorator.class); - highlighting.removeHighlights(); - } - } - - private void oldIssueTreeSelectionChanged() { - var selectedNodes = oldTree.getSelectedNodes(IssueNode.class, null); - if (selectedNodes.length > 0) { - var issue = selectedNodes[0].issue(); - findingDetailsPanel.show(issue); - } else { - findingDetailsPanel.clear(); - var highlighting = SonarLintUtils.getService(project, EditorDecorator.class); - highlighting.removeHighlights(); - } - } - protected void setToolbar(Collection actions) { if (mainToolbar != null) { mainToolbar.setTargetComponent(null); @@ -131,7 +107,6 @@ private void createIssuesTree() { treeBuilder = new IssueTreeModelBuilder(project); var model = treeBuilder.createModel(false); tree = new IssueTree(project, model); - tree.addTreeSelectionListener(e -> issueTreeSelectionChanged()); tree.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { @@ -148,7 +123,6 @@ private void createOldIssuesTree() { oldTreeBuilder = new IssueTreeModelBuilder(project); var model = oldTreeBuilder.createModel(true); oldTree = new IssueTree(project, model); - oldTree.addTreeSelectionListener(e -> oldIssueTreeSelectionChanged()); oldTree.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { diff --git a/src/main/java/org/sonarlint/intellij/ui/vulnerabilities/TaintVulnerabilitiesPanel.kt b/src/main/java/org/sonarlint/intellij/ui/vulnerabilities/TaintVulnerabilitiesPanel.kt index e267e2d6f..9d59c6e28 100644 --- a/src/main/java/org/sonarlint/intellij/ui/vulnerabilities/TaintVulnerabilitiesPanel.kt +++ b/src/main/java/org/sonarlint/intellij/ui/vulnerabilities/TaintVulnerabilitiesPanel.kt @@ -335,7 +335,6 @@ class TaintVulnerabilitiesPanel(private val project: Project) : SimpleToolWindow } else { issue.module?.let { module -> rulePanel.setSelectedFinding(module, issue, issue.getRuleKey(), issue.getRuleDescriptionContextKey()) } ?: rulePanel.clear() - highlighting.highlight(issue) } } }