Skip to content

Report the Sight directive in each comment in sight parse --json, so other tools don't reimplement the directive grammar - #353

Merged
jbearak merged 1 commit into
mainfrom
parse-json-directives
Nov 4, 2026
Merged

jbearak merged 1 commit into
mainfrom
parse-json-directives

Conversation

@jbearak

@jbearak jbearak commented Nov 4, 2026

Copy link
Copy Markdown
Owner

do2r translates Stata to R and rewrites each Sight directive as the matching Raven directive. Until now sight parse --json reported comments only as raw text. To do the rewrite, do2r would have had to copy Sight's directive grammar: the @lsp- aliases, the optional colon, quoting, and which placements count (header-only rules, trailing-comment rules, block comments).

Now every comment object has a directive field. It holds the directive Sight actually honors there, read by the editor's own code. It is null for an ordinary comment and for a directive Sight ignores where it stands. The kinds are declare (local, global, variables, scalar, matrix, program), ignore and ignore_next, forward, backward (run-by is kept as run), standalone, and working_directory. ignore and ignore_next carry a target_range: the code whose diagnostics Sight suppresses. A new top-level comments list holds the comments no statement reports, so a file that is only header comments no longer loses them. The change is additive only, and schema_version stays 1. docs/cli.md documents it under "Directives".

To keep the CLI and the editor from drifting apart, the analyzer's comment-directive rules (ignore, ignore-next, declarations, variables, and the trivia walk) moved to src/directive-parser/comment-directives.ts. The analyzer and the CLI both call that module. The forward, backward, standalone, and working-directory directives come from DirectiveParser. Existing directive tests pass unchanged.

Proof:

  • Golden fixtures cover every kind and an ignored placement of each sort.
  • Unit tests check the CLI against the editor itself: the analyzer's undefined-macro diagnostics for ignore and declarations, and sight graph for forward, backward, and standalone. With either CLI rule removed, these tests fail.
  • The built bundle's sight parse --json output on the fixture matches the golden file.
  • typecheck, lint, line-endings, and bun test ./tests pass. The exception is the local-Stata help-coverage test, which also fails on main on this machine.

Reviewed with sol-loop: 1 round with gpt-6.1-sol. Sol verdict: approved

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

Add a directive field to every comment object (null for an ordinary
comment or a directive Sight does not honor where it stands) and a
file-level comments list for comments no statement reports.

The analyzer's comment-directive rules (ignore, ignore-next,
declarations, variables, and the trivia walk) move to
src/directive-parser/comment-directives.ts so the analyzer and the CLI
call the same functions. Forward, backward, standalone, and
working-directory directives come from DirectiveParser.
@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available. Your 25 included PR review attempts over the past 7 days set your current allowance at 8 reviews per hour.

Learn how review limits work.

Review configuration:

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: 03114208-be6b-4774-a7d1-43a17a86aa00
Commits

Reviewing files that changed from the base of the PR and between 9189110 and 32d1775.

Files selected for processing: 12
  • docs/cli.md
  • src/analyzer/index.ts
  • src/cli/parse-directives.ts
  • src/cli/parse-json.ts
  • src/directive-parser/comment-directives.ts
  • src/directive-parser/index.ts
  • tests/fixtures/cli-json/expected/graph.json
  • tests/fixtures/cli-json/expected/parse.json
  • tests/fixtures/cli-json/project/directives.do
  • tests/fixtures/cli-json/project/header-only.do
  • tests/unit/cli/json-golden.test.ts
  • tests/unit/cli/parse-directives.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@jbearak
jbearak merged commit be1d854 into main Nov 4, 2026
16 checks passed
@jbearak
jbearak deleted the parse-json-directives branch November 4, 2026 23:47
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