Commit Graph

10 Commits

Author SHA1 Message Date
Alex Hoppen
0fa7ffcee3 Allow specification of SourceKitLSPOptions in the initialize request
This allows editors to provide UI elements to toggle SourceKit-LSP options.

# Conflicts:
#	Sources/SourceKitLSP/Swift/SwiftLanguageService.swift
2024-06-28 22:55:53 +02:00
Alex Hoppen
3e9c682cc9 Allow configuring of SourceKit-LSP’s options using .sourcekit-lsp configuration files
The idea here is to unify the different ways in which we can currently set options on SourceKit-LSP in a scalable way: Environment variables, command line arguments to `sourcekit-lsp` and initialization options.

The idea is that a user can define a `~/.sourcekit-lsp/.sourcekit-lsp` file (we store logs in `~/.sourcekit-lsp/logs` on non-Darwin platforms), which will be used as the default configuration for all SourceKit-LSP instances. They can also place a `.sourcekit-lsp` file in the root of a workspace to configure SourceKit-LSP for that project specifically, eg. setting arguments that need to be passed to `swift build` for that project and which thus also need to be set on SourceKit-LSP.

For compatibility reasons, I’m mapping the existing command line options into the new options structure for now. I hope to delete the command line arguments in the future and solely rely on `.sourcekit-lsp` configuration files.

Environment variable will be migrated to `.sourcekit-lsp` in a follow-up commit.

# Conflicts:
#	Sources/SourceKitLSP/SourceKitLSPServer+Options.swift
#	Sources/SourceKitLSP/Swift/SwiftLanguageService.swift
#	Sources/sourcekit-lsp/SourceKitLSP.swift
#	Tests/SourceKitLSPTests/BackgroundIndexingTests.swift
#	Tests/SourceKitLSPTests/ExecuteCommandTests.swift
2024-06-28 22:35:15 +02:00
Alex Hoppen
8642768902 Fix a few Swift concurrency warnings 2024-06-18 18:07:22 -07:00
Alex Hoppen
05dd10257d Wait for target to be prepared before returning diagnostics
Diagnostics are usually not helpful if the file’s target hasn’t been prepared yet. We should await the target’s preparation before returning diagnostics.

rdar://128645617
2024-05-26 18:55:15 -07:00
Alex Hoppen
815fea827e Add infrastructure to test which targets are being prepared 2024-05-20 09:49:24 -07:00
Alex Hoppen
eaa378f390 Plumb capabilities to SwiftPMTestProject and add a closure that can be executed before SourceKit-LSP is initialized 2024-05-14 06:38:22 -07:00
Alex Hoppen
e5254c0c8e Allow serverOptions to be specified on SwiftPMTestProject
This will allow us to conditionally enable background indexing in tests
2024-05-03 14:48:15 -07:00
Alex Hoppen
1d9b67b0b9 Don’t include files from package dependencies in the syntactic test index
`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
2024-04-24 11:13:40 -07:00
Alex Hoppen
fd7b268431 Reload a file when other files within the same module or a .swiftmodule file has been changed
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 #620
Fixes #1116
rdar://99329579
rdar://123971779
2024-04-23 09:34:20 -07:00
Alex Hoppen
161171668c Rename test projects for consistency
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
2024-03-20 22:50:34 +01:00