Skip to content

ast: construct with optional comments#4373

Merged
kitbellew merged 1 commit intoscalameta:mainfrom
kitbellew:3372_9
Dec 3, 2025
Merged

ast: construct with optional comments#4373
kitbellew merged 1 commit intoscalameta:mainfrom
kitbellew:3372_9

Conversation

@kitbellew
Copy link
Copy Markdown
Collaborator

Helps with #3372.

@kitbellew kitbellew force-pushed the 3372_9 branch 6 times, most recently from e7f4084 to f47261a Compare November 30, 2025 07:58
@kitbellew kitbellew requested a review from tgodzik November 30, 2025 08:55
@kitbellew kitbellew force-pushed the 3372_9 branch 5 times, most recently from d886979 to bf98ad5 Compare December 1, 2025 21:17
Comment thread docs/trees/examples.md
Comment thread docs/trees/examples.md Outdated

```scala

Lit.Null.withComments(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could not just add withComments method that would copy the tree? Similar to withOrigin etc.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

there's copyWithComments, of course. the difference is, withOrigin is a private extension that nobody uses. once again, it is trivial to add a couple of constructors to build the tree in one shot, than to force users to adjust to having to use copy...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe then createWithComments to make it more different or applyWithComments?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

createWithComments it is, then. give me a sec.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done. any other modifications?

For that, let's add `createWithComments` static constructor methods,
`copyWithComments` instance methods, and a package-private static
`_ctor` which takes all parameters including the private ones (such as
origin, parent, comments etc.).
@kitbellew kitbellew merged commit 97e5ea7 into scalameta:main Dec 3, 2025
39 of 40 checks passed
@kitbellew kitbellew deleted the 3372_9 branch December 3, 2025 17:59
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