fix: leave free-form string values at the default color (#467 #342)#483
Closed
SJrX wants to merge 1 commit into
Closed
fix: leave free-form string values at the default color (#467 #342)#483SJrX wants to merge 1 commit into
SJrX wants to merge 1 commit into
Conversation
The default heuristic mapped RegexTerminal -> IDENTIFIER, so free-form values like Description= and interface names (Bond=) got recoloured, which felt wrong — those should keep the editor's normal value color. Make RegexTerminal uncoloured by default. - defaultRole: RegexTerminal now falls through to null (no coloring). - Drop the Identifier descriptor + tag + demo example from the color settings page, since nothing uses the IDENTIFIER role by default now. The Role and its key are kept for grammars that opt in explicitly via Labeled later (e.g. a single-token User=). Refs #467 #342 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 21, 2026
SJrX
pushed a commit
that referenced
this pull request
Jun 29, 2026
IDENTIFIER was defined (enum value, GRAMMAR_IDENTIFIER attributes key, annotator branch) but never produced: defaultRole never returns it, nothing wraps a value in Labeled(Role.IDENTIFIER), and it has no color-settings descriptor. It was the role intended for free-form names — but #483 settled that free-form values keep the editor's default color, which leaves IDENTIFIER with no purpose. Remove it; the taxonomy is ENUM / LITERAL / OPERATOR (plus uncoloured default).
SJrX
added a commit
that referenced
this pull request
Jun 29, 2026
* feat: grammar coloring engine layer — roles, defaults, optional Labeled (#467 #342) Adds the (pure, IntelliJ-free) substrate for grammar-based syntax coloring. Coloring is automatic and needs NO grammar changes; an optional wrapper handles composite spans. - Role { ENUM, LITERAL, OPERATOR, IDENTIFIER } + Region(start, end, role). - defaultRole(terminal): IntegerTerminal -> LITERAL; Literal/FlexibleLiteralChoice -> ENUM, or OPERATOR when all choices are punctuation (":", "+", "=", "~", "/", ...); RegexTerminal -> IDENTIFIER; whitespace/other -> uncoloured. - Labeled(role, inner): optional, transparent wrapper. Matching is delegated to inner unchanged (SyntacticMatch/SemanticMatch/parse), so it affects only colour — e.g. Labeled(LITERAL, IPV4_ADDR) paints 127.0.0.1 as one literal instead of per-octet. - Parse gains a defaulted `regions` field; the merging combinators (Seq, ZeroOrMore, OneOrMore, Repeat) thread it. colorize(value) returns labeled regions plus per-token defaults for anything not inside a labeled region. Role -> TextAttributes mapping is deliberately left to the IntelliJ layer (next MR: annotator + color settings, behind the experimental flag). Tests: default roles; automatic colouring of the unchanged RestrictAddressFamilies grammar (operator/enum, whitespace uncoloured); Labeled collapsing an IPv4 address to one LITERAL; and Labeled being transparent to validation. Refs #467 #342 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat: render grammar value coloring + color settings (#467 #342) The rendering half of grammar coloring — now visible in the editor behind the flag. - UnitFileHighlighter: four user-customizable TextAttributesKeys, one per Role (GRAMMAR_ENUM/LITERAL/OPERATOR/IDENTIFIER), defaulting to CONSTANT/NUMBER/ OPERATION_SIGN/IDENTIFIER colors. - GrammarValueColorAnnotator: flag-gated; for grammar-backed options it runs colorize() and paints each Region with the matching attributes key. No-op when the flag is off. - UnitFileColorSettings: adds the four roles under "Value" (customizable + themed) and extends the preview with grammar examples — RestrictAddressFamilies, SocketBindAllow/ Deny, IPAddressAllow, RootImagePolicy — via highlighting tags. - Combinators: IPV4_ADDR / IPV6_ADDR wrapped in Labeled(LITERAL) so an address colours as one literal span rather than per-octet/hextet (transparent to matching; full suite green confirms validation/completion unchanged). colorize() now dedupes identical regions (nested Labeled, e.g. IPv4 suffix inside IPv6). Tests: GrammarValueColorAnnotatorTest (SocketBindAllow coloured by role; an IP as one literal span; nothing when the flag is off) and the extended ColoringTest. Refs #467 #342 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs: show an identifier example (Description=) in the color settings preview (#467 #342) The color-settings preview had grammar examples for enum/literal/operator but none for the Identifier role, so clicking "Value//Identifier (grammar)" highlighted nothing. Tag the [Unit] Description= value (a config_parse_unit_string_printf identifier) so the role has a visible example. Refs #467 #342 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix: leave free-form string values at the default color (#467 #342) The default heuristic mapped RegexTerminal -> IDENTIFIER, so free-form values like Description= and interface names (Bond=) got recoloured, which felt wrong — those should keep the editor's normal value color. Make RegexTerminal uncoloured by default. - defaultRole: RegexTerminal now falls through to null (no coloring). - Drop the Identifier descriptor + tag + demo example from the color settings page, since nothing uses the IDENTIFIER role by default now. The Role and its key are kept for grammars that opt in explicitly via Labeled later (e.g. a single-token User=). Refs #467 #342 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test: filter INFORMATION highlights from GrammarParseEngineInspectionTest The value-color annotator adds INFORMATION-severity coloring highlights when the experimental flag is on, which inflates doHighlighting() counts. Count only the inspection problems (severity != INFORMATION), matching the value-coloring annotator. * refactor: drop the unused Role.IDENTIFIER coloring role IDENTIFIER was defined (enum value, GRAMMAR_IDENTIFIER attributes key, annotator branch) but never produced: defaultRole never returns it, nothing wraps a value in Labeled(Role.IDENTIFIER), and it has no color-settings descriptor. It was the role intended for free-form names — but #483 settled that free-form values keep the editor's default color, which leaves IDENTIFIER with no purpose. Remove it; the taxonomy is ENUM / LITERAL / OPERATOR (plus uncoloured default). --------- Co-authored-by: Steve Ramage <gitcommits@sjrx.net> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The default coloring heuristic mapped
RegexTerminal → IDENTIFIER, so free-form values —Description=, interface names likeBond=bond1, etc. — got recolored as identifiers. That felt wrong: those should keep the editor's normal value color. MakeRegexTerminaluncolored by default.Changes
defaultRole:RegexTerminalnow falls through tonull(no grammar coloring) — free-form names/strings keep the default value color.Description=example, since nothing uses theIDENTIFIERrole by default anymore.Role.IDENTIFIERenum and itsGRAMMAR_IDENTIFIERkey, so a grammar can still opt a specific field in viaLabeled(Role.IDENTIFIER, …)later (e.g. a single-token, can't-be-space-separated field likeUser=) — at which point we'd re-add the descriptor + example.Enum / Literal / Operator coloring is unchanged. Full suite green.
Refs #467 #342
🤖 Generated with Claude Code