Commit Graph

197 Commits

Author SHA1 Message Date
Ben Barham
333e950df2 Allow workspace options to affect build system search
There were a few places that options only took place *after* determining
a build system, even though we have multiple that impact the search (eg.
`defaultBuildSystem` and `searchPaths`).

Additionally track project root and configuration paths separately, so
that when searching for implicit workspaces we can make sure to skip
creating duplicates.

(cherry picked from commit 0c896696c9)
2025-01-23 15:17:48 -08:00
Alex Hoppen
351a7814c6 Allow injection of build systems into SourceKitLSP
This allows us to clean up the creation of `TestBuildSystem` a little bit because the tests can create `TestBuildSystem` instead of retrieving it from the `BuildSystemManager`.

rdar://142906050
(cherry picked from commit 31b1909ce1)
2025-01-23 15:17:14 -08:00
Alex Hoppen
9e10ece2eb Remove imports of SwiftPM modules that are not strictly necessary
(cherry picked from commit 718c0ee809)
2025-01-23 11:43:18 -08:00
Alex Hoppen
c8f8c1e53d Avoid logging options for a workspace twice
We are already logging the options below.

(cherry picked from commit 760be317bc)
2025-01-23 11:42:59 -08:00
Alex Hoppen
2122cd36eb Revert "Merge pull request #1907 from ahoppen/remove-unused-method"
This reverts commit 991b8933bc, reversing
changes made to c214a5fdb1.
2025-01-08 09:43:54 +01:00
Alex Hoppen
c63ccc24d2 Revert "Merge pull request #1887 from ahoppen/generated-interface-reference-document"
This reverts commit f653ef3255, reversing
changes made to 233f2e6f37.
2025-01-08 09:43:07 +01:00
Alex Hoppen
17e2db073c Merge pull request #1909 from ahoppen/cache-container-names
Cache container names in `CheckedIndex`
2025-01-08 09:37:30 +01:00
Alex Hoppen
2a0902bb20 Cache container names in CheckedIndex
It is important that we cache this because we might find a lot of symbols in the same container for eg. workspace symbols (eg. consider many symbols in the same C++ namespace). If we didn't cache this value, then we would need to perform a `primaryDefinitionOrDeclarationOccurrence` lookup for all of these containers, which is expensive.

For example, searching for `only` in SourceKit-LSP’s codebase used to not return results in more than 20s (after which I gave up) and now returns >8000 results in <2s.

rdar://141412138
2025-01-03 16:00:22 +01:00
Alex Hoppen
2f53e7cf16 Remove SourceKitLSPServer.openGeneratedInterface
The method was never called.
2025-01-03 15:09:40 +01:00
Alex Hoppen
f653ef3255 Merge pull request #1887 from ahoppen/generated-interface-reference-document
Support semantic functionality in generated interfaces if the client supports `getReferenceDocument`
2025-01-03 14:35:01 +01:00
Alex Hoppen
8d73731bcb Support semantic functionality in generated interfaces if the client supports getReferenceDocument
This allows us to provide semantic functionality inside the generated interfaces, such as hover or jump-to-definition.

