Skip to content

Migrate SwiftLanguageServer and ClangLanguageServerShim to be actors #834

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

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Sep 27, 2023

The next step to making sourcekit-lsp use Swift concurrency.

I think the best way to review this, is commit by commit, ignoring whitespace-only changes because I changed the indentation of quite a few lines if e.g. queue.async becomes unnecessary since the function is now async itself.

After this change, there are a few low-probability race conditions in the code as well as things to clean up. Those are marked with FIXME: (async). I will fix all of them in follow-up PRs. I’m splitting them to keep the reviews manageable.

For reference, my full stack of asyncifying commits is in https://github.com/ahoppen/sourcekit-lsp/tree/ahoppen/swift-concurrency-4.

@ahoppen ahoppen force-pushed the ahoppen/toolchain-language-servers-actor branch 2 times, most recently from 395f1ca to 67bc93f Compare September 27, 2023 16:21
Copy link
Contributor

@hamishknight hamishknight left a comment

Choose a reason for hiding this comment

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

Great!

This is a preparation step for making `SwiftLanguageServer` and `ClangLanguageServerShim` actors.
…build settings

Instead of storing build settings inside the language servers based on update notifications from the build system, always call into the `BuildSystemManager` to get the build settings.

Overall, I think this is a much clearer separation of concerns and will allow us to remove `SourceKitServer.documentToPendingQueue` in a follow-up commit as `SwiftLanguageServer` can always directly call into `BuildSystemManager` to get build settings and we don’t need to wait for the initial notification to receive the first build settings.

This requies `BuildServerBuildSystem` to keep track of the build settings it has received from the BSP server.

`ClangLanguageServer` still caches build settings locally. `ClangLanguageServer` will change to the same pull-based model in a follow-up commit.
Fairly straightforward since we have all the infrastructure now.
…get build settings

The same kind of change that we did for `SwiftLanguageServer`. Instead of caching build settings inside `ClangLanguageServerShim`, always call into `BuildSystemManager` to get the build settings.
@ahoppen ahoppen force-pushed the ahoppen/toolchain-language-servers-actor branch from 216a860 to 729c18d Compare September 27, 2023 23:30
@ahoppen ahoppen changed the title Migrate SwiftLanguageServer and ClangLanguageServerShim to be actors 🚥 #830 Migrate SwiftLanguageServer and ClangLanguageServerShim to be actors Sep 27, 2023
@ahoppen ahoppen force-pushed the ahoppen/toolchain-language-servers-actor branch from 729c18d to aaa9bd4 Compare September 27, 2023 23:52
@ahoppen
Copy link
Member Author

ahoppen commented Sep 27, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Sep 28, 2023

@swift-ci Please test Windows

@ahoppen ahoppen merged commit 4282b1b into swiftlang:main Sep 28, 2023
@ahoppen ahoppen deleted the ahoppen/toolchain-language-servers-actor branch September 28, 2023 13:51
@ahoppen ahoppen mentioned this pull request Sep 29, 2023
ahoppen added a commit that referenced this pull request Sep 29, 2023
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.

2 participants