Commit Graph

7 Commits

Author SHA1 Message Date
Harlan
bdfa6cd4d7 [SwiftSyntax] Add SyntaxRewriter.visitAny(_:) (#15212)
* [SwiftSyntax] Add SyntaxRewriter.visitAny(_:)

This function, when overridden, allows Syntax rewriters to perform custom dynamic visitation behavior. If a user wanted to, say, store a series of transformations accessible by metatype, they can override visitAny and do their own runtime dispatch.

If a non-nil result is returned from visitAny, the original specialized visitors are skipped.
2018-03-27 10:55:31 -04:00
Harlan
e41a42b060 [SwiftSyntax] Ensure SyntaxRewriter respects nil children when rewriting (#15052) 2018-03-08 00:37:41 -05:00
Xi Ge
dac918f870 SwiftSyntax: add pre and post visit function so that client can override a general visiting logic. SR-6902 (#14365) 2018-02-02 16:23:09 -08:00
Harlan
a339c82c1e [SwiftSyntax] Make Syntax nodes structs instead of classes (#14122)
* [Experiment] Make Syntax nodes structs instead of classes

* [Experiment] Add Hashable conformance to concrete types

* Fix pep8 violation

* Remove AnySyntax, explicitly specialize SyntaxCollection nodes

* Refine the comment for SyntaxCollection nodes
2018-01-24 23:17:25 -05:00
Xi Ge
b85f6d9c58 libSyntax: add a C++ side read-only syntax visitor to facilitate verification. NFC (#13882) 2018-01-11 16:17:44 -08:00
Xi Ge
d41eedcbf6 SwiftSyntax: Add a read-only syntax visitor. (#13681)
Based on the feedbacks from our early adopters, separating syntax tree analysis
with transformation is a common pattern. Thus, we introduce a read-only
syntax tree visitor to help the analysis phase. This visitor never alters the
content of a tree being visited, in contrast to SyntaxRewriter which always does.
2018-01-02 16:52:30 -08:00
Harlan
ade67ca899 [Syntax] Swift libSyntax API (#11320)
* Create Swift libSyntax API

This patch is an initial implementation of the Swift libSyntax API. It
aims to provide all features of the C++ API but exposed to Swift.

It currently resides in SwiftExperimental and will likely exist in a
molten state for a while.

* Only build SwiftSyntax on macOS
2017-08-14 16:47:48 -07:00