From 7b341bae97791c8b07aa7f3c989a04c413fca808 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Tue, 12 Nov 2024 16:25:43 +0100 Subject: [PATCH] do not show highlight tooltips on hover on file-level info because they are extremely in the way otherwise; to fix IJPL-171293 File-Level errors are showing an unneeded tooltip on mouse moves GitOrigin-RevId: d0e66a8a7da278bca18cef81d169d63ec10e7748 --- .../daemon/impl/DaemonCodeAnalyzerImpl.java | 20 ++++++++++++++++--- .../daemon/impl/ShowIntentionsPass.java | 2 +- .../editor/EditorMouseHoverPopupManager.java | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java index 8072fc8417f8..291546a67dda 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java @@ -998,7 +998,16 @@ public final class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx boolean includeFixRange, boolean highestPriorityOnly, @NotNull HighlightSeverity minSeverity) { - HighlightByOffsetProcessor processor = new HighlightByOffsetProcessor(highestPriorityOnly); + return findHighlightsByOffset(document, offset, includeFixRange, highestPriorityOnly, minSeverity, true); + } + @ApiStatus.Internal + public @Nullable HighlightInfo findHighlightsByOffset(@NotNull Document document, + int offset, + boolean includeFixRange, + boolean highestPriorityOnly, + @NotNull HighlightSeverity minSeverity, + boolean includeFileLevel) { + HighlightByOffsetProcessor processor = new HighlightByOffsetProcessor(highestPriorityOnly, includeFileLevel); processHighlightsNearOffset(document, myProject, minSeverity, offset, includeFixRange, processor); return processor.getResult(); } @@ -1035,14 +1044,19 @@ public final class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx static final class HighlightByOffsetProcessor implements Processor { private final List foundInfoList = new SmartList<>(); private final boolean highestPriorityOnly; + private final boolean myIncludeFileLevel; - HighlightByOffsetProcessor(boolean highestPriorityOnly) { + HighlightByOffsetProcessor(boolean highestPriorityOnly, boolean includeFileLevel) { this.highestPriorityOnly = highestPriorityOnly; + myIncludeFileLevel = includeFileLevel; } @Override public boolean process(@NotNull HighlightInfo info) { - if (info.getSeverity() == HighlightInfoType.ELEMENT_UNDER_CARET_SEVERITY || info.type == HighlightInfoType.TODO) { + if (info.getSeverity() == HighlightInfoType.ELEMENT_UNDER_CARET_SEVERITY + || info.type == HighlightInfoType.TODO + || !myIncludeFileLevel && info.isFileLevelAnnotation() + ) { return true; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java index 3f7620a7c33d..aa44a7db0059 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java @@ -298,7 +298,7 @@ public final class ShowIntentionsPass extends TextEditorHighlightingPass impleme intentions.setOffset(offset); List fixes = new ArrayList<>(); - DaemonCodeAnalyzerImpl.HighlightByOffsetProcessor highestPriorityInfoFinder = new DaemonCodeAnalyzerImpl.HighlightByOffsetProcessor(true); + DaemonCodeAnalyzerImpl.HighlightByOffsetProcessor highestPriorityInfoFinder = new DaemonCodeAnalyzerImpl.HighlightByOffsetProcessor(true, true); List infos = new ArrayList<>(); List additionalInfos = new ArrayList<>(); Document document = hostEditor.getDocument(); diff --git a/platform/lang-impl/src/com/intellij/openapi/editor/EditorMouseHoverPopupManager.java b/platform/lang-impl/src/com/intellij/openapi/editor/EditorMouseHoverPopupManager.java index 4954d1d3dd27..c87e7f9b7070 100644 --- a/platform/lang-impl/src/com/intellij/openapi/editor/EditorMouseHoverPopupManager.java +++ b/platform/lang-impl/src/com/intellij/openapi/editor/EditorMouseHoverPopupManager.java @@ -345,7 +345,7 @@ public class EditorMouseHoverPopupManager implements Disposable { DaemonCodeAnalyzerImpl daemonCodeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project); boolean highestPriorityOnly = !Registry.is("ide.tooltip.showAllSeverities"); info = daemonCodeAnalyzer - .findHighlightsByOffset(editor.getDocument(), offset, false, highestPriorityOnly, HighlightInfoType.SYMBOL_TYPE_SEVERITY); + .findHighlightsByOffset(editor.getDocument(), offset, false, highestPriorityOnly, HighlightInfoType.SYMBOL_TYPE_SEVERITY, false); } PsiElement elementForQuickDoc = findElementForQuickDoc(editor, offset, project);