Skip to content

fix: SC refs in multi-line headers, abbrev refs on indented lines, transitive refs, isWordPattern (#38)#41

Merged
theodevelop merged 8 commits intodevfrom
fix/issue-38
Apr 3, 2026
Merged

fix: SC refs in multi-line headers, abbrev refs on indented lines, transitive refs, isWordPattern (#38)#41
theodevelop merged 8 commits intodevfrom
fix/issue-38

Conversation

@theodevelop
Copy link
Copy Markdown
Owner

Type of change

  • Bug fix

What does this PR do?

Fixes four false positives discovered while testing with a real-world Flex file (gnucobol's pplex.l):

  1. SC refs in multi-line block headers<SC_A,\nSC_B,\nSC_C>{ only counted the closing SC; the others had 0 refs, triggering false flex/unused-sc and showing "0 references" in Code Lens.

  2. Abbrev refs on indented rule lines{ABBR} on lines indented inside a <SC>{ } block was not counted as an abbreviation reference (actionStart was computed before stripping {name} tokens, so the leading whitespace before {ABBR} itself was misidentified as the action opener).

  3. 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 false flex/unused-abbrev. The parser now scans each definition body for {name} references.

  4. isWordPattern with 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 false flex/unreachable-rule for every keyword rule that followed. isWordPattern now requires the entire pattern to consist solely of character-class groups.

Related issue

Closes #38

How to test manually

  • Open a Flex file using multi-line SC block headers (<A,\nB,\nC>{) → Code Lens must show correct reference counts for all SCs; no flex/unused-sc.
  • Open a Flex file with {ABBR} inside an indented SC block → no flex/unused-abbrev.
  • Declare FOO [0-9] and BAR {FOO}+, use only {BAR} in rules → no flex/unused-abbrev for FOO.
  • Write [A-Z]+(\.[A-Z]+)+ before keyword rules "IN", "OF" → no flex/unreachable-rule.

Checklist

  • npm run compile passes with no new errors
  • Tests added or updated (207 passed, 0 failed)
  • Manual test done in VS Code
  • CHANGELOG.md updated
  • No unintended files staged (node_modules, .env, dist...)

@theodevelop theodevelop self-assigned this Apr 3, 2026
@theodevelop theodevelop added the bug Something isn't working label Apr 3, 2026
@theodevelop theodevelop merged commit eb882a0 into dev Apr 3, 2026
1 check passed
@theodevelop theodevelop linked an issue Apr 3, 2026 that may be closed by this pull request
@theodevelop theodevelop deleted the fix/issue-38 branch April 3, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flex references of start conditions and abbreviations not recognized

1 participant