Commit Graph

484 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
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
Matthew Bastien
e938dfaa7d include parameters in initializer document symbol 2024-12-04 16:42:04 -05: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
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
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
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
1d7c27bc4b Adopt MemberImportVisibility 2024-11-05 21:04:01 -08: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
Alex Hoppen
5d47358236 Merge pull request #1762 from ahoppen/build-settings-timeout 2024-10-23 23:50:58 -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
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
Rintaro Ishizaki
7add264c3e Update for EditorPlaceholder SPI changes in swift-syntax 2024-10-10 11:44:07 -07:00
Alex Hoppen
947e5269c4 Reduce the number of public imports 2024-09-30 07:50:12 -07:00
Alex Hoppen
8cd831b55d Adopt InternalImportsByDefault 2024-09-27 09:17:13 -07:00
Alex Hoppen
2ec571b529 Revert "Require a Swift 6 compiler to build SourceKit-LSP"
This reverts commit 7ab7c01cdc.

# Conflicts:
#	Package.swift
2024-09-26 18:23:59 -07:00
Paul LeMarquand
87954813b9 Don't sort CodeActions
Returned code actions are often sorted in a predetermined, preferred
order. For instance, when proposing actions to handle error propagation
on a throwing function the option to handle the error with `try` should
appear before the more dangerous option to disable error propagation
with `try!`.

Fixes #1696
2024-09-23 16:17:10 -04:00
Alex Hoppen
0f78562eb4 Only reopen files for which the build settings actually changed 2024-09-18 07:57:55 -07:00
Alex Hoppen
7ab7c01cdc Require a Swift 6 compiler to build SourceKit-LSP
Xcode 16 with Swift 6 has been released, we can drop support for building and testing SourceKit-LSP using a Swift 5.10 toolchain. This allows us to remove a number of workarounds.
2024-09-17 16:53:13 -07:00
Alex Hoppen
014ebbeee5 Close code completion session when a document’s dependencies are updated
Even after sending the `dependencyUpdated` request to sourcekitd, the code completion session has state from before the AST update. Close it and open a new code completion session on the next completion request.
2024-09-17 15:06:20 -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
57055d4135 Make Workspace the delegate of a BuildSystemManager
`Workspace` is responsible for creating the `BuildSystemManager` and responds to most of the delegate calls. It should thus also be the delegate of `BuildSystemManager`.
2024-09-10 15:22:18 -07:00
Lokesh T R
0784041cf4 Support Semantic Functionality in Macro Expansion Reference Documents & Nested Macro Expansions 2024-08-21 15:01:37 +05:30
Alex Hoppen
8d5af39a7f Fix the build using a Swift 5.10 compiler
`host(percentEncoded:)` is not available using Swift 5.10 on Linux.

Bare slash regex literals are not enabled in Swift 5 mode.
2024-08-20 07:33:18 -07:00
Alex Hoppen
41c15bfc18 Merge pull request #1637 from ahoppen/review-comments-1631
Address review comments to #1631
2024-08-20 07:23:52 -07:00
Alex Hoppen
b45d975ab9 Merge pull request #1635 from lokesh-tr/remove-experimental-feature-flag-for-macro-expansions
Remove `ExperimentalFeature.showMacroExpansions` flag for macro expansions
2024-08-20 01:17:42 -07:00
Lokesh T R
a616fc1459 Remove ExperimentalFeature.showMacroExpansions flag for macro expansions 2024-08-20 07:07:36 +05:30
Alex Hoppen
3d6484dd90 Address review comments to #1631 2024-08-19 15:51:42 -07:00
Alex Hoppen
1f6bfce77c Merge pull request #1633 from ahoppen/remove-workarounds
Remove workarounds that are no longer needed
2024-08-19 14:53:41 -07:00
Alex Hoppen
5833322218 Merge pull request #1631 from ahoppen/nested-macro-expansions
Support expansion of nested macros
2024-08-18 11:58:36 -07:00
Alex Hoppen
189f32ae04 Remove workarounds that are no longer needed 2024-08-17 07:52:55 -07:00