Commit Graph

1098 Commits

Author SHA1 Message Date
Alex Hoppen
8aa8fa0ff8 Remove offensive terms from the codebase 2025-03-07 13:58:02 -08:00
Alex Hoppen
1cfa8db1d8 Require Swift 6 to build SourceKit-LSP
This significantly cleans up our `import` statements
2025-03-07 08:05:49 -08:00
Alex Hoppen
698b384a8b Add - to swift-format invocation to indicate that file contents should be read from stdin
To match https://github.com/swiftlang/swift-format/pull/914
2025-03-06 22:53:26 -08:00
Alex Hoppen
2a1fd10295 Add an experimental LSP request to return the output paths for all files in a target 2025-03-06 08:30:47 -08:00
Alex Hoppen
2a12d21378 Merge pull request #2036 from ahoppen/log-invalid-language
Add log message if we can’t infer the language server type for a document that was opened
2025-03-05 23:50:46 -08:00
Alex Hoppen
9f5f06bc57 Merge pull request #2032 from ahoppen/ahoppen/response-file-indexing
Use response files to index files if argument list exceeds maximum number of arguments
2025-03-05 23:50:33 -08:00
Alex Hoppen
2bb79e3888 Add log message if we can’t infer the language server type for a document that was opened
Motivated by https://github.com/swiftlang/sourcekit-lsp/issues/2028#issuecomment-2702162160.
2025-03-05 13:53:28 -08:00
Alex Hoppen
5541060451 Use response files to index files if argument list exceeds maximum number of arguments 2025-03-05 13:33:40 -08:00
Alex Hoppen
51a035dce2 Use the BSP output file paths request to exclude units from the index that are no longer part of any targets 2025-03-05 09:58:37 -08:00
Alex Hoppen
2a05d940ff Merge pull request #2022 from ahoppen/structure-index-log
Add structure to the index logs
2025-03-05 09:56:47 -08:00
Alex Hoppen
655a93f05a Add structure to the index logs
When the client supports it, communicate the structure of tasks that were stared during background indexing or by the build server to the client. If there are multiple operations happening in parallel, this allows the client to display them in separate log tracks instead of interspersing them with the emoji prefixes like we do today.
2025-03-04 16:36:26 -08:00
Alex Hoppen
d696a946cd Merge pull request #2033 from ahoppen/standardized-file-paths
Allow a build system to use standardized paths while indexstore-db return realpaths
2025-03-04 16:34:56 -08:00
Alex Hoppen
f07a4bd531 Mark target preparation out-of-date when it has changed in the build server
When the target changes in the build server, it’s build settings might have changed, which  means that we can no longer assume that it’s up-to-date.
2025-03-04 08:51:53 -08:00
Alex Hoppen
28e3f99319 Allow a build system to use standardized paths while indexstore-db return realpaths
On Darwin platforms, this fixes the following problem: indexstore-db by itself returns realpaths but the build system might be using standardized Darwin paths (eg. realpath is `/private/tmp` but the standardized path is `/tmp`). Because of this, when inferring the main file for a file, we might get a URI that the build system doesn’t know about. To fix this, if the realpath that indexstore-db returns could not be found in the build system's source files but the standardized path is part of the source files, use the standardized path instead.
2025-03-03 21:16:14 -08:00
Alex Hoppen
bafd8babc1 Merge pull request #2013 from ahoppen/clean-background-index-up-to-date-checks
When the build system sends an update for build targets, update the index for the files in those targets
2025-03-03 20:34:13 -08:00
Alex Hoppen
6818cbe45a Log a few strings publicly
Just something I noticed while reading logs
2025-03-03 13:29:29 -08:00
Alex Hoppen
15c34bf849 Do not schedule re-indexing of files if they haven’t been modified since an in-progress index was requested
This fixes the following problem, which caused files to get indexed twice: You open a workspace, which schedules initial indexing. While we are waiting for the build graph generation from the build server, the build servers sends `buildTarget/didChange` notification to SourceKit-LSP (eg. because it has finished loading the build graph). This causes all files in the changed targets to be scheduled for re-indexing since new files might be present in the updated targets. And since we have already started indexing of those files, we assumed that we need to index them again because the contents might have changed.

