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.
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.
* [CMake] Only build SwiftSyntax if building SDK overlays
SwiftSyntax depends on Foundation, which depends on the SDK overlays
being built. However, the existing build configuration tried to build
SwiftSyntax even if the SDK overlays were not built. Ensure we're
building overlays before building SwiftSyntax, and guard tests with an
sdk_overlay test.
* Remove TODO comment
This is, unfortunately, the quickest workaround to get SwiftSyntax
building properly and generating a proper module. I'm going to take some
time to figure out what global mutable state exactly is touched inside
stdlib/ that suddenly makes this work, but for now, get the tests re-enabled.
* 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