Commit Graph

1005 Commits

Author SHA1 Message Date
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
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
718c0ee809 Remove imports of SwiftPM modules that are not strictly necessary 2025-01-08 12:43:43 +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
320177ff85 Merge pull request #1902 from ahoppen/clear-in-progress-on-queue
Clear `inProgressTextDocumentRequests` on `textDocumentTrackingQueue`
2025-01-02 18:40:11 +01:00
Alex Hoppen
3f085600ef Merge pull request #1903 from ahoppen/macro-highlighting
Add semantic highlighting for macros
2025-01-02 18:40:01 +01:00
Alex Hoppen
4303e44fcb Add semantic highlighting for macros 2025-01-02 13:25:58 +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
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
lijunliang.9819
4987a40359 fix ASTBuild command exec failed 2024-12-20 16:55:18 +08: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
5eb460f148 Fix background indexing behavior if a source file is included in two targets via a symlink
Consider the following scenario: A project has target A containing A.swift an target B containing B.swift. B.swift is a symlink to A.swift. When A.swift is modified, both the dependencies of A and B need to be marked as having an out-of-date preparation status, not just A.
2024-12-09 15:06:39 -08:00
Alex Hoppen
87af5b06f1 Merge pull request #1857 from ahoppen/no-implicit-completion-cancellation 2024-12-07 08:56:38 -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
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
f59fb2bb2f Merge pull request #1863 from ahoppen/index-schedule-progress
Improve logic for build graph generation status
2024-12-06 13:35:39 -08:00
Alex Hoppen
14264b769b Merge pull request #1871 from ahoppen/settrace-freestanding
Treat `$/setTrace` as a freestanding message
2024-12-06 13:33:10 -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
f376e669bd Merge pull request #1869 from ahoppen/batch-filedidchange-syntacticindex
Batch updates to the syntactic test index on fileDidChange events
2024-12-06 12:25:16 -08:00
Alex Hoppen
2bf477675e Merge pull request #1868 from ahoppen/only-calls-in-call-hierarchy
Only show call-like occurrences in call hierarchy.
2024-12-06 12:22:13 -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
697e65acdc Improve logic for build graph generation status
`generateBuildGraph` was named misleadingly because the primary purpose of these tasks was to schedule indexing tasks and generating the build graph was just a necessary step for this. Also update it to take into account that multiple tasks scheduling indexing tasks might be running in parallel.
2024-12-06 09:07:18 -08:00
Alex Hoppen
7c474fdc58 Treat $/setTrace as a freestanding message
`$/setTrace` changes a global configuration setting but it doesn't affect the result of any other request. To avoid blocking other requests on a `$/setTrace` notification the client might send during launch, we treat it as a freestanding message.
Also, we don't do anything with this notification at the moment, so it doesn't matter.
2024-12-06 08:57:27 -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
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
9bbb8f3287 Merge pull request #1854 from matthewbastien/documentation-language-service
Handle `*.md` and `*.tutorial` files from Swift DocC
2024-12-05 20:35:23 -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
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
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
Matthew Bastien
b4cf0da663 address review comments 2024-12-05 14:13:23 -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
Matthew Bastien
8fd30908e7 handle *.md and *.tutorial files for Swift DocC 2024-12-05 11:18:49 -05:00
Matthew Bastien
e938dfaa7d include parameters in initializer document symbol 2024-12-04 16:42:04 -05: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
51634d8f08 Merge pull request #1840 from ahoppen/async-queue-quadratic
Fix quadratic performance issue in `AsyncQueue<Serial>`
2024-12-03 14:38:36 -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
Alex Hoppen
eb982d5b1e Fix quadratic performance issue in AsyncQueue<Serial>
Adding an item to `AsyncQueue` was linear in the number of pending queue items, thus adding n items to an `AsyncQueue` before any can execute is in O(n^2). This decision was made intentionally because the primary use case for `AsyncQueue` was to track pending LSP requests, of which we don’t expect to have too many pending requests at any given time.

While we can't fix the quadratic performance issue in general, we can resolve the quadratic issue of `AsyncQueue<Serial>` by making a new task only depend on the last item in the queue, which then transitively depends on all the previous items. `AsyncQueue<Serial>` are the queues that are most likely to contain many items.

Fixes #1725
rdar://137886469
2024-11-22 15:33:57 +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
1f33ed484d Split SKUtilities from SKSupport 2024-11-13 16:53:54 -08:00