Commit Graph

3683 Commits

Author SHA1 Message Date
Alex Hoppen
71dfc73453 Merge pull request #2042 from ahoppen/soundness-checks
Fix yaml lint error and remove offensive terms from the codebase
swift-DEVELOPMENT-SNAPSHOT-2025-03-09-a swift-DEVELOPMENT-SNAPSHOT-2025-03-10-a
2025-03-08 03:53:50 -08:00
Alex Hoppen
42cc692f84 Merge pull request #2045 from Mordil/nh-2040-in_process_client
Vend InProcessClient as a package library product
2025-03-07 18:55:43 -08:00
Alex Hoppen
8aa8fa0ff8 Remove offensive terms from the codebase 2025-03-07 13:58:02 -08:00
Alex Hoppen
1efbba325c Fix yaml lint error 2025-03-07 13:56:20 -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
39b76bb3f2 Merge pull request #2044 from ahoppen/require-swift-6
Require Swift 6 to build SourceKit-LSP
2025-03-07 13:05:11 -08:00
Nathan Harris
3d6a405362 Vend InProcessClient as a package library product 2025-03-07 14:34:37 -06: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
4ae360c755 Merge pull request #2043 from ahoppen/swiftformat-stdin
Add `-` to `swift-format` invocation to indicate that file contents should be read from stdin
2025-03-07 06:44:17 -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
a3c9cfd9bc Merge pull request #2039 from ahoppen/pollindex
Poll index in `testBuildSystemUsesStandardizedFileUrlsInsteadOfRealpath`
2025-03-06 19:00:20 -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
f92fa53d86 Merge pull request #2018 from ahoppen/output-paths-lsp-request
Add an experimental LSP request to return the output paths for all files in a target
2025-03-06 16:48:18 -08:00
Alex Hoppen
3b2160e319 Poll index in testBuildSystemUsesStandardizedFileUrlsInsteadOfRealpath
We need to make sure that all unit files are read into indexstore-db so that we know about the unit file that allows us to map from header to main file.

Fixes rdar://146392120
2025-03-06 13:52: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
375f9e5127 Merge pull request #2037 from ahoppen/flaky-workspacetestdiscovery-test
Fix nondeterministic failure in `testSyntacticOrIndexBasedXCTestsBasedOnWhetherFileIsIndexed`
2025-03-05 23:51:00 -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
9184f6556d Fix nondeterministic failure in testSyntacticOrIndexBasedXCTestsBasedOnWhetherFileIsIndexed
If we were indexing the modified file too fast, we would get semantic tests to the `workspace/tests` request while we were expecting syntactic results.

Add semaphores to ensure that indexing doesn’t finish until we have received the syntactic result.

rdar://146331921
2025-03-05 15:27:47 -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
eb4b083a94 Merge pull request #2034 from ahoppen/download-lap
Add section to `README` on how to download SourceKit-LSP
2025-03-04 16:35:05 -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
56a438576a Merge pull request #2025 from ahoppen/reprepare-target-when-changed
Mark target preparation out-of-date when it has changed in the build server
2025-03-04 16:34:32 -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
0ef094f50e Add section to README on how to download SourceKit-LSP
Motivated by https://github.com/swiftlang/sourcekit-lsp/issues/2028#issuecomment-2695559644.
2025-03-04 08:37:00 -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
swift-DEVELOPMENT-SNAPSHOT-2025-03-04-a
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
Rintaro Ishizaki
49d0338dab Merge pull request #2029 from rintaro/disable-rdar145905708
Disable SwiftSourceKitPluginTests.testCancellation
2025-03-03 09:51:58 -08:00
Rintaro Ishizaki
ec99b1f05c Disable SwiftSourceKitPluginTests.testCancellation
rdar://145905708
2025-03-03 09:50:47 -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