Skip to content

Pull SwiftSyntax into SourceKit-LSP #651

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 3 commits into from
Oct 20, 2022
Merged

Pull SwiftSyntax into SourceKit-LSP #651

merged 3 commits into from
Oct 20, 2022

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Oct 16, 2022

The general idea is to try to use the syntax tree to provide an in-process source of truth about syntactic and structural document requests. Having the syntax tree in process also enables syntactic transformations and analyses that can be used to provide code actions, programmatic language features like (keyword) hovering, etc. both natively in Swift and without having to incur a hop out to SourceKit.

To that end, re-core the "lexical" token stream on top of SwiftSyntax and call into the parser to (re-)generate these "lexical tokens" when the document changes. Leave the semantic tokens alone since they take some non-zero amount of name lookup to fully resolve references to fully replicate.

A follow-on will demonstrate what we can start to do with this infrastructure.

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

Please update the CMake builds, the build-windows-toolchain.bat in apple/swift, and this will require coordination as https://GitHub.com/compnerd/swift-build will need updates to keep the official builds from breaking.

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

A few from my comments on #652 also apply here. I only saw this PR after adding my review comments to the other one.

@CodaFi CodaFi force-pushed the syn-city branch 2 times, most recently from 08bf040 to 259bf64 Compare October 18, 2022 02:45
@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 18, 2022

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

Looks good to me. I’ve got a few comments, mostly around naming.

Re-core the "lexical" token stream on top of SwiftSyntax and call into the parser to (re-)generate these "lexical tokens" when the document changes. Leave the semantic tokens alone since they take some non-zero amount of name lookup to fully resolve references to fully replicate.
@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 18, 2022

I think this should do it. @compnerd please review the cmake changes when you get a chance. There's an oddity around some paths in SwiftSyntax::SwiftParser that's forcing me to link with TARGET_OBJECTS, but otherwise I was able to get a good local build.

@swift-ci test

@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 18, 2022

@swift-ci test

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

This looks fantastic!

@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 20, 2022

@compnerd and I worked out these issues on a separate channel. Patching Swift Syntax at swiftlang/swift-syntax#991

@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 20, 2022

CodaFi added a commit to CodaFi/swift-build that referenced this pull request Oct 20, 2022
As of swiftlang/sourcekit-lsp#651 sourcekit-lsp  now
depends on SwiftSyntax for its internal representation of
documents.
Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

Thanks, the build side of things look good to me.

@compnerd compnerd dismissed their stale review October 20, 2022 03:39

addressed

@CodaFi CodaFi merged commit 3124c96 into main Oct 20, 2022
compnerd pushed a commit to compnerd/swift-build that referenced this pull request Oct 24, 2022
As of swiftlang/sourcekit-lsp#651 sourcekit-lsp  now
depends on SwiftSyntax for its internal representation of
documents.
@ahoppen ahoppen deleted the syn-city branch November 13, 2024 18:33
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.

4 participants