Avatar
SwiftSyntax の dump が超絶読みづらい問題、近々会社的な fork からパッチをあげるかもです
3:34 PM
Pretty results of dump() for Syntax The result of dump() with Syntax is not useful. For example, the dumped result of Tests/SwiftSyntaxTest/Inputs/closure.swift is the following: ▿ // A closure without a signature. The test will ensure it stays the same after // applying a rewriting pass. let x: () -> Void = {} ▿ data: SwiftSyntax.SyntaxData - parent: nil ▿ absoluteRaw: SwiftSyntax.AbsoluteRawSyntax - raw: // A closure without a signature. The test will ensure it stays the same after // applying a rewriting pass. let x: () -> Void = {} #0 ▿ super: Swift.ManagedBuffer<SwiftSyntax.RawSyntaxBase, Swift.UInt64> ▿ header: SwiftSyntax.RawSyntaxBase ... This patch improve this result to the following: ▿ SourceFileSyntax ▿ statements: CodeBlockItemListSyntax ▿ 0: CodeBlockItemSyntax ▿ item: VariableDeclSyntax - attributes: nil - modifiers: nil ▿ letOrVarKeyword: TokenSyntax - text: "let" ▿ leadingTrivia: SwiftSyntax.Trivia ▿ pieces: 4 elements ▿ TriviaPiece - lineComment: "// A closure without a signature. The test will ensure it stays the same after" ...
3:35 PM
これ、 https://swift-ast-explorer.kishikawakatsumi.com/ を dump でできるようにするイメージがわかりやすいかもですね。LLDB から見てもきっと便利なはず。
👀 4