Commit Graph

519 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
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
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
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
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
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
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
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
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
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
Alex Hoppen
a48d73b547 Use text match score to score completion items 2025-01-27 08:56:42 -08:00
Alex Hoppen
03da4a4747 Merge pull request #1937 from ahoppen/use-plugin
Use the SourceKit plugin for the code completion request
2025-01-27 08:42:09 -08:00
Alex Hoppen
fc100d24bf Cache the mapping from compiler to toolchain
While at it, also make `Toolchain.path` non-optional and clean up `ToolchainRegistry.init` slightly.
2025-01-25 21:32:44 -08:00
Alex Hoppen
2e21be85a6 Use the SourceKit plugin for the code completion request
This allows us to sort code completion items by their semantic score.

rdar://142909859
2025-01-25 08:57:55 -08:00
Alex Hoppen
6bde06b4aa Merge pull request #1951 from ahoppen/search-sourcekit-plugins
Load the SourceKit plugins when launching SourceKit-LSP
2025-01-25 08:53:25 -08:00
Alex Hoppen
ed098f58cb Merge pull request #1934 from ahoppen/multi-toolchain-support
Support opening documents within the same workspace with sourcekitd/clangd from different toolchains
2025-01-25 08:52:52 -08:00
Alex Hoppen
7bf63beb85 Load the SourceKit plugins when launching SourceKit-LSP
Previously, we were only loading the SourceKit plugins during tests. Make sure we find them in the toolchain as well.
2025-01-24 23:05:20 -08:00
Alex Hoppen
98b1294ad9 Support opening documents within the same workspace with sourcekitd/clangd from different toolchains
rdar://142909783
2025-01-24 22:32:05 -08:00
Alex Hoppen
64f2aef446 Fix build warnings
Quite a few of these were reminders to clean things up once we no longer need to support testing using compilers and sourcekitd from older toolchains.
2025-01-23 21:11:08 -08:00
Matthew Bastien
d4b63a2af5 add textDocument/convertDocumentation request to SourceKit-LSP 2025-01-17 11:11:54 -05:00
Alex Hoppen
31b1909ce1 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
2025-01-15 15:57:21 -08:00
Alex Hoppen
69121eed95 Merge pull request #1906 from ahoppen/add-sourcekit-plugin
Add a SourceKit plugin to handle code completion requests
2025-01-15 12:42:18 -08:00
Alex Hoppen
e26d9f68f6 Merge pull request #1915 from ahoppen/diags-from-symlinks
Return diagnostics if SwiftPM project is opened from a symlinked URL
2025-01-13 14:31:12 -08:00
Alex Hoppen
8ac1beec86 Merge pull request #1899 from iMostfa/feat/support-range-in-hover
feat: Support range in `textDocument/hover`
2025-01-10 21:57:15 +01:00
iMostafa
f2978b0491 Adjust tokenRange 2025-01-10 13:26:21 +02:00
Alex Hoppen
6063c27f82 Return diagnostics if SwiftPM project is opened from a symlinked URL
If you have a SwiftPM project at `/projects/myProject` and a symlink pointing from `/myProject` to `/projects/myProject`, we would correctly get build settings etc for the files. But, when getting diagnostics, sourcekitd would return these diagnostics for the full `/projects/myProject` path. We would then decide that those diagnostics didn’t matched the file you opened (inside `/myProject`) and thus suppress them.

Show diagnostics diagnostics if the originated from a file with the same realpath as the file you opened.

Fixes #1910
rdar://142386278
2025-01-09 22:48:12 +01:00
Alex Hoppen
e5f1bbfc03 Set plugin paths in all tests
Otherwise, we were trying to load sourcekitd without the plugins for the normal SourceKIt-LSP tests and with the plugins for the plugin tests.
2025-01-09 14:09:01 +01:00
Alex Hoppen
48389c75a2 Merge pull request #1912 from ahoppen/reduce-swiftpm-dependency
Support building SourceKit-LSP without a dependency on SwiftPM
2025-01-09 13:10:44 +01:00
Alex Hoppen
5326852ea8 Support building SourceKit-LSP without a dependency on SwiftPM 2025-01-08 13:13:31 +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
4303e44fcb Add semantic highlighting for macros 2025-01-02 13:25:58 +01:00
iMostafa
fb4ed6510e Support Range when hovering
By getting the token at hovering position, then get the token
position.
2024-12-30 12:26:40 +02:00
Alex Hoppen
a54c709425 When a sourcekitd diagnostics request fails, show the request error as a diagnostic on the source file
The missing diagnostics might be due to an error that the user can fix. Report it to them.

Fixes #1812
rdar://139514623
2024-12-12 16:32:33 -08:00
Alex Hoppen
1a708ec596 Merge pull request #1870 from ahoppen/no-escape-open-brace
Don’t escape `{` inside placeholder snippets
2024-12-06 18:25:06 -08:00
Alex Hoppen
ee1f4b13fc Don’t escape { inside placeholder snippets
When `\{` is included inside an LSP placeholder, in VS Code will insert `\{` verbatim. At least in VS Code, we only need to escape the closing brace.

While at it, also escape `$` and `\` inside placeholders, according to the LSP spec.
2024-12-06 12:26:22 -08:00
Alex Hoppen
67b98cd7b2 Batch updates to the syntactic test index on fileDidChange events
This is more performant. In particular adding a new task to `indexingQueue` for each file to rescan can hit the quadratic issue in `AsyncQueue` if many files were changed.
2024-12-06 08:24:09 -08:00
Alex Hoppen
21dfaf0f9c Merge pull request #1831 from woolsweater/the-trail-is-closed
Handle new swift-syntax closure expansion behavior
2024-12-05 16:59:51 -08:00
Matthew Bastien
debb5dc165 Merge pull request #1852 from matthewbastien/document-symbols
Include parameters in initializer document symbols
2024-12-05 16:48:18 -05:00
Josh Caswell
60beed85ae Customize closure expansion behavior
This resolves <https://github.com/swiftlang/sourcekit-lsp/issues/1788>,
following the discussion of alternatives on
<https://github.com/swiftlang/sourcekit-lsp/pulls/1789>. The bulk of the
change updates the translation from SourceKit placeholders to LSP
placeholders to handle nesting. The `CodeCompletionSession` also passes
a new custom formatter to the swift-syntax expansion routine, which
disables the transformation to trailing closures.
2024-12-05 08:57:41 -08:00