Commit Graph

981 Commits

Author SHA1 Message Date
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
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
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
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
Alex Hoppen
47f3cd506b Split TSCExtensions into a separate module 2024-11-13 13:58:36 -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
Alex Hoppen
c1e090ef33 Address minor review comments 2024-11-13 10:09:31 -08:00
Alex Hoppen
3a1896090f Merge pull request #1806 from MahdiBM/mmbm-range-formatting
Handle `DocumentRangeFormattingRequest`
2024-11-08 20:25:45 -08:00
MahdiBM
8f3253d773 support range formatting 2024-11-08 15:25:48 +03:30
Alex Hoppen
5c7d495ebd Merge pull request #1808 from ahoppen/member-import-visibility
Adopt `MemberImportVisibility`
2024-11-07 15:38:05 -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
1d7c27bc4b Adopt MemberImportVisibility 2024-11-05 21:04:01 -08:00
Alex Hoppen
331599efef Merge pull request #1798 from ahoppen/linetable-crash
Fix a crash when trying to apply in edit that has out of line positions
2024-11-01 12:30:51 -07:00
Alex Hoppen
bdf5ab45fa Merge pull request #1793 from plemarquand/document-tests-index-extension-fix
XCTests in extensions produced by symbols have no parent ID
2024-11-01 12:27:50 -07:00
Alex Hoppen
da10fbbdcb Fix a crash when trying to apply in edit that has out of line positions
`LineTable.replace` did not actually validate that the edit is in range. This could cause crashes of SourceKit-LSP if the editor is sending us bogus edits. Validate the position, like we do in all the other position conversions and log a fault if the edit is out-of-range.

While fixing this, I found a couple more places where line table accesses were not properly guarded. I migrated them to safe alternatives as well.

rdar://138962353
2024-10-30 20:02:31 -07:00
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
2023c055c7 Reduce the number of log messages to log the translation for token types and token modifiers from clangd to SourceKit-LSP
This used to produce ~40 log entries, which was pretty spammy. Compact them into 1
2024-10-30 13:55:12 -07:00
Alex Hoppen
5d47358236 Merge pull request #1762 from ahoppen/build-settings-timeout 2024-10-23 23:50:58 -07:00
Alex Hoppen
9e9579d17f Merge pull request #1766 from ahoppen/documents-private
Make `DocumentManager.documents` private
2024-10-22 18:09:31 -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
2a84422d00 Make DocumentManager.documents private
`documents` needs to be guarded by `queue` and thus shouldn’t be accessible from outside the type. Also uncovered on incorrect use of it.
2024-10-16 11:23:57 -07:00
Alex Hoppen
5bae73fca8 Use fallback build settings if build system doesn’t provide build settings within a timeout
When we receive build settings after hitting the timeout, we call `fileBuildSettingsChanged` on the delegate, which should cause the document to get re-opened in sourcekitd and diagnostics to get refreshed.

rdar://136332685
Fixes #1693
2024-10-16 10:55:29 -07:00
Alex Hoppen
17b13a935a Merge pull request #1751 from ahoppen/windows-fixes 2024-10-11 11:31:44 -07:00
Rintaro Ishizaki
7add264c3e Update for EditorPlaceholder SPI changes in swift-syntax 2024-10-10 11:44:07 -07:00
Alex Hoppen
c16e33d281 Miscellaneous adjustments to make tests pass on Windows
This is mostly test infrastructure that needed adjusting.
2024-10-10 09:28:26 -07:00
Alex Hoppen
87db1bf614 Merge pull request #1736 from ahoppen/weak-back-ref
Make `BuildSystemManager` only keep a weak reference to `SourceKitLSPServer`
2024-10-04 15:54:24 -07:00
Alex Hoppen
52599974a8 Make BuildSystemManager only keep a weak reference to SourceKitLSPServer
This allows us to free `SourceKitLSPServer` in tests even if there are outstanding messages from the build server to be handled.
2024-10-03 17:41:54 -07:00