Commit Graph

63 Commits

Author SHA1 Message Date
Matthew Bastien
0e05bca76c remove isHeader from SourceKitSourceItemData 2025-04-16 14:44:13 -04:00
Matthew Bastien
0adaf2581f more robust searching for DocC catalogs 2025-04-16 14:44:12 -04:00
Alex Hoppen
77b39200dc Fix typos 2025-03-17 17:10:00 -07:00
Alex Hoppen
4991e1560c Re-index header files when they are modified 2025-03-14 15:50:11 -07:00
Alex Hoppen
d10c868497 Support indexing a file in the context of multiple targets
If a source file is part of multiple targets, we should index it in the context of all of those targets because the different targets may produce different USRs since they might use different build settings to interpret the file.
2025-03-14 15:49:59 -07:00
Alex Hoppen
c9a1a08255 Make output paths part of the buildTarget/sources request instead of a separate request
We need a mapping from source file to its output path in order to support source files that are part of multiple targets (because we need the output path to check if we have an up-to-date unit for a file in a given target). To achieve this mapping, it’s easier to tag the output path for each source file onto the `buildTarget/sources` request.
2025-03-14 15:12:38 -07:00
Alex Hoppen
cb17643752 Make a couple parameters in the BuildTarget initializer defaulted 2025-03-14 15:12:38 -07: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
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
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
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
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
5efdd19a3b Remove superfluous semicolons 2025-02-25 15:01:29 -08:00
Alex Hoppen
8414e2938c Add CancelRequestNotification to BSP notification types
Otherwise a client that uses the `BuildServerProtocol` modules to implement a BSP server can’t deserialize the `$/cancelRequest` notification.
2025-02-21 20:59:04 -08:00
Alex Hoppen
cda8788119 Improve two imports
- Import `LanguageServerProtocol` in `BuildServerProtocol/TextDocumentIdentifier.swift` because we use `URI` publicly within it.
- Don’t import `LanguageServerProtocolExtensions` in `ToolchainRegistry` because it’s not needed
2025-01-14 17:25:19 -08:00
Alex Hoppen
c1e090ef33 Address minor review comments 2024-11-13 10:09:31 -08:00
Alex Hoppen
06f58db5c8 Use build/taskStart, build/taskProgress and build/taskFinish to communicate progress from a BSP server to the client
Instead of defining BSP extensions for `window/workDoneProgress/create` and `$/progress`, we should be able to use the standard `build/taskStart`, `build/taskProgress` and `build/taskFinish` messages to the same effect, as suggested by https://forums.swift.org/t/extending-functionality-of-build-server-protocol-with-sourcekit-lsp/74400/9.

Fixes #1783
rdar://138653131
2024-11-06 09:39:09 -08:00
Alex Hoppen
c4e246b351 Add BSP definitions for task start, progress and finish notifications 2024-11-05 21:58:28 -08:00
Alex Hoppen
01640ee68f Merge pull request #1731 from ahoppen/bsp-implementation-documentation
Add a document that describes the basic steps needed to implement a BSP server
2024-10-02 10:27:30 -07:00
Alex Hoppen
c2d1c15310 Add a document that describes the basic steps needed to implement a BSP server 2024-09-30 14:51:07 -07:00
Alex Hoppen
36478d87ed Allow build systems to specify the files to watch for changes
rdar://136014553
Resolves #1671
2024-09-30 10:33:32 -07:00
Alex Hoppen
8cd831b55d Adopt InternalImportsByDefault 2024-09-27 09:17:13 -07:00
Alex Hoppen
1fd700b810 Expose all BSP messages used by SourceKit-LSP to BSP servers
The interaction to an out-of-process BSP server still went through the `BuildServerBuildSystem`, which doesn’t forward all messages to the build system and uses the old push-based model for build settings.

If we discover that the BSP server supports the new pull-based build settings model, we now forward all methods to it directly, without going through `BuiltInBuildSystemAdapter`, which has been renamed to `LegacyBuildServerBuildSystem`.

rdar://136106323
rdar://127606323
rdar://126493405
Fixes #1226
Fixes #1173
2024-09-24 22:47:07 -07:00
Alex Hoppen
316790ff7a Review BuiltInBuildSystem 2024-09-16 10:12:34 -07:00
Alex Hoppen
85b2f1fd30 Review BuildServerProtocol module for consistency 2024-09-16 10:10:26 -07:00
Alex Hoppen
5870ad9eb4 Implement InverseSourcesRequest in BuildSystemManager
`buildTarget/inverseSources` is not required to be implemented by BSP servers and we have almost all information needed for it in `BuildSystemManager`.

