Skip to content

Treat #d, #del, and other abbreviations of #delimit like #delimit - #412

Merged
jbearak merged 3 commits into
mainfrom
t3/support-delimit-abbreviations
Nov 19, 2026
Merged

jbearak merged 3 commits into
mainfrom
t3/support-delimit-abbreviations

Conversation

@jbearak

@jbearak jbearak commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Stata accepts any abbreviation of #delimit down to #d. Base ado files use #del ; a lot. Sight only recognized the full word, so after #d ; or #del ; it kept ending statements at line breaks and reported false errors: missing_open_brace, code_follows_open_brace, brace_not_alone, and undefined-macro warnings for syntax locals such as `if'.

Now #d, #de, #del, #deli, #delim and #delimi act exactly like #delimit. Matching is exact-case, so #D ; and #define ; are still not directives. One shared pattern in src/utils/delimit-directive.ts replaces the lexer's startsWith('delimit') check and the three copies of the ;-mode regex (parser, alignment detector, and the helper that Send to Stata uses). Other changes:

  • The lexer takes the directive only where a command can start or at the start of a line. That keeps a factor-variable interaction like i.a#d an operator. One side effect: a mid-line x#delimit is now an interaction too, which is how Stata reads it. Before this change it was a directive.
  • Both formatter modes keep the spelling as written. #d ; is no longer rewritten to #delimit ;.
  • The TextMate grammar colored the d in #d and #de as describe, and hover showed describe help there. A grammar rule now colors every spelling, #delimit included, as a directive, and hover shows nothing on the directive, the same as it did for #delimit.

Proof: on main, the issue's two repros give 5 and 4 issues with #d/#del and 0 with #delimit. On this branch every spelling gives 0. The new tests/unit/delimit-abbreviation.test.ts covers tokens, AST, diagnostics, both formatter modes, Send to Stata, the grammar and hover: run against the old src, 23 tests fail, and against the old grammar and hover, 8. All four gates pass when run separately (check:line-endings, typecheck, bun test ./tests with 9903 passing and 0 failing, and lint).

sol-loop was skipped: this run was told not to start subagents.

Created with Claude Opus 5.5 in Claude Code (T3 Code).

Summary by CodeRabbit

  • New Features
    • Stata now recognizes abbreviated #delimit directives, including forms such as #d and #de.
    • Directive abbreviations are preserved when formatting code, and are highlighted as directives in the editor.
  • Bug Fixes
    • Improved handling of delimiter modes for abbreviated directives, including statement detection and diagnostics.
    • Hover information no longer appears over directive text, while remaining available for other code.

Stata 18 accepts any abbreviation of #delimit down to #d, and base ado
files use #del ; widely. Sight only knew the full word, so after #d ;
it kept ending statements at line breaks and reported false errors.

One shared pattern (src/utils/delimit-directive.ts) now recognizes the
keyword, exact-case and as a whole word, for the lexer, parser,
alignment detector, and Send to Stata. The lexer takes it only where a
command can start or at the start of a line, so a factor-variable
interaction such as i.a#d stays an operator. The pretty-printer keeps
the spelling as written.
The TextMate grammar and hover read the d of #d and #de as describe.
A grammar rule now colors #delimit and each abbreviation as a
directive, and hover shows nothing on the directive, as for #delimit.
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Stata directive handling now recognizes #delimit abbreviations from #d through #delimit. Parsing and formatting retain the written keyword and use shared delimiter-mode helpers. Tests cover lexer, parser, formatter, Send to Stata, TextMate scopes, and hover behavior.

Changes: Stata delimiter abbreviations

Layer / File(s) Summary
Recognize abbreviated directives
src/utils/delimit-directive.ts, src/lexer/index.ts, client/syntaxes/stata.tmLanguage.json, src/types/index.ts, src/parser/index.ts
Shared helpers match supported abbreviations and determine keyword length. The lexer and TextMate grammar recognize directives, and DirectiveNode stores the keyword as written.
Apply delimiter modes and preserve spelling
src/parser/index.ts, src/utils/semicolon-statement.ts, src/formatter/alignment-detector.ts, src/pretty-printer/index.ts, tests/property/generators/ast-nodes.ts, tests/property/pretty-printer-frame-block-deletion.prop.test.ts
Parser and formatter components use shared helpers to determine the delimiter mode. The pretty-printer emits the stored keyword. Property-test directive fixtures now include the keyword.
Handle directive text in editor features
src/providers/hover.ts, tests/unit/delimit-abbreviation.test.ts
Hover returns no result when the cursor is inside a directive token. Tests cover abbreviations and their case and context constraints across editor features.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: Minimal · up to 7f397

This change makes Stata #delimit abbreviations behave like the full directive in parsing, formatting, highlighting and hover. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the lexer, parser, formatter, and related helpers now treat Stata's abbreviations of #delimit (#d, #de, #del, and so on) the same as #delimit. The changeset matches th…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the lexer, parser, formatter, and related helpers now treat Stata's abbreviations of #delimit (#d, #de, #del, and so on) the same as #delimit. The changeset matches this, including the lexer, parser, alignment detector, semicolon-statement helper, the new delimit-directive utilities, the TextMate grammar, hover suppression, and the abbreviation tests. The title is concise and specific, and it does not describe any unrelated change.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Team
  • Run ID: f48f7d02-9276-4e17-ad5c-f6956a81b15f
Commits

Reviewing files that changed from the base of the PR and between 6d98b9b and 7f397bd.

Files selected for processing: 12

  • client/syntaxes/stata.tmLanguage.json
  • src/formatter/alignment-detector.ts
  • src/lexer/index.ts
  • src/parser/index.ts
  • src/pretty-printer/index.ts
  • src/providers/hover.ts
  • src/types/index.ts
  • src/utils/delimit-directive.ts
  • src/utils/semicolon-statement.ts
  • tests/property/generators/ast-nodes.ts
  • tests/property/pretty-printer-frame-block-deletion.prop.test.ts
  • tests/unit/delimit-abbreviation.test.ts

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant