fix: SC refs in multi-line headers, abbrev refs on indented lines, transitive refs, isWordPattern (#38)#41
Merged
theodevelop merged 8 commits intodevfrom Apr 3, 2026
Merged
Conversation
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.
Type of change
What does this PR do?
Fixes four false positives discovered while testing with a real-world Flex file (gnucobol's
pplex.l):SC refs in multi-line block headers —
<SC_A,\nSC_B,\nSC_C>{only counted the closing SC; the others had 0 refs, triggering falseflex/unused-scand showing "0 references" in Code Lens.Abbrev refs on indented rule lines —
{ABBR}on lines indented inside a<SC>{ }block was not counted as an abbreviation reference (actionStartwas computed before stripping{name}tokens, so the leading whitespace before{ABBR}itself was misidentified as the action opener).Transitive abbreviation references — abbreviations used only inside another abbreviation's definition (e.g.,
ALNUM_LITERAL {ALNUM_LITERAL_Q}|{ALNUM_LITERAL_A}) were never recorded as referenced, producing falseflex/unused-abbrev. The parser now scans each definition body for{name}references.isWordPatternwith mandatory non-class groups — patterns like[_0-9A-Z]+(\.[_0-9A-Z]+)+were classified as "word patterns" because the heuristic only checked the beginning. Such patterns require a literal dot and cannot match simple keyword strings ("IN","OF"), yet they triggered falseflex/unreachable-rulefor every keyword rule that followed.isWordPatternnow requires the entire pattern to consist solely of character-class groups.Related issue
Closes #38
How to test manually
<A,\nB,\nC>{) → Code Lens must show correct reference counts for all SCs; noflex/unused-sc.{ABBR}inside an indented SC block → noflex/unused-abbrev.FOO [0-9]andBAR {FOO}+, use only{BAR}in rules → noflex/unused-abbrevforFOO.[A-Z]+(\.[A-Z]+)+before keyword rules"IN","OF"→ noflex/unreachable-rule.Checklist
npm run compilepasses with no new errors