This also makes sure that `buildTarget/sources` and `buildTarget/inverseSources` actually match each other. Before this change, we had source files like `Package.swift` for which we returned a target from `buildTarget/inverseSources` but that weren’t part of that target’s sources retrieved using `buildTarget/sources`.
2024-09-16 10:08:14 -07:00
Alex Hoppen
5ffc782316 Add BSP messages to bspRegistry 2024-09-16 10:06:35 -07:00
Alex Hoppen
6cc2cc4e95 Implement reloadPackageStatusCallback using BSP messages 2024-09-15 16:28:12 -07:00
Alex Hoppen
fac21f5976 Implement waitForUpToDateBuildGraph using BSP 2024-09-13 11:12:40 -07:00
Alex Hoppen
12923b6d73 Implement toolchain(for:) using BSP 2024-09-13 11:12:40 -07:00
Alex Hoppen
9006ab6fc8 Use the InitializeRequest from BSP to communicate some static options between the build system and BuildSystemManager 2024-09-12 07:34:12 -07:00
Alex Hoppen
9d94fe36a9 Migrate defaultLanguage(for:) to BSP 2024-09-12 07:34:12 -07:00
Alex Hoppen
c5ba9671f0 Migrate getting the list of all source files to BSP 2024-09-11 13:42:01 -07:00
Alex Hoppen
3a118980b4 Migrate BuildSystem.prepare to a BSP request 2024-09-11 09:48:50 -07:00
Alex Hoppen
f9e468ffba Use BSP requests to get build settings of a source file 2024-09-10 09:30:36 -07:00
Alex Hoppen
b490a6fef1 Use buildTarget/inverseSources from BSP to get targets of a source file 2024-09-09 16:31:30 -07:00
Alex Hoppen
e38d37e01c Use workspace/didChangeWatchedFiles from BSP to communicate file changes to the build system 2024-09-09 16:31:00 -07:00
Alex Hoppen
aa424d9eb4 Make the BuildServerProtocol module build with strict concurrency enabled 2024-03-12 13:14:25 -07:00
Alex Hoppen
d0fc00ce98 Format using swift-format
Add `.swift-format` to the repo and format the repo with `swift-format`.

This commit does not add any automation to enforce formatting of sourcekit-lsp in CI. The goal of this commit is to get the majority of source changes out of the way so that the diff of actually enforcing formatting will have fewer changes or conflicts.
2023-10-10 13:44:47 -07:00
Saleem Abdulrasool
fca0cd3913 build: build SourceKit-LSP with static linking
This adjusts the sourcekit-lsp build to use static linking for the
internal libraries.  It is not currently possible to build
SourceKitLSP.dll as that requires re-exporting the interfaces from the
consumed modules.  However, this allows us to reduce the overall size of
the distribution of SourceKit-LSP by ~1 MiB and reduces the
distributed file set.  The values here assume partial static linking of
swift-package-manager, which helps reduce the total size.

Before:

   228,352 BuildServerProtocol.dll
 1,773,056 LanguageServerProtocol.dll
   114,688 LanguageServerProtocolJSONRPC.dll
    49,152 LSPLogging.dll
   262,656 SKCore.dll
    54,784 SKSupport.dll
    80,896 SKSwiftPMWorkspace.dll
   150,528 SourceKitD.dll
   645,632 SourceKitLSP.dll

    70,144 sourcekit-lsp.exe

 3,429,888 bytes

After:

 2,416,640 sourcekit-lsp.exe

 2,416,640 bytes
2022-03-02 08:43:06 -08:00
Saleem Abdulrasool
54d5324613 build: add CMake build system 2019-12-04 16:47:34 -08:00
Ben Langmuir
ab4a25d581 [BSP] Use URI instead of URL
Similar to LSP, BSP also uses URI. We were handling this correctly
everywhere except one test that was using a string with no scheme.
2019-11-20 09:41:48 -08:00
Alex Hoppen
5c839f8640 Add support for non-URL URIs
According to the LSP specification, arbitrary URIs can be used as
document identifiers. Instead of internally assuming that all URIs are
URLs, use a DocumentURI enum to represent URIs. These can either be file
URLs or other URIs whose value as treated as an opaque string.
2019-11-20 09:41:48 -08:00
Richard Howell
130d81c96f make event kind optional 2019-10-21 11:24:07 -07:00
Richard Howell
4c59633e2d add test case 2019-10-21 10:39:22 -07:00
Richard Howell
1d7858e023 call delegate on build targets change 2019-10-21 10:39:22 -07:00
Richard Howell
ec9681023e add BuildTargetChangedNotification 2019-10-21 10:39:22 -07:00
Richard Howell
0f6f260701 add interface for fetching output paths 2019-10-04 14:51:26 -07:00
Richard Howell
ca63a2e69d add request for build target output paths 2019-10-04 14:50:48 -07:00