To fix this, keep track of the file’s modification time at the time at which we scheduled indexing for it. If that time hasn’t changed and we have an in-progress indexing operation for it, there is no need to schedule another one.
2025-03-03 13:10:29 -08:00
Alex Hoppen
1c968226f1 When the build system sends an update for build targets, update the index for the files in those targets
For each file in the changed targets, we still check whether it has an up-to-date unit based on timestamps. The important thing for this change is that we start indexing files for which we only receive build settings after an update from the build server.
2025-03-01 09:25:45 -08:00
Alex Hoppen
0a54c25785 Merge pull request #1999 from ahoppen/schedule-initial-syntactic-test-population
Do not block initialization of the build server when build server is unresponsive in returning the list of test files
2025-02-28 15:36:17 -08:00
Alex Hoppen
3fc3616988 Merge pull request #2019 from ahoppen/sourcekitoptions-improvements
Small improvements to `workspace/_sourceKitOptions` request
2025-02-28 15:35:55 -08:00
Alex Hoppen
37aaa9218a Mark workspace/_sourceKitOptions as freestanding
The request doesn’t depend on any document state, so it should be freestanding instead of `workspaceRequest`.
2025-02-27 19:04:26 -08:00
Alex Hoppen
6a1d923f5b Add a request to check if SourceKit-LSP is currently performing any indexing 2025-02-27 12:52:28 -08:00
Alex Hoppen
bd6fb5d04c Do not block initialization of the build server when build server is unresponsive in returning the list of test files
We were blocking the initialization response on `self.buildSystemManager.testFiles`, which requires the list of test files to be determined. Make that operation asynchronous so that a slow build server can’t take down all of SourceKit-LSP.
2025-02-26 16:31:29 -08:00
Alex Hoppen
f4e015b3c0 Merge pull request #1988 from ahoppen/sourcekitoptions
Add an experimental request to return the build settings that SourceKit-LSP uses to process a file
2025-02-26 16:06:20 -08:00
Alex Hoppen
dae74db63c Merge pull request #2011 from ahoppen/client-specified-id
Add a `send` method to `InProcessSourceKitLSPClient` and `LocalConnection` in which the client specifies the request ID
2025-02-26 16:06:05 -08:00
Alex Hoppen
0258d1dd63 Merge pull request #2007 from ahoppen/dont-cache-failed-diag-reports
Do not cache diagnostic reports for sourcekitd requests that have failed
2025-02-26 16:05:42 -08:00
Alex Hoppen
66793ffbb2 Merge pull request #2000 from ahoppen/index-store-path-option
If a build server doesn’t specify `-index-store-path` in the SourceKit options, add it during background indexing
2025-02-26 12:30:07 -08:00
Alex Hoppen
9496b49c72 Add an experimental request to return the build settings that SourceKit-LSP uses to process a file
This can be useful to IDEs that want to perform some additional semantic processing of source files, which requires knowledge of a file’s build settings.
2025-02-26 09:12:47 -08:00
Alex Hoppen
db792c536f Add a send method to InProcessSourceKitLSPClient and Connection in which the client specifies the request ID 2025-02-26 08:41:30 -08:00
Alex Hoppen
c311e1bb13 Merge pull request #2003 from ahoppen/no-poll-index-for-file-change
Don’t poll the index for unit changes on every `filesDidChange` call
2025-02-25 20:56:29 -08:00
Alex Hoppen
abea29c9fa Do not cache diagnostic reports for sourcekitd requests that have failed
Otherwise, we return the failed diagnostic report even after sourcekitd has been restored.

