From 1b39899906f754b89bee3268255e8db0229d4b06 Mon Sep 17 00:00:00 2001 From: Zero King Date: Sun, 18 Aug 2024 00:04:50 +0800 Subject: [PATCH] Replace custom HighlightSeverity with INFORMATION --- .../org/rust/ide/annotator/RsCfgDisabledCodeAnnotator.kt | 7 +------ .../rust/ide/annotator/RsHighlightingMutableAnnotator.kt | 9 +-------- .../ide/annotator/RsMacroExpansionHighlightingPass.kt | 3 ++- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/main/kotlin/org/rust/ide/annotator/RsCfgDisabledCodeAnnotator.kt b/src/main/kotlin/org/rust/ide/annotator/RsCfgDisabledCodeAnnotator.kt index 76164cc814..946ebcb97d 100644 --- a/src/main/kotlin/org/rust/ide/annotator/RsCfgDisabledCodeAnnotator.kt +++ b/src/main/kotlin/org/rust/ide/annotator/RsCfgDisabledCodeAnnotator.kt @@ -24,7 +24,7 @@ class RsCfgDisabledCodeAnnotator : AnnotatorBase() { private fun AnnotationHolder.createCondDisabledAnnotation() { val color = RsColor.CFG_DISABLED_CODE - val severity = if (isUnitTestMode) color.testSeverity else CONDITIONALLY_DISABLED_CODE_SEVERITY + val severity = if (isUnitTestMode) color.testSeverity else HighlightSeverity.INFORMATION newAnnotation(severity, RsBundle.message("text.conditionally.disabled.code")) .textAttributes(color.textAttributesKey) @@ -43,10 +43,5 @@ class RsCfgDisabledCodeAnnotator : AnnotatorBase() { && element.isDisabledCfgAttrAttribute(crate) && element.owner?.isEnabledByCfgSelfOrInAttrProcMacroBody(crate) == true } - - val CONDITIONALLY_DISABLED_CODE_SEVERITY = HighlightSeverity( - "CONDITIONALLY_DISABLED_CODE", - HighlightSeverity.INFORMATION.myVal + 1 - ) } } diff --git a/src/main/kotlin/org/rust/ide/annotator/RsHighlightingMutableAnnotator.kt b/src/main/kotlin/org/rust/ide/annotator/RsHighlightingMutableAnnotator.kt index 717e99c3da..0ce72311e6 100644 --- a/src/main/kotlin/org/rust/ide/annotator/RsHighlightingMutableAnnotator.kt +++ b/src/main/kotlin/org/rust/ide/annotator/RsHighlightingMutableAnnotator.kt @@ -61,19 +61,12 @@ class RsHighlightingMutableAnnotator : AnnotatorBase() { } private fun addHighlightingAnnotation(holder: AnnotationHolder, target: PsiElement, key: RsColor) { - val annotationSeverity = if (isUnitTestMode) key.testSeverity else MUTABLE_HIGHLIGHTING + val annotationSeverity = if (isUnitTestMode) key.testSeverity else HighlightSeverity.INFORMATION holder.newSilentAnnotation(annotationSeverity) .range(target.textRange) .textAttributes(key.textAttributesKey).create() } - - companion object { - private val MUTABLE_HIGHLIGHTING = HighlightSeverity( - "MUTABLE_HIGHLIGHTING", - HighlightSeverity.INFORMATION.myVal + 1 - ) - } } private val RsElement.isMut: Boolean diff --git a/src/main/kotlin/org/rust/ide/annotator/RsMacroExpansionHighlightingPass.kt b/src/main/kotlin/org/rust/ide/annotator/RsMacroExpansionHighlightingPass.kt index 22d3274b82..8661573100 100644 --- a/src/main/kotlin/org/rust/ide/annotator/RsMacroExpansionHighlightingPass.kt +++ b/src/main/kotlin/org/rust/ide/annotator/RsMacroExpansionHighlightingPass.kt @@ -12,6 +12,7 @@ import com.intellij.codeInsight.daemon.impl.* import com.intellij.lang.annotation.Annotation import com.intellij.lang.annotation.AnnotationSession import com.intellij.lang.annotation.Annotator +import com.intellij.lang.annotation.HighlightSeverity import com.intellij.openapi.editor.Document import com.intellij.openapi.editor.Editor import com.intellij.openapi.progress.ProgressIndicator @@ -179,7 +180,7 @@ class RsMacroExpansionHighlightingPass( for (mappedRange in cfgDisabledMappedRanges) { val color = RsColor.CFG_DISABLED_CODE - val severity = if (isUnitTestMode) color.testSeverity else RsCfgDisabledCodeAnnotator.CONDITIONALLY_DISABLED_CODE_SEVERITY + val severity = if (isUnitTestMode) color.testSeverity else HighlightSeverity.INFORMATION results += HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION) .severity(severity) .textAttributes(color.textAttributesKey)