Commit Graph

56 Commits

Author SHA1 Message Date
loveucifer
4ece7f9eea fix trailing trivia handling 2026-01-15 08:02:34 +05:30
loveucifer
d465ba967a multiline string interpolation 2026-01-09 16:09:33 +05:30
Alex Hoppen
7495f5532f Merge pull request #2387 from DPrakashh/feature/snippets-2118
[#2118] Implement keyword snippets for control-flow keywords (if/for/while/etc.)
2025-12-21 12:05:49 +01:00
Divya Prakash
0e8fb5fa21 Refactor keyword snippets: update tab stop order, use descriptive placeholders, and align switch cases 2025-12-19 15:43:47 +05:30
Divya Prakash
2abad47760 fix: resolve snippet issues 2025-12-18 21:49:24 +05:30
Divya Prakash
dde3c8427e 2118: Implement keyword snippets for control-flow keywords 2025-12-10 20:42:39 +05:30
Adam Ward
a7dfaad45a Don't reuse syntaxTreeManager 2025-12-08 15:16:36 -05:00
Alex Hoppen
219428328c Address my own review comments
Apply the following changes:
- Check for the presence of `#Playgrounds` textually before getting the module name in `SwiftPlaygroundsScanner`. This is important because getting the module name requires us to get build settings for the file, which can be expensive. Do the cheaper check first
- Make `syntacticTests` and `syntacticPlaygrounds` closures capture the workspace instead of passing the workspace from the `SwiftSyntacticIndex` back out. I like this better because now we can’t accidentally pass the wrong workspace to a `SwiftSyntacticIndex`, eg. to `buildTargetsChanges`.
- Capture the initialize result in `TestSourceKitLSPClient` instead of using `postInitialization` to capture the result
- Minor cleanup of unnecessary abstractions, likely artifacts of earlier iterations
- Restructure tests so that every test has its own list of source files, allowing for easier local reasoning – turns out some of these tests didn’t even need to open a workspace, just to check the initialize response
2025-12-08 15:16:36 -05:00
Adam Ward
1b7e5a8dfe Fix CMake files 2025-12-08 15:16:36 -05:00
Adam Ward
308375a135 Move syntactic index back to Workspace 2025-12-08 15:16:36 -05:00
Adam Ward
9602433d2a Add new workspace/playgrounds request 2025-12-08 15:16:36 -05:00
Anthony Latsis
d1b9c27b95 Merge pull request #2366 from AnthonyLatsis/jepa
Enable some Swift 7 mode features
2025-12-02 17:37:01 +00:00
Anthony Latsis
6b19657739 Enable ExistentialAny 2025-12-02 12:27:27 +00:00
Alex Hoppen
99f2bb3915 Merge pull request #2364 from ahoppen/no-optional-map
Don’t use `Optional.map` or `Optional.flatMap`
2025-12-02 00:01:23 +01:00
Alex Hoppen
f9f13a4105 Don’t use Optional.map or Optional.flatMap
Replace usages of `Optional.map` and `Optional.flatMap` by if expressions or other expressions.

I personally find `Optional.map` to be hard to read because `map` implies mapping a collection to me. Usually the alternative constructs seem clearer to me.
2025-11-20 09:47:21 +01:00
Vladimir Gusev
9647dcc3dc Convert between computed properties and zero-parameters functions 2025-11-14 12:00:46 +03:00
Adam Ward
927d347778 Fix spelling error in CMakelist 2025-11-11 13:48:06 -05:00
Adam Ward
2830c55fc0 Fix Swift format error 2025-11-11 13:46:02 -05:00
award999
0366a4dcbb Update Sources/SwiftLanguageService/CMakeLists.txt
Co-authored-by: Alex Hoppen <alex@alexhoppen.de>
2025-11-11 07:52:52 -05:00
Adam Ward
0f82f33f96 Use utf8 column 2025-11-10 11:14:25 -05:00
Adam Ward
ddcddded67 Support swift.play in textDocument/codelens request
- New `swift.play` CodeLens support that is an experimental feature while [swift play](https://github.com/apple/swift-play-experimental/) is still experimental
- Add #Playground macro visitor to parse the macro expansions
- File must `import Playgrounds` to record the macro expansion
- The `swift-play` binary must exist in the toolchain to
- TextDocumentPlayground will record the id and optionally label to match detail you get from
```
$ swift play --list
Building for debugging...
Found 1 Playground
* Fibonacci/Fibonacci.swift:23 "Fibonacci"
```
- Add LSP extension documentation for designing pending `workspace/playground` request
- Add new parsing test cases
- Update CMake files

Issue: #2339 #2343

Add column to unnamed label

Update Sources/SwiftLanguageService/SwiftCodeLensScanner.swift

Co-authored-by: Alex Hoppen <alex@alexhoppen.de>

Update Sources/SwiftLanguageService/SwiftPlaygroundsScanner.swift

Co-authored-by: Alex Hoppen <alex@alexhoppen.de>

Update Sources/SwiftLanguageService/SwiftPlaygroundsScanner.swift

Co-authored-by: Alex Hoppen <alex@alexhoppen.de>

Update Tests/SourceKitLSPTests/CodeLensTests.swift

Co-authored-by: Alex Hoppen <alex@alexhoppen.de>

Address review comments

Fix test failures

Fix more review comments

Update for swift-tools-core
2025-11-07 15:51:17 -05:00
Mishal Shah
0876b7d403 Merge pull request #2324 from owenv/owenv/adopt-swift-tools-protocols
Adopt swift-tools-protocols
2025-11-05 09:02:00 -08:00
Owen Voorhees
f04b971726 Adopt swift-tools-protocols 2025-10-31 14:11:11 -07:00
Alex Hoppen
d9295b2c93 Add a closing parenthesis to function argument completions
Fixes #782
2025-10-30 14:38:33 +01:00
Alex Hoppen
4c957506e8 Add a code action to remove unused imports in a source file
The idea is pretty simple: When `MemberImportVisibility` is enabled, we know that imports can only affect the current source file. So, we can just try and remove every single `import` declaration in the file, check if a new error occurred and if not, we can safely remove it.
2025-10-22 23:56:09 +02:00
Alex Hoppen
2ad02363a3 Show inlay hints of #if conditions at their corresponding #endif directives
Fixes #2221
2025-10-13 16:35:05 +02:00
Alex Hoppen
a6c291b84e Do not block SourceKit-LSP functionality when a build server takes long to initialize
We previously waited for the initialization response from the build server during the creation of a `Workspace` so that we could create a `SemanticIndexManager` with the index store path etc. that was returned by the `build/initialize` response. This caused all functionality (including syntactic) of SourceKit-LSP to be blocked until the build server was initialized.

Change the computation of the `SemanticIndexManager` and related types to happen in the background so that we can provide functionality that doesn’t rely on the build server immediately.

Fixes #2304
2025-09-29 13:02:08 +01:00
Alex Hoppen
95538e7de9 Migrate appendingPathComponent to appending(component:)
`appending(component:)` is the more modern API and can take multiple path components at the same time.
2025-09-23 16:57:56 +02:00
Alex Hoppen
aa7ff70042 Merge pull request #2300 from ahoppen/drop-6.1
Drop support for building with Swift 6.1
2025-09-22 14:16:39 +02:00
Alex Hoppen
c7ca73aecb Drop support for building with Swift 6.1
Swift 6.2 has been released, so we no longer need to support building and testing SourceKit-LSP using Swift 6.1
2025-09-20 16:37:24 +02:00
Ben Barham
1313ef4520 Remove SwiftPM dependency from SwiftLanguageService
This was needed for the package manifest refactorings, but they're
now provided by swift-syntax instead.
2025-09-15 19:48:46 -07:00
Alex Hoppen
37aafd35c0 Merge pull request #2287 from ahoppen/multi-line-completion-item-formatting 2025-09-10 09:43:29 +02:00
Alex Hoppen
e43c808afd Format multi-line completion items returned by sourcekitd
For closures that don’t take any inputs and that don’t produce output, sourcekitd returns a completion item that has the trailing closure already expanded. Run SwiftBasicFormat on those to enure that the placeholder for the closure’s body is properly indented.

Fixes #2285
2025-09-09 14:47:10 +02:00
Ahmed Elrefaey
a5854f4ecf Add signature help LSP request support (#2250)
Depends on https://github.com/swiftlang/swift/pull/83378

---

Adds support for the LSP signature help request.

> [!NOTE]
> As of https://github.com/swiftlang/swift/pull/83378, SourceKitD still
doesn't separate parameter documentation from the signature
documentation and thus parameters don't have their own separate
documentation. This should just work once SourceKitD implements this
functionality and we'll only need to modify the tests.
2025-09-05 14:52:56 +01:00
Ahmed Elrefaey
1982798b5d Fetch full documentation in code completion (#2207)
When resolving documentation for code completion items, we fetch full
documentation through the newly added
`swiftide_completion_item_get_doc_full_copy` SourceKitD function, if not
found we fallback to brief documentation as before using
`swiftide_completion_item_get_doc_brief`.

> [!NOTE]
> Unlike brief documentation, SourceKitD doesn't cache full
documentation for completion results to avoid bloating memory with a lot
of large strings.
>
> As of now, SourceKit-LSP doesn't cache completion item documentation
either, should we introduce a new full documentation cache (e.g. using
`LRUCache`)?
2025-09-04 19:42:37 +01:00
Alex Hoppen
47ca76bb32 Merge pull request #2226 from matthewbastien/docc-cache-snapshots
[DocC Live Preview] Cache on-disk snapshots opened in sourcekitd
2025-08-27 23:30:42 +02:00
Ben Barham
17d260507a Merge pull request #2262 from xedin/adopt-refactoring-actions-to-use-edit-provider
[SwiftLanguageService] Adopt changes to package manifest refactoring …
2025-08-27 13:30:03 -07:00
Matthew Bastien
58096eb822 cache snapshots opened in sourcekitd by textDocument/doccDocumentation requests 2025-08-27 15:30:50 +02:00
Pavel Yaskevich
061c7a094b [SwiftLanguageService] CodeActions: Use asWorkspaceEdit in more places 2025-08-26 14:04:36 -07:00
Pavel Yaskevich
0594744a93 [SwiftLanguageService] Adopt changes to package manifest refactoring actions
Previously package manifest refactoring actions conformed to a custom
refactoring provider and produced a `PackageEdit` that, in addition to
manifest file changes, included a list of auxiliary files. This is no
longer the case and all package manifest refactoring actions are now
responsible only for manifest file transformations, the rest is handled
separately.
2025-08-26 13:00:00 -07:00
Alex Hoppen
4040a5e4ac Add default implementations to LanguageService for methods that are not expected to be implemented by all language services
With the introduction of secondary language services, we don’t expect every language service to implement every request anymore. To simplify the addition of language services like `DocumentationLanguageService` add default implementations for methods that satisfy the following criteria:
 - `SourceKitLSPServer` does not expect side effects to happen when they are called
 - The method can throw or there is a reasonable default value
 - It is reasonable to expect that not all language services need to implement it
2025-08-26 16:10:36 +02:00
Pavel Yaskevich
3274349b61 Merge pull request #2251 from xedin/throwing-refactoring-actions
[SwiftLanguageService] Adopt to throwing refactoring actions
2025-08-26 00:06:38 -07:00
Alex Hoppen
aa6301ba96 Merge pull request #2249 from ahoppen/merge-docc
Merge `DocumentationLanguageService` and `DocCDocumentation` modules
2025-08-25 14:39:18 +02:00
Pavel Yaskevich
28ec028ef5 [SwiftLanguageService] Adopt to throwing refactoring actions
`EditRefactoringProvider.textRefactor` and `EditRefactoringProvider.refactor`
requirements are now throwing and produce a non-optional type.
2025-08-22 23:27:39 -07:00
Alex Hoppen
64fe439f24 Make DocumentationLanguageService the only module that imports DocCDocumentation 2025-08-21 10:10:54 +02:00
Alex Hoppen
c1a8301b1f Merge pull request #2233 from aelam/fix/group_of_module_definition
Fix module definition jumping in Swift interface files
2025-08-20 19:05:37 +02:00
Alex Hoppen
1ca9780cd7 Merge pull request #2248 from ahoppen/lang-service-init-not-failable
Make `LanguageService` initializer non-failable
2025-08-20 06:51:27 +02:00
Alex Hoppen
08faa197af Make LanguageService initializer non-failable 2025-08-20 00:21:45 +02:00
Alex Hoppen
22fae21153 Handle documentation requests for Swift files in DocumentationLanguageService
This cleanly separates the responsibilities for handling documentation from those of handling Swift files. It also simplifies providing docc support for clang because we just need to implement the two `symbolGraph` methods in `ClangLanguageService` and can re-use the remaining infrastructure from `DoccLanguageService`.
2025-08-20 00:20:27 +02:00
Wang Lun
a86ed02a11 fixed format issue, path of interface file 2025-08-19 11:49:03 +09:00