fix $76 add support for enum constants highlighting and initial enum documentation

This commit is contained in:
sergeych committed 2025-12-05 00:30:32 +01:00
1 parent 84f2f8fac4
commit 65a7555e93
7 files changed
+120 -5

No files matched your search

@@ -262,6 +262,18 @@ class LyngExternalAnnotator : ExternalAnnotator<LyngExternalAnnotator.Input, Lyn
}
}
// Map Enum constants from token highlighter to IDEA enum constant color
run {
val tokens = try { SimpleLyngHighlighter().highlight(text) } catch (_: Throwable) { emptyList() }
for (s in tokens) if (s.kind == HighlightKind.EnumConstant) {
val start = s.range.start
val end = s.range.endExclusive
if (start in 0..end && end <= text.length && start < end) {
putRange(start, end, LyngHighlighterColors.ENUM_CONSTANT)
}
}
}
// Build spell index payload: identifiers from symbols + references; comments/strings from simple highlighter
val idRanges = mutableSetOf<IntRange>()
try {
@@ -65,6 +65,7 @@ class LyngColorSettingsPage : ColorSettingsPage {
AttributesDescriptor("Type (semantic)", LyngHighlighterColors.TYPE),
AttributesDescriptor("Namespace (semantic)", LyngHighlighterColors.NAMESPACE),
AttributesDescriptor("Parameter (semantic)", LyngHighlighterColors.PARAMETER),
AttributesDescriptor("Enum constant (semantic)", LyngHighlighterColors.ENUM_CONSTANT),
)
override fun getColorDescriptors(): Array<ColorDescriptor> = ColorDescriptor.EMPTY_ARRAY
@@ -77,4 +77,9 @@ object LyngHighlighterColors {
val ANNOTATION: TextAttributesKey = TextAttributesKey.createTextAttributesKey(
"LYNG_ANNOTATION", DefaultLanguageHighlighterColors.METADATA
)
// Enum constant (declaration or usage)
val ENUM_CONSTANT: TextAttributesKey = TextAttributesKey.createTextAttributesKey(
"LYNG_ENUM_CONSTANT", DefaultLanguageHighlighterColors.STATIC_FIELD
)
}