Skip to content

Automatically initialize the SourceKit-LSP server when creating a TestSourceKitLSPClient #911

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 1 commit into from
Oct 20, 2023

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Oct 20, 2023

Sending the InitializeRequest was always unnecessarily verbose. If we automatically initialize the server when creating the test client, the code becomes sufficiently concise that we can set up the client + server in the test method itself and no longer need the setUp methods, making the tests easier to read.

@ahoppen ahoppen requested a review from benlangmuir as a code owner October 20, 2023 00:13
@ahoppen ahoppen changed the title Automatically initialize the SourceKit-LSP server when creating a TestSoruceKitLSPClient Automatically initialize the SourceKit-LSP server when creating a TestSourceKitLSPClient Oct 20, 2023
…stSourceKitLSPClient`

Sending the `InitializeRequest` was always unnecessarily verbose. If we automatically initialize the server when creating the test client, the code becomes sufficiently concise that we can set up the client + server in the test method itself and no longer need the `setUp` methods, making the tests easier to read.
@ahoppen ahoppen force-pushed the ahoppen/auto-initialize-server branch from 02c6062 to 70997db Compare October 20, 2023 00:13
@ahoppen
Copy link
Member Author

ahoppen commented Oct 20, 2023

@swift-ci Please test

),
trace: .off,
workspaceFolders: nil
private let quickFixCapabilities = ClientCapabilities(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be static. I don't know if we want eg. a separate support enum that has the common ones we use, but quickFix seems to be used in a few places outside this test file as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would like to leave these local to the test cases. In my experience what would happen otherwise is that we need another capability in addition to quickFix in some other test case and it just gets added to the support enum. Also, at the moment it’s only duplicated once, so not too bad.

Regarding static: I’d prefer to leave it as a member because otherwise we need to refer to it as Self.quickFixCapabilities which doesn’t read as nice. And it’s not like it makes a huge performance difference.

@ahoppen ahoppen merged commit 0ef499a into swiftlang:main Oct 20, 2023
@ahoppen ahoppen deleted the ahoppen/auto-initialize-server branch October 20, 2023 16:29
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