Skip to content

refactor: change AST to CST#204

Merged
DecimalTurn merged 4 commits into
latestfrom
cst
May 13, 2026
Merged

refactor: change AST to CST#204
DecimalTurn merged 4 commits into
latestfrom
cst

Conversation

@DecimalTurn
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ASTCST across parsing, traversal, patching, and serialization.
  • Updated TomlDocument to store _cst and adjusted patch/update flows to use CST naming.
  • Added a deprecated compatibility wrapper for TomlFormat.autoDetectFormatWithAst (now forwarding to autoDetectFormatWithCst).

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 patchAstpatchCst 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 (astcst).
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 (ASTCST) 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 AST type alias was removed in favor of CST. If external code referenced the AST type name (even if the underlying structure is unchanged), this forces a breaking rename. Consider exporting type AST = CST as a /** @deprecated */ alias to smooth the transition.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/patch.ts
Comment thread src/truncate.ts
Comment thread src/toml-document.ts Outdated
@DecimalTurn DecimalTurn marked this pull request as ready for review May 13, 2026 13:40
@DecimalTurn DecimalTurn merged commit 98eec73 into latest May 13, 2026
5 of 6 checks passed
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.

2 participants