Also, make sure that we don't show the `semantic editor is disabled` error to users.
2025-02-25 20:29:21 -08:00
Alex Hoppen
c40a786a6a Merge pull request #1994 from ahoppen/active-document-refinements
A couple refinements to the `window/didChangeActiveDocument` notification
2025-02-25 20:23:09 -08:00
Alex Hoppen
1209747496 Merge pull request #2001 from ahoppen/add-call-with-no-defaulted-arguments
Add calls with no defaulted arguments to code completion results
2025-02-25 19:53:08 -08:00
Alex Hoppen
447b8b5cbc Don’t poll the index for unit changes on every filesDidChange call
`pollForUnitChangesAndWait` is a costly operation since it iterates through all the unit files on the file system. We should only run it during initial indexing (where we might need to build the initial indexstore-db) but not for any subsequent indexing calls.
2025-02-25 15:15:09 -08:00
Alex Hoppen
bcdf91cf5e Add calls with no defaulted arguments to code completion results
The completion items that don’t have any of the defaulted arguments disappeared when we switched to the SourceKit plugin.
2025-02-25 14:59:17 -08:00
Alex Hoppen
1727a7bdf7 Remove options to override the index store path and index database path
We should always infer these from the build system and I can’t think of a reason to override these settings.
2025-02-25 14:24:15 -08:00
Alex Hoppen
9339791e83 Set useNewAPI when closing a code completion session
Otherwise, the close does not get handled by the SourceKit plugin. In practice, it doesn’t matter too much because the SourceKit plugin will implicitly close the last completion session when a new one is opened but we should fix this.
2025-02-25 08:04:58 -08:00
Alex Hoppen
baa3b70f7c A couple refinements to the window/didChangeActiveDocument notification
- Clarify that this must only be called with documents that are open in SourceKit-LSP and add a check for that.
- Allow sending `null` to indicate that no SourceKit-LSP document is currently active.
- Cancel preparation tasks for other workspaces that don’t contain the currently active document.
2025-02-24 13:58:19 -08:00
Alex Hoppen
1d1f1fb3dc Merge pull request #1989 from ahoppen/didchangactivedocument
Add notification to inform SourceKit-LSP about the currently active document
2025-02-23 21:27:23 -08:00
Alex Hoppen
b3ac424f67 Merge pull request #1986 from ahoppen/pause-background-indexing
Add an experimental request to pause background indexing
2025-02-21 13:12:52 -08:00
Alex Hoppen
f1aeb6c196 Add an experimental request to pause background indexing
This request allows IDEs to disable SourceKit-LSP’s background indexing functionality when it requires all compute resources for other, more interactive, tasks.
2025-02-21 08:09:34 -08:00
Alex Hoppen
4d00c9089b Add notification to inform SourceKit-LSP about the currently active document
SourceKit-LSP prepares the currently active file for editor functionality and currently infers the currently active document from whichever received the last `TextDocumentRequest`.

If an editor is capable of doing so, it should be able to report the document that the user currently has focused so that SourceKit-LSP does not have to infer this information from other requests.

Also clean up some handling code for experimental capabilities.
2025-02-20 12:29:30 -08:00
Matthew Bastien
151ac12463 add target name to command arguments 2025-02-20 11:20:05 -05:00
Matthew Bastien
96d8dd09b6 add target display name to run and debug code lenses 2025-02-20 11:20:05 -05:00
Alex Hoppen
825c17e50c Merge pull request #1970 from ahoppen/active-compilation-condition-no-swiftpm
Use an active compilation condition to build SourceKit-LSP without SwiftPM support
2025-02-05 22:31:16 -08:00
Alex Hoppen
1f17adb1e3 Merge pull request #1938 from ahoppen/completion-item-resolve
Support completionItem/resolve to compute documentation of a code completion item
2025-02-05 21:29:50 -08:00
Alex Hoppen
6678fb0e40 Use an active compilation condition to build SourceKit-LSP without SwiftPM support
This is more explicit than using `#if canImport(PackageModel)`.
2025-02-05 17:56:20 -08:00
Alex Hoppen
f6b83dbb1e Support completionItem/resolve to compute documentation of code completion item
Fixes #1935
2025-02-05 10:26:44 -08:00
Alex Hoppen
03da7e979d Merge pull request #1956 from ahoppen/reduce-syntactic-test-rescan
Do not schedule a syntactic test rescan if we know that we already have an up-to-date syntactic test index for it
2025-02-05 10:09:36 -08:00
Alex Hoppen
38df8c4da5 Do not schedule a syntactic test rescan if we know that we already have an up-to-date syntactic test index for it
If the build system is sending us with `buildTarget/didChange`, we would always create processor count * 4 new entries in the `indexingQueue` to rescan those files, if they are up-to-date. This can be quite wasteful if the underlying files didn’t actually change. Do a quick scan up-front to check if the files actually need to be re-scanned up-front.
2025-01-27 16:48:47 -08:00