Skip to content

Add analysis passes and a public parse entry - #15

Merged
JPDuchesne merged 4 commits into
mainfrom
jpd/analysis-api
Jul 29, 2026
Merged

Add analysis passes and a public parse entry#15
JPDuchesne merged 4 commits into
mainfrom
jpd/analysis-api

Conversation

@JPDuchesne

Copy link
Copy Markdown
Contributor

Summary

  • Extract the shared traversal core (AbstractProcessor: sealed process, process_node hook, thunk descent, TransformationHelper) from AbstractTransformation; both leaves now differ only in what run returns.
  • Add ASTTransform::AbstractAnalysis, the read-only leaf: run discards the rebuilt tree and returns the analysis instance so callers chain result readers.
  • Extract parsing into ASTTransform::SourceParser and expose ASTTransform.parse / ASTTransform.parse_file for analysis-only consumers that never emit; Transformer#build_ast delegates (unchanged public behavior).
  • Document the pass taxonomy (structural on_* / positional node builders / sibling-annotation) on AbstractTransformation, Transformation, and in the README, plus a README "Analysis passes" section.
  • Bump to 3.1.0 (first consumer: d3mlabs/simplecov-sorbet, which parses covered files to skip runtime-unreachable T.type_alias blocks).

Test plan

  • dev test — 108 tests, 0 failures (new AbstractAnalysis + SourceParser suites)
  • dev style — no offenses
  • Downstream canary: rspock's suite (242 tests) green against this checkout via a local path override

Made with Cursor

Extract the traversal core (sealed process, process_node hook, thunk
descent, TransformationHelper) from AbstractTransformation into
AbstractProcessor, and add AbstractAnalysis as the read-only leaf: same
engine, but run discards the rebuilt tree and returns the analysis
instance. Move parsing into SourceParser and expose ASTTransform.parse /
parse_file for analysis-only consumers that never emit. Document the
pass taxonomy (structural / positional builders / sibling-annotation)
on AbstractTransformation, Transformation, and the README.

Co-authored-by: Cursor <cursoragent@cursor.com>
@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

JPDuchesne and others added 3 commits July 29, 2026 10:11
Class-method delegation to a hidden memoized instance is the shape the
org's constructor-injection rule forbids: it hides the collaborator and
locks the seam shut. SourceParser is the public parse entry — callers
construct it and keep the instance for as many parses as they need.

Co-authored-by: Cursor <cursoragent@cursor.com>
…collaborator

The memoized reset-and-reuse parser was carried over from Transformer's
original code: a micro-optimization that made the instance stateful (and
create_buffer's default_encoding lookup re-triggered the reset on every
access). Parser instances accumulate per-run state and cost nothing to
construct next to the parse itself, so they are per-call; the builder is
fixed for the instance's lifetime and moves to the constructor.

Co-authored-by: Cursor <cursoragent@cursor.com>
The associate override predates the parser gem's native flag and rewrote
any braceless hash construction; emit_kwargs rewrites at the call sites
where kwargs semantics actually live (calls, index, super/yield) and is
maintained upstream. The flag is a class-level ivar, so setting it on
the subclass opts in this builder only — the global default is
untouched. Verified AST-identical on every probed form via the Prism
translation layer.

Also stop exposing the builder as a SourceParser constructor parameter:
the kwargs/hash distinction is required for the framework's emission to
round-trip, an implementation detail rather than an injection seam.

Co-authored-by: Cursor <cursoragent@cursor.com>
@JPDuchesne
JPDuchesne merged commit ca714bf into main Jul 29, 2026
5 checks passed
@JPDuchesne
JPDuchesne deleted the jpd/analysis-api branch July 29, 2026 14:31
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