rdar://125663597
2025-01-02 20:29:36 +01:00
Alex Hoppen
e59df13bb0 Clear inProgressTextDocumentRequests on textDocumentTrackingQueue
`inProgressTextDocumentRequests` is supposed to only be accessed on `textDocumentTrackingQueue` but we were accessing it outside of that queue. Because of this, we might try to remove requests from `inProgressTextDocumentRequests` before adding them, which would cause them to stay in the list indefinitely.
2025-01-02 13:23:18 +01:00
Alex Hoppen
87af5b06f1 Merge pull request #1857 from ahoppen/no-implicit-completion-cancellation 2024-12-07 08:56:38 -08:00
Alex Hoppen
5183889e7e Merge pull request #1872 from ahoppen/no-background-indexing-warning
Don’t show warning message when opening projects that don't support background indexing
2024-12-06 18:16:23 -08:00
Alex Hoppen
cbd897de03 Don’t show warning message when opening projects that don't support background indexing
Since we enabled background indexing by default, the user is no longer explicitly opting into it. A user might be exclusively working with compilation database projects or BSP server without background indexing support and thus not care that we switched the background indexing default. We shouldn’t bother them with a warning message every time they launch sourcekit-lsp.
2024-12-06 12:12:26 -08:00
Alex Hoppen
751291e14f Only show call-like occurrences in call hierarchy.
`extension MyTask: AnyTask {}` includes an occurrence of `MyTask.cancel` to mark it as an override of `AnyTask.cancel` but we shouldn't show the extension in the call hierarchy.
2024-12-06 08:05:50 -08:00
Alex Hoppen
990ec7fc2a Don’t implicitly cancel code completion requests on document edits
As the user types, we filter the code completion results. Cancelling the completion request on every keystroke means that we will never build the initial list of completion results for this code completion session if building that list takes longer than the user's typing cadence (eg. for global completions) and we will thus not show any completions.
2024-12-05 14:43:56 -08:00
Alex Hoppen
9efa7e8cff Merge pull request #1844 from ahoppen/fully-qualified-names
Fully qualify type names in call hierarchy, type hierarchy and workspace symbols
2024-12-03 14:40:13 -08:00
Alex Hoppen
7a95075fcb Merge pull request #1842 from ahoppen/shutdown-null
Reply with `null` to `shutdown` request
2024-12-03 14:39:22 -08:00
Alex Hoppen
eb72e10886 Fully qualify type names in call hierarchy, type hierarchy and workspace symbols
Previously, we didn’t take outer types into account or only took one level of container type into account.

Fixes #1673
rdar://136078089
2024-11-22 21:33:26 +01:00
Alex Hoppen
e073a01bbc Reply with null to shutdown request
The LSP spec says the result of `shutdown` is `null`, not an empty object.

Fixes #1733
rdar://137886488
2024-11-22 15:52:27 +01:00
MahdiBM
a2eb7b9b2c Handle on-type formatting requests 2024-11-21 16:07:22 +03:30
Alex Hoppen
be546308ca Use URL in many cases where we used AbsolutePath
We made quite a few fixes recently to make sure that path handling works correctly using `URL` on Windows. Use `URL` in most places to have a single type that represents file paths instead of sometimes using `AbsolutePath`.

While doing so, also remove usages of `TSCBasic.FileSystem` an `InMemoryFileSystem`. The pattern of using `InMemoryFileSystem` for tests was never consistently used and it was a little confusing that some types took a `FileSystem` parameter while other always assumed to work on the local file system.
2024-11-18 18:19:48 -08:00
Alex Hoppen
9c84a344c8 Merge pull request #1817 from ahoppen/bsp-review 2024-11-14 08:10:02 -08:00
Alex Hoppen
8c2def8ef9 Rename SKSupport to LanguageServerProtocolExtensions 2024-11-13 16:53:58 -08:00
Alex Hoppen
1aa96fa099 Share common pattern of determining the build system for a workspace and creating it 2024-11-13 10:31:15 -08:00
Alex Hoppen
0fbb6466e7 Make BuildSystemKind a struct and rename to BuildSystemSpec 2024-11-13 10:23:43 -08:00
MahdiBM
8f3253d773 support range formatting 2024-11-08 15:25:48 +03:30
Paul LeMarquand
857cb61c79 XCTests in extensions have no parent ID
If the workspace has been indexed then TestItems are pulled from
indexed symbols. In this code path XCTests defined in extensions don't
have their parent class name appended to their ID.

