Commit Graph

2451 Commits

Author SHA1 Message Date
Alex Hoppen
8aa8fa0ff8 Remove offensive terms from the codebase 2025-03-07 13:58:02 -08:00
Alex Hoppen
34f977219b Merge pull request #2041 from ahoppen/license-headers
Consistently add license headers to all files
2025-03-07 13:26:18 -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
cf828a8135 Consistently add license headers to all files
To prepare for the GitHub Action license header check.
2025-03-06 22:01:00 -08:00
Alex Hoppen
a7b7f21d88 Merge pull request #2035 from ahoppen/build-server-tests
Add a new test project type that uses a custom build server
2025-03-06 16:48:36 -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
5c60d1d39c Add a new test project type that uses a custom build server
This allows us to more easily test behavior for build servers that have different behavior than SwiftPM and compile commands without having to implement the build server in Python.
2025-03-05 23:54:32 -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
f6a29f43cb Merge pull request #2017 from ahoppen/output-file-paths
Add BSP request to get the output file paths of a target
2025-03-05 20:31:55 -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
0e22653b5e Merge pull request #2030 from ahoppen/plugin-logging
Add logging for requests handled by the SourceKit plugin
2025-03-05 13:36:54 -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
c3ecb9adae Add BSP request to get the output file paths of a target 2025-03-05 09:58:34 -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
300c40ba2c Merge pull request #2031 from ahoppen/public-logging
Log a few strings publicly
2025-03-03 18:24:22 -08:00
Alex Hoppen
fe750f6e09 Cache the set of buildable source files
This way we don’t need to rebuild the set every time we call `filesToIndex(toCover:)`.
2025-03-03 13:58:29 -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
2ee9dff5e5 Merge pull request #2023 from ahoppen/dont-escape-slashes
Don't escape slashes in various `JSONEncoder`s
2025-03-03 12:51:47 -08:00
Alex Hoppen
12b38fe1ea Add logging for requests handled by the SourceKit plugin 2025-03-03 12:17:19 -08:00
Alex Hoppen
45be280989 Make SKDRequestDictionaryReader conform to CustomStringConvertible 2025-03-03 12:16:49 -08:00
Alex Hoppen
2305dfab7a Don't escape slashes in various JSONEncoders
This makes the JSON easier to work with, especially for paths.
2025-03-03 07:55:09 -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
1a32c4a9f7 Fix a race that could lead to unnecessary scheduling of two update index store tasks 2025-03-01 09:25:23 -08:00
Alex Hoppen
0cb7c82d03 Use FileToIndex as the key of inProgressIndexTasks
Indexing a header via a main file and indexing the main file itself are two different index tasks that update the `indexStoreUpToDateTracker` in different ways. We should thus consider them differently in `inProgressIndexTasks` as well.
2025-03-01 09:24:13 -08:00
Alex Hoppen
86be2a442d Centralize up-to-date check in SemanticIndexManager
We had checks for whether we need to index a file or if it is up-to-date in multiple places of `SemanticIndexManager`. Centralize them in `filesToCover(toIndex:)`, so that it’s easier to reason about them.
2025-03-01 09:24:13 -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
4e44553125 Merge pull request #2020 from ahoppen/debounce-buildsettingschanged
Debounce `filesBuildSettingsChanged` calls
2025-02-28 15:36:06 -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
18b18c2b12 Debounce filesBuildSettingsChanged calls
This helps in the following situation: A build system takes 5s to return build settings for a file and we have 10 requests for those build settings coming in that time period. Once we get build settings, we get 10 calls to `resultReceivedAfterTimeout` in `buildSettings(for:in:language:fallbackAfterTimeout:)`, all for the same document.
But calling `fileBuildSettingsChanged` once is totally sufficient.
2025-02-27 21:54:04 -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
112252632d Make response of workspace/_sourceKitOptions request non-optional
The response was not specified as being optional and shouldn’t be.
2025-02-27 19:03:50 -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
58bce8225f Add a concurrentForEach method to start a concurrent task for each element in a collection
This is simpler to reason about than creating a `TaskGroup`.
2025-02-26 16:27:56 -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
Ben Barham
85e0f96ac0 Merge pull request #1995 from bnbarham/fix-backslash
Fix a couple testing paths on Windows
2025-02-26 00:33:17 -08:00