swift-syntax
swift-syntax copied to clipboard
Add an 'indented' method to SyntaxProtocol
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.inferIndentation since 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 to indent multiple times as needed.
@swift-ci please test
@swift-ci please test
@swift-ci please test
Why might the indented(by:) method not be able to be found? Things work fine for me locally.
/Users/ec2-user/jenkins/workspace/swift-syntax-PR-macOS/branch-main/swift-syntax/Sources/SwiftSyntaxBuilder/Syntax+StringInterpolation.swift:85:27: error: value of type 'Node' has no member 'indented'
indentedNode = node.indented(by: lastIndentation)
~~~~ ^~~~~~~~
A Node is not a kind of Syntax, it’s meta-information about the declaration of a syntax node the builder will spit out. You may want to revert your change in that file.
It’s a local generic type (which must be shadowing the real Node type): func appendInterpolation<Node: SyntaxProtocol>.
Why might the
indented(by:)method not be able to be found? Things work fine for me locally./Users/ec2-user/jenkins/workspace/swift-syntax-PR-macOS/branch-main/swift-syntax/Sources/SwiftSyntaxBuilder/Syntax+StringInterpolation.swift:85:27: error: value of type 'Node' has no member 'indented' indentedNode = node.indented(by: lastIndentation) ~~~~ ^~~~~~~~
You need to add Indenter.swift to CMakeLists.txt so we can find it when building swift-syntax using CMake for the compiler.
@swift-ci please test
@swift-ci please test
@swift-ci please test
@swift-ci please test
@swift-ci please test
@swift-ci please test
@swift-ci please test Windows