Commit Graph

11 Commits

Author SHA1 Message Date
Alex Hoppen
6505ec8f7e Make ToolchainRegistry initializer synchronous
This requires a bit of a restructuring of `ToolchainRegistry` because calling `scanForToolchain` on `self` is a suspension point. Instead, we need to implement the entire toolchain discovery in the initializer itself, which really isn’t that bad anyway.

This allows us to make the `SourceKitLSP.run` function synchronous again.

Fixes #1023
rdar://120976054
2024-01-18 15:25:00 -08:00
Alex Hoppen
6f342e2b82 Remove static shared toolchain registry
Global state is never a good thing and we needed to modify it in tests. The design becomes a lot cleaner if we explicitly pass the toolchain registry around.
2024-01-09 17:17:31 -08:00
Alex Hoppen
3e73f11de0 Migrate ToolchainRegistry to be an actor 2024-01-09 17:17:31 -08:00
Alex Hoppen
2b9a99e3cb Increase test coverage of rename
- Invoke the rename request from multiple marker locations within a test file
- Add more test cases to test compound decl name references
2023-12-12 17:34:34 -08:00
Alex Hoppen
9c424d8740 Define sources of implementation tests inline with the test cases
Also split them up for better readability.
2023-10-26 18:23:41 -07:00
Alex Hoppen
9391d24b95 Add infrastructure to define indexed single-file workspaces inside the tests
The new approach has a few advantages over the olde TIBS-based approach:
1. The source file being tested is defined within the test case itself and not in a separate file, which makes it easier to understand the test case since the auxiliaury file doesn’t need to be opened. Finding it inside `Sources/SKTestSupport/INPUTS` is already hard for people that are not familiar with the codebase.
2. The build setup is significantly simpler since it doesn’t rely on `ninja`. It is thus easier to understand what is run during the test.
3. We can use the emoji location markers to refer to test locations, like we do for files that are opened using `TestSourceKitLSPClient.openDocument`.

This commit only migrates call hierarchy testing to the new design. If we like it, I’ll migrate the other test workspaces as well.
2023-10-24 08:42:05 -07:00
Alex Hoppen
70997dbf13 Automatically initialize the SourceKit-LSP server when creating a TestSourceKitLSPClient
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.
2023-10-19 17:13:49 -07:00
Alex Hoppen
ea6b8375ee Open documents using testClient.openDocument instead of constructing a DidOpenDocumentNotification
This removes a lot of boilerplate and makes the tests easier to read.
2023-10-18 17:15:03 -07:00
Alex Hoppen
4086874cf3 Implement push diagnostics in terms of DocumentDiagnosticsRequest
Instead of listening for document updates sent from `sourcekitd` and sending a `PublishDiagnosticsNotification` based on the `sourcekitd` notification, wait for a little while and then execute an internal `DocumentDiagnosticsRequest` to load diagnostics and send them to the client.

This has two advantages:
- It unifies the two diagnostic implementations
- It removes the need to keep track of semantic diagnostics in `SwiftLanguageServer`
- It gets us one step closed to opening and editing documents in `syntactic_only` mode. The only thing that is left now are semantic tokens.
2023-10-18 13:48:23 -07:00
Alex Hoppen
64ba40e5cc Make TestSourceKitLSPClient.serverOptions a static member on SourceKitServer.Options
Really, these options had nothing to do with `TestSourceKitLSPClient`, they are just the defaults that are used for all the tests.
2023-10-12 08:28:06 -07:00
Alex Hoppen
2120d124f7 Rename TestSourceKitServer to TestSourceKitClient
Really, what the class was mocking is a SourceKit-LSP client.
2023-10-12 08:28:06 -07:00