Conversation
|
@swift-ci please test |
ahoppen
left a comment
There was a problem hiding this comment.
Sorry for taking sooooooo long to get back to this. We already have Indenter in SwiftSyntaxBuilder, which serves the same purpose. I don’t think that Indenter was ever intended to be public API, but now it’s out there.
I think your API is the nicer one (doesn’t expose a SyntaxRewriter) but I think it would be good to unify these two implementations. Could you:
- Mark the
Indenterclass inSwiftSyntaxBuilderas deprecated? - Migrate all uses of
Indenterinside swift-syntax to your indentation method? - Add release note entries for the deprecation of the
Indenterand the introduction of the newindentedmethod?
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
Why might the |
|
A |
|
It’s a local generic type (which must be shadowing the real |
You need to add |
| self.shouldIndent = indentFirstLine | ||
| } | ||
|
|
||
| private func indentIfNeeded() -> [TriviaPiece] { |
There was a problem hiding this comment.
Also, I would call it indentationIfNeeded because indentIfNeeded sounds like an action that’s actively indenting something but this just returns the indentation.
Same for indentAfterNewlines.
There was a problem hiding this comment.
indentAfterNewlines does actually perform the indentation (and returns the indented string) but I’ve renamed indentIfNeeded.
This comment was marked as outdated.
This comment was marked as outdated.
1 similar comment
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
1 similar comment
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
@swift-ci please test |
|
@swift-ci please test Windows |
This method allows for easily indenting a node tree without needing to manually find where to place the new trivia.
I also chose not to implement a version that automatically detects an amount to indent by using
BasicFormat.inferIndentationsince that would probably produce better results if called higher up in the tree, and the user of this API can more easily cache that calculated indentation amount and pass it toindentmultiple times as needed.