ast: construct with optional comments#4373
Merged
kitbellew merged 1 commit intoscalameta:mainfrom Dec 3, 2025
Merged
Conversation
e7f4084 to
f47261a
Compare
d886979 to
bf98ad5
Compare
tgodzik
reviewed
Dec 3, 2025
|
|
||
| ```scala | ||
|
|
||
| Lit.Null.withComments( |
Collaborator
There was a problem hiding this comment.
Could not just add withComments method that would copy the tree? Similar to withOrigin etc.
Collaborator
Author
There was a problem hiding this comment.
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...
Collaborator
There was a problem hiding this comment.
Maybe then createWithComments to make it more different or applyWithComments?
Collaborator
Author
There was a problem hiding this comment.
createWithComments it is, then. give me a sec.
Collaborator
Author
There was a problem hiding this comment.
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.).
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.
Helps with #3372.