refactor: change AST to CST#204
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR renames the project’s internal syntax tree terminology from AST to CST across the codebase, aligning file/module names, public/internal APIs, and documentation with “Concrete Syntax Tree” wording while keeping functionality largely the same.
Changes:
- Renamed core types/functions/parameters from
AST→CSTacross parsing, traversal, patching, and serialization. - Updated
TomlDocumentto store_cstand adjusted patch/update flows to use CST naming. - Added a deprecated compatibility wrapper for
TomlFormat.autoDetectFormatWithAst(now forwarding toautoDetectFormatWithCst).
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/writer.ts | Switched imports/docs from ./ast to ./cst and updated terminology in comments/JSDoc. |
| src/truncate.ts | Renamed truncate API to truncateCst and updated parameter/return naming to CST. |
| src/traverse.ts | Renamed traverse input from ast to cst and updated imports/docs accordingly. |
| src/toml-format.ts | Renamed format auto-detect helper to autoDetectFormatWithCst; added deprecated autoDetectFormatWithAst wrapper. |
| src/toml-document.ts | Internal storage renamed to _cst; patch/update/overwrite flows updated to CST naming; added CST/AST accessors. |
| src/to-toml.ts | Updated types/docs to accept CST and use CST naming throughout. |
| src/to-js.ts | Updated types/docs and iteration variable naming from AST to CST. |
| src/patch.ts | Renamed exported patch helper patchAst → patchCst and updated internal variables/docs to CST. |
| src/parse-toml.ts | Updated generator return type from AST to CST and renamed documentation to CST. |
| src/parse-js.ts | Updated imports/docs to CST terminology. |
| src/index.ts | Updated exported documentation comment to reference CST. |
| src/generate.ts | Updated module/file documentation and imports to CST. |
| src/formatter.ts | Updated imports to CST module. |
| src/find-by-path.ts | Updated imports and docs to reference CST structure/semantics. |
| src/cst.ts | Updated terminology to “Concrete Syntax Tree” and renamed exported tree type to CST. |
| src/comment-alignment.ts | Updated imports and docs to CST terminology. |
| src/tests/writer.test.ts | Updated imports and local variable naming (ast → cst). |
| src/tests/validate-cst.test.ts | Updated imports and patch helper usage to patchCst; updated CST wording. |
| src/tests/truncate.test.ts | Updated tests to use truncateCst and CST naming. |
| src/tests/toml-format.test.ts | Updated tests to use autoDetectFormatWithCst and CST variable names. |
| src/tests/toml-document.test.ts | Updated test descriptions and access to use doc.cst rather than doc.ast. |
| src/tests/to-toml.test.ts | Updated test description to CST wording. |
| src/tests/roundtrip.patch-parse.test.ts | Updated equality assertion to compare cst structures. |
| src/tests/patch.test.ts | Updated comments to CST wording. |
| src/tests/parse-toml.test.ts | Updated imports to CST module. |
| src/tests/parse-js.test.ts | Updated imports/types (AST → CST) and helper naming. |
| src/tests/generate.test.ts | Updated imports to CST module. |
| src/tests/find-by-path.test.ts | Updated imports and local variable names to CST. |
| src/tests/detect-trailing-comma.test.ts | Updated tests to pass CST variables into detection helpers. |
| src/tests/cst-parsing.test.ts | Updated suite naming/snapshots to CST wording and CST variable names. |
| src/tests/continue-parsing.test.ts | Updated test descriptions to CST wording. |
| src/tests/snapshots/cst-parsing.test.ts.snap | Snapshot keys updated from AST-focused names to CST-focused names. |
| README.md | Updated user-facing documentation to reference CST instead of AST. |
Comments suppressed due to low confidence (1)
src/cst.ts:36
- The
ASTtype alias was removed in favor ofCST. If external code referenced theASTtype name (even if the underlying structure is unchanged), this forces a breaking rename. Consider exportingtype AST = CSTas a/** @deprecated */alias to smooth the transition.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
No description provided.