As a result, when the user freshly opened a test file that contained
XCTests defined in extensions then their IDs would be incorrect.
However as soon as they made a change to the file then the method to
produce the document tests would switch over to getting the tests from
`languageService.syntatciDocumentTests(for:in:)` which does handle
tests in extensions correctly, and the issue would dissapear.
2024-10-30 16:23:26 -07:00
Alex Hoppen
951e923245 Use withUnsafeFileSystemRepresentation to get the path of a URL on disk
`URL.path` returns forward slashes in the path on Windows (https://github.com/swiftlang/swift-foundation/issues/973) where we expect backslashes. Work around that by defining our own `filePath` property that is backed by `withUnsafeFileSystemRepresentation`, which produces backslashes.

rdar://137963660
2024-10-21 11:12:30 -07:00
Alex Hoppen
ee29e31fb4 Merge pull request #1719 from ahoppen/explicit-bsp-shutdown
Explicitly shut down the build server when SourceKit-LSP is shut down
2024-10-02 10:27:15 -07:00
Alex Hoppen
3c7aa6f438 Merge pull request #1715 from ahoppen/bsp-cancellation
Share implementation of message handling on an `AsyncQueue` between `BuildSystemIntegration` and `SourceKitLSPServer`
2024-09-30 15:31:54 -07:00
Alex Hoppen
84878fe3a9 Merge pull request #1705 from ahoppen/watch-files-by-build-system
Allow build systems to specify the files to watch for changes
2024-09-30 15:31:41 -07:00
Alex Hoppen
d25b65c307 Explicitly shut down the build server when SourceKit-LSP is shut down
The build server is automatically shut down using a background task when `BuildSystemManager` is deallocated.

This, however, leads to possible race conditions where the shutdown task might not finish before the test is done, which could result in the connection being reported as a leak. To avoid this problem, we want to explicitly shut, down the build server when the `SourceKitLSPServer` gets shut down.
2024-09-30 11:57:39 -07:00
Alex Hoppen
4e53c01944 Merge pull request #1729 from ahoppen/reduce-public-imports
Reduce the number of public imports
2024-09-30 11:43:44 -07:00
Alex Hoppen
7befd0c648 Share implementation of message handling on an AsyncQueue between BuildSystemIntegration and SourceKitLSPServer
This gives us cancellation support for `BuiltInBuildSystemAdapter`.
2024-09-30 10:42:46 -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
d842579402 Merge pull request #1712 from ahoppen/build-system-logging-improvements
Improve logging surrounding build systems
2024-09-30 08:11:40 -07:00
Alex Hoppen
947e5269c4 Reduce the number of public imports 2024-09-30 07:50:12 -07:00
Alex Hoppen
bd422cf5d7 Improve logging surrounding build systems 2024-09-27 11:07:39 -07:00
Alex Hoppen
8cd831b55d Adopt InternalImportsByDefault 2024-09-27 09:17:13 -07:00
Alex Hoppen
78b4955d6c Log full initialize request and response
The initialize request and response are often critical to debug issues with editor setups. Log them completely over multiple log messages, instead of truncating them in the normal logging path.
2024-09-23 08:52:19 -07:00
Alex Hoppen
444ce41dec Log all options when opening a SourceKit-LSP workspace
Previously, OSLog was truncating these options after ~1000 bytes, which left out valuable information about the setup.
2024-09-23 08:52:18 -07:00
Alex Hoppen
6762bb3e25 Remove resolved FIXME 2024-09-16 10:10:26 -07:00
Alex Hoppen
d00722e33f Use BSP to log messages from preparation in the build system 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
3d95375043 Use a LocalConnection to communicate between BuildSystemManager and BuildSystem 2024-09-15 16:28:12 -07:00
Alex Hoppen
12923b6d73 Implement toolchain(for:) using BSP 2024-09-13 11:12:40 -07:00
Alex Hoppen
3a118980b4 Migrate BuildSystem.prepare to a BSP request 2024-09-11 09:48:50 -07:00
Alex Hoppen
236f566977 Instead of having FileHandlingCapability for a source file, check if it belongs to any targets 2024-09-11 08:27:12 -07:00