Add analysis passes and a public parse entry - #15
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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>
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.
Summary
AbstractProcessor: sealedprocess,process_nodehook, thunk descent,TransformationHelper) fromAbstractTransformation; both leaves now differ only in whatrunreturns.ASTTransform::AbstractAnalysis, the read-only leaf:rundiscards the rebuilt tree and returns the analysis instance so callers chain result readers.ASTTransform::SourceParserand exposeASTTransform.parse/ASTTransform.parse_filefor analysis-only consumers that never emit;Transformer#build_astdelegates (unchanged public behavior).on_*/ positional node builders / sibling-annotation) onAbstractTransformation,Transformation, and in the README, plus a README "Analysis passes" section.T.type_aliasblocks).Test plan
dev test— 108 tests, 0 failures (newAbstractAnalysis+SourceParsersuites)dev style— no offensesMade with Cursor