This allows us to run `sourcekit-lsp index --project /path/to/project` to index a project. Intended to debugging purposes, eg.
- Profile the time it takes to index a project
- See if the project can be indexed successfully
- Look at signposts generated during indexing in Instruments to see whether indexing or preparation is the bottleneck and how well we can parallelize tasks.
This allows a user of SourceKit-LSP to inspect the result of background indexing. This allows a user of SourceKit-LSP to inspect the result of background indexing. I think this gives useful insights into what SourceKit-LSP is indexing and why/how it fails, if it fails, also for users of SourceKit-LSP.
rdar://127474136
Fixes#1265
We weren’t logging requests sent to a `TestSourceKitLSPClient` because we were assuming that `JSONRPCConnection` logs those requests in `SourceKitLSPServer`. But no logging happens in `LocalConnection`, which `TestSourceKitLSPClient` uses.
Since `LangaugeServerProtcol` can’t depend on `LSPLogging`, move the type to `LSPTestsSupport`.
Implements an initial background index when the project is opened.
The following will be implemented in follow-up PRs:
- Resolving package dependencies
- Preparing dependent modules
- Watching for file updates
Creating `Process` on Amazon Linux fails with: `workingDirectory is not supported in this platform`. Instead of setting a working directory, pass the working directory as `-C` to `git` when creating a `SwiftPMDependencyProject`.
`SwiftPMBuildSystem.testFiles()` returned all source files in the package, including files of package dependencies. This caused us to index those files for tests in the syntactic test index, which we should not.
Make `SwiftPMBuildSystem.testFiles` only return files from the root package.
Also add test infrastructure to be able to test cross-package functionality.
rdar://126965614
When the client sends us `workspace/didChangeWatchedFiles` notification of an updated `.swift` file, we should refresh the other open files in that module since they might be referencing functions from that updated file.
If a `.swiftmodule` file has been updated, we refresh all the files within the package since they might import that module. Technically, we would only need to refresh files that are in module that are downstream of the updated module but we don’t currently have that information easily available from SwiftPM. Also, usually, if the client has a file from a low-level module open, he’ll be working on that module which means that such an optimization won’t help. The real solution here is to wait for us to finish preparation (which we would exactly know when it finishes since sourcekit-lsp would schedule it) but for that we need to implement background preparation.
Fixes#620Fixes#1116
rdar://99329579
rdar://123971779
This workspace-wide syntactic test index is used for two purposes:
- It is used for XCTests instead of the semantic index for files that have on-disk or in-memory modifications to files
- It is uses for swift-testing tests, which are only discovered syntactically.
rdar://119191037
With https://github.com/apple/swift/pull/72930 we can use the `containedBy` instead of `calledBy` relation for the call hierarchy, which allows us to show unapplied function references in the call hierarchy as well.
rdar://123769825
Instead of returning `nil` to indicate that the position conversion failed, log a fault and perform a best-effort recovery.
I think this allows us to perform better recovery and also makes code calling these position conversions a lot simpler because it doesn’t need to make decisions about what to do if position conversions fail.
Rename all the classes that write files to disk to create a test project that we can open in sourcekit-lsp to end with `TestProject`. This is better than the old `Workspace` suffix because it avoids ambiguities with the `Workspace` type inside sourcekit-lsp.
- IndexedSingleSwiftFileWorkspace -> IndexedSingleSwiftFileTestProject
- MultiFileTestWorkspace -> MultiFileTestProject
- SwiftPMTestWorkspace -> SwiftPMTestProject
The client ID was needed when a `MessageHandler` could handle messages from multiple connections. We don’t support this anymore (because it wasn’t needed) and so the client ID doesn’t need to get passed through as well.
Currently, all tests send publish diagnostics notifications, which is noise in the logs for most tests. Change the tests to use the pull diagnostics model by default and make the push diagnostic model opt-in.
rdar://123241539
This should help users debug issues when functionality is not working because compiler arguments are missing.
Note that when opening a standalone Swift file, we consider that file as having non-fallback build settings, even though the build settings are synthesized from the fallback build system. Thus, this will only pop up when the user is in a context that has some build system (like a compilation database or a Swift package) but the current file isn’t handled by that.
rdar://119741960
When starting rename from a function parameter’s label, we should be performing a rename of the function signature. To do that, we need to do some adjustments of th rename positions in order to get the position of the function’s base name and use that for the rename requests sent to sourcekitd.
rdar://119875277
Up until now we have skipped tests on a very ad-hoc basis and some of these skips have lingered around much longer than they were needed.
Add infrastructure to check if a given host toolchain has a feature required by a test. The key ideas here are:
- The skip check specifies a Swift version in which the required feature was introduced. Any newer Swift versions are always considered to support this feature. This allows us to remove the checks once the minimum required version to test sourcekit-lsp exceeds the specified version.
- If the toolchain version is the same as the Swift version that introduces the feature, we execute a closure that performs a fine-grained check to see if the feature is indeed supported. This differentiates toolchain snapshots which contain the feature from those that don’t.
- Tests are never skipped in Swift CI. This ensures that we don’t get passing tests because we hit the skip condition even though we are not expecting to hit it in Swift CI, which should have built an up-to-date toolchain.
- Use this new infrastructure to skip tests that aren’t passing using older Swift versions.
rdar://121911039
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
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.