Skip to content

SwiftSyntax: Teach SwiftSyntax to use SourceKit to serialize syntax trees. #14424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 7, 2018
Merged

SwiftSyntax: Teach SwiftSyntax to use SourceKit to serialize syntax trees. #14424

merged 6 commits into from
Feb 7, 2018

Conversation

nkcsgexi
Copy link
Contributor

@nkcsgexi nkcsgexi commented Feb 6, 2018

When using SwiftSyntax as a standalone tool, we invoke Swiftc
internally to get the serialized syntax tree. 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 SourceKit to get the
tree just like other clients. We first add a SourceKit client library
written in Swift; and next teach SwiftSyntax to use this SourceKit
client-side library. For platforms other than MacOS, we still use Swiftc
to get syntax trees.

This patch also re-enables several flaky tests.

When using SwiftSyntax as a standalone tool, we invoke Swiftc
internally to get the serialized syntax tree. 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 SourceKit to get the
tree just like other clients. We first add a SourceKit client library
written in Swift; and next teach SwiftSyntax to use this SourceKit
client-side library. For platforms other than MacOS, we still use Swiftc
to get syntax trees.

This patch also re-enables several flaky tests.
@nkcsgexi
Copy link
Contributor Author

nkcsgexi commented Feb 6, 2018

@swift-ci please smoke test

return Dictionary(dict: val)
}

public func asAnyObject() -> AnyObject? {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason you're using AnyObject and Foundation types here instead of stdlib types?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I'm not sure because this is borrowed code from internal clients. I'll try to convert to stdlib types.

@harlanhaskins
Copy link
Contributor

Super glad to see SwiftSyntax communicating with SourceKit!

@nkcsgexi
Copy link
Contributor Author

nkcsgexi commented Feb 6, 2018

@harlanhaskins it seems we don't need the bridging with NS-types so I removed them altogether.

@nkcsgexi
Copy link
Contributor Author

nkcsgexi commented Feb 6, 2018

@swift-ci please smoke test

@nkcsgexi
Copy link
Contributor Author

nkcsgexi commented Feb 7, 2018

@swift-ci please smoke test

@nkcsgexi
Copy link
Contributor Author

nkcsgexi commented Feb 7, 2018

@swift-ci please smoke test

@nkcsgexi nkcsgexi changed the title WIP: Teach SwiftSyntax to use SourceKit to serialize syntax trees. SwiftSyntax: Teach SwiftSyntax to use SourceKit to serialize syntax trees. Feb 7, 2018
@nkcsgexi nkcsgexi merged commit 871c9da into swiftlang:master Feb 7, 2018
@nkcsgexi nkcsgexi deleted the swift-sourcekit-client branch February 7, 2018 03:40
@rudkx
Copy link
Contributor

rudkx commented Feb 7, 2018

@nkcsgexi Could this change have something to do with this source compatibility failure?

https://ci.swift.org/job/swift-PR-source-compat-suite/670/consoleFull#1850297433122a513-f36a-4c87-8ed7-cbc36a1ec144

@nkcsgexi
Copy link
Contributor Author

nkcsgexi commented Feb 7, 2018

@rudkx thanks for the heads-up. The PR seems related to the failure. I'm reverting it in #14456

nkcsgexi added a commit that referenced this pull request Feb 8, 2018
DougGregor added a commit to DougGregor/swift that referenced this pull request Feb 9, 2018
nkcsgexi added a commit that referenced this pull request Feb 11, 2018
…erialize syntax trees. (#14424)" (#14506)

After removing white space changes and attempting to configure dependencies
correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants