Commit Graph

15 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
2e03eac75c [WIP] Re-apply "SwiftSyntax: Teach SwiftSyntax to use SourceKitd to serialize syntax trees. (#14424)" (#14506)
After removing white space changes and attempting to configure dependencies
correctly.
2018-02-11 09:38:53 -08:00
Doug Gregor
774bee2294 Revert "Re-apply "SwiftSyntax: Teach SwiftSyntax to use SourceKitd to serialize syntax trees. (#14424)" (#14465)"
This reverts commit f8c77e17ce.
2018-02-08 22:58:45 -08:00
Doug Gregor
b060667877 Revert "[sourcekitd] Rename module SwiftSourceKit to SwiftLang. (#14497)"
This reverts commit 43435af7ee.
2018-02-08 22:58:43 -08:00
Xi Ge
43435af7ee [sourcekitd] Rename module SwiftSourceKit to SwiftLang. (#14497)
The sourcekitd client library provides parsing APIs for SwiftSyntax users.
The internal use of sourcekit service is an implementation detail that end users
shouldn't worry about.
2018-02-08 17:26:00 -08:00
Xi Ge
f8c77e17ce Re-apply "SwiftSyntax: Teach SwiftSyntax to use SourceKitd to serialize syntax trees. (#14424)" (#14465) 2018-02-08 15:11:31 -08:00
Xi Ge
50cde06cf0 Revert "SwiftSyntax: Teach SwiftSyntax to use SourceKitd to serialize syntax trees. (#14424)" 2018-02-06 23:20:42 -08:00
Xi Ge
871c9dac2a SwiftSyntax: Teach SwiftSyntax to use SourceKitd to serialize syntax trees. (#14424)
When using SwiftSyntax as a standalone tool, we invoke Swiftc
internally to get serialized syntax trees. This is not ideal for
several reasons: (1) we have to hard-code the relative path of swiftc
to invoke it; (2) we have to rely on standard input/output to pass the
tree across the process boundaries; and (3) we have to maintain two
different ways to get syntax tree (swiftc and sourcekitd).

This patch attempts to teach SwiftSyntax to use SourceKitd to get the
tree just like other clients. We first add a SourceKitd client library
written in Swift; and next teach SwiftSyntax to adopt this SourceKitd
client-side library. For platforms other than MacOS, we still use Swiftc
to get syntax trees. This client library also allows us to add 
SourceKitd tests in Swift.

This patch also re-enables several flaky tests.
2018-02-06 19:40:16 -08:00
Rintaro Ishizaki
fced748790 [Syntax] Represent missing optioanl nodes as nullptr (#14300)
Allocating RawSyntax/SyntaxData for missing optional node is a waste of
resource.
2018-01-31 19:24:00 +09: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
Rintaro Ishizaki
9c4d6f4893 Revert "[SwiftSyntax] Add debug print when the JSONDecoder fails to decode JSON (#14056)" (#14101)
This reverts commit 840166c3ea.
2018-01-24 10:01:43 +09:00
Rintaro Ishizaki
840166c3ea [SwiftSyntax] Add debug print when the JSONDecoder fails to decode JSON (#14056)
from the compiler's '-emit-syntax'.

Investigating: rdar://problem/36379512
2018-01-22 23:44:18 +09:00
Ben Langmuir
79c8695c5b [test] Disable SwiftSyntax/VisitorTest that fails occassionally in CI
rdar://36379512
2018-01-12 11:53:42 -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