Skip to content

Commit

Permalink
Replace custom HighlightSeverity with INFORMATION
Browse files Browse the repository at this point in the history
  • Loading branch information
l2dy committed Aug 17, 2024
1 parent d7ec651 commit 1b39899
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1b39899

Please sign in to comment.