40 Commits

Author SHA1 Message Date
Alex Hoppen
ca1da1af53 Re-generate sourcekitd UIDs
Also fix a bug that caused swift-format-ignore comments to get dropped when re-generating.
2026-01-12 14:36:32 +01: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
Alex Hoppen
6074529dac Manually fix swift-format lint rules
- I think there are valid calls with mixing inline and trailing closures (notably `Debouncer`), so I’m considering whether we should disable that rule.
- The `forEach` rule is a little annoying because we have `forEach` on `SKDResponseArray`. But it caught two cases of using `forEach` on arrays, so I think it’s worth keeping.
2025-08-11 09:31:09 +02:00
Alex Hoppen
34f977219b Merge pull request #2041 from ahoppen/license-headers
Consistently add license headers to all files
2025-03-07 13:26:18 -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
cf828a8135 Consistently add license headers to all files
To prepare for the GitHub Action license header check.
2025-03-06 22:01:00 -08:00
Alex Hoppen
5709e1a864 Add a SourceKit plugin to handle code completion requests
This adds a sourcekitd plugin that drives the code completion requests. It also includes a `CompletionScoring` module that’s used to rank code completion results based on their contextual match, allowing us to show more relevant code completion results at the top.
2025-01-03 14:21:54 +01:00
Alex Hoppen
8cd831b55d Adopt InternalImportsByDefault 2024-09-27 09:17:13 -07:00
Alex Hoppen
2877675bd5 Adopt package access level
Change a l public declarations to the `package` access level, accept for:
- The `LanguageServerProtocol` module
- The `BuildServerProtocol` module
- `InProcessClient.InProcessSourceKitLSPClient`
- `LanguageServerProtocolJSONRPC` (I would like to create a more ergonomic API for this like `InProcessSourceKitLSPClient` in the future, but for now, we’ll leave it public)

Unfortunately, our pattern of marking functions as `@_spi(Testing) public` no longer works with the `package` access level because declarations at the `package` access level cannot be marked as SPI. I have decided to just mark these functions as `package`. Alternatives would be:
- Add an underscore to these functions, like we did for functions exposed for testing before the introduction of `SPI`
- Use `@testable` import in the test targets and mark the methods as `internal`

Resolves #1315
rdar://128295618
2024-07-19 09:54:30 -07:00
Alex Hoppen
76da45444f Re-generate sourcekitd UIDs 2024-05-23 13:41:40 -07:00
Alex Hoppen
a6b8cbecad Emit raw documentation comments instead of parsing XML
Fixes #1014
rdar://120685874
2024-02-26 19:55:23 -08:00
Alex Hoppen
f5fb23ad4c Rename sourcekitd_ to sourcekitd_api_ and add nullability annotations to sourcekit_functions.h
Naming types in sourcekitd_functions.h `sourcekit_api_` instead of `sourcekitd_` indicates that these are types to be used with dynamically loaded sourcekitd libraries. It avoids confusion if sourcekitd is also linked, which adds the `sourcekitd_` symbols.

Adding nullability annotations to it is also just nice.

And some improved formatting never hurts.
2024-02-23 09:13:42 -08:00
Alex Hoppen
b5fd79fbb9 Generate sourcekitd UIDs instead of manually maintaining the list
rdar://121953119
2024-02-14 16:33:34 -08:00
Alex Hoppen
d73f44c447 Support cross-language rename between Swift and clang languages
This adds support for name translation between Swift anc clang languages to allow renaming across those language boundaries.

Rename is always initiated at the symbol’s definition, so when renaming an Objective-C symbol from Swift, the user is prompeted to enter the new Objective-C method name.

rdar://118996461
2024-01-31 10:51:03 -08:00
Alex Hoppen
7572fb96ee Report secondary cursor info results
rdar://119163908
2024-01-10 21:05:31 -08:00
Alex Hoppen
777f1dc463 Add support for rename within the current file
rdar://117822427
2023-12-09 08:35:13 -08:00
Alex Hoppen
8857a08940 Parse information from related identiers that is needed to perform local rename 2023-12-09 08:34:41 -08:00
Alex Hoppen
84fdea9e05 Filter overrides in DefinitionRequest by receiver types 2023-11-29 09:03:36 -08:00
Alex Hoppen
4052465905 Show overriden functions when performing jump-to-definition on a dynamic call
Fixes #809
rdar://114864256
2023-11-29 09:02:02 -08:00
Alex Hoppen
2aedb85a1f Don't cancel cursor info and related identifiers requests on subsequent requests
SourceKit-LSP supports explicit cancellation and thus we don’t need to do the implicit cancellation of cursor info and related identifiers on subsequent requests.
2023-11-21 17:45:10 -08:00
Alex Hoppen
ac3eb32e65 Format sources with swift-format 2023-10-31 19:30:31 -07:00
Alex Hoppen
ffbf025896 Open and edit documents in syntactic-only mode in sourcekitd
With this change, opening and editing a document no longer causes a non-cancellable AST build. Instead, all semantic information is retrieved via requests that can be cancelled (after we implement cancellation).
2023-10-20 09:38:35 -07:00
Alex Hoppen
080e664363 Load semantic tokens from a document using a sourcekitd request instead of the 0,0 edit
This allows us to cancel the semantic tokens request. It is also the last step to allow us to open and edit documents in syntactic-only mode.

It also means that we no longer need to send a `WorkspaceSemanticTokensRefreshRequest` to the client after sourcekitd has updated its semantic tokens since with the new design the `DocumentSemanticTokensRangeRequest` will simply return the results once it has the updated semantic token.
2023-10-19 17:46:58 -07:00
Alex Hoppen
7c15ba8731 Highlight references to actors like references to classes
We weren’t semantically highlighting references to actors because we missed the `ref_actor` case from the sourcekitd `annotations` response.

Fixes #694
rdar://104573568
2023-06-27 20:57:04 +02:00
Tristan Labelle
542a29db2b Implement pull-model documentDiagnostics 2023-05-26 10:35:26 -04:00
Adam Fowler
0da1d40a28 Move module name split into OpenInterfaceRequest
Use group names when running open interface request
2023-05-21 10:26:00 +01:00
Adam Fowler
45adabb3e5 Extend OpenInterface to also seatch for a symbol 2023-05-16 19:32:29 +01:00
Bart Whiteley
d2f7f2f3c6 Generate textual Swift interfaces for module references 2022-12-12 12:45:21 -07:00
Alex Hoppen
0d83557f87 Provide semantic highlighting for operators in declarations
Adopts https://github.com/apple/swift/pull/60210

Resolves #595
rdar://97961816
2022-08-12 14:21:57 +02:00
Fredrik Wieczerkowski
17f656865d Implement lexical and semantic highlighting for Swift
This is an implementation of LSP's semantic tokens for Swift. Both
lexical and semantic tokens are provided by using the syntaxmap and the
semantic annotations provided as part of SourceKit's open responses and
document update notifications.

While lexical tokens are parsed and stored in the DocumentManager
synchronously, semantic tokens are provided asynchronously. If an edit
occurs, tokens are automatically shifted by the DocumentManager. This is
especially relevant for lexical tokens, which are updated in deltas.

In addition, unit tests are added that assert that both lexical and
semantic tokens are provided and shifted correctly upon edits.
2021-08-24 16:49:52 +02:00
Fredrik Wieczerkowski
134073deba Implement sourcekitd to VariableTypeInfo deserialization 2021-06-24 18:51:53 +02:00
Fredrik Wieczerkowski
5eaee0f235 Add UIDs for sourcekitd's new CollectVariableType request 2021-06-24 18:51:53 +02:00
Fredrik Wieczerkowski
3fef5145ea Add support for inlay hints using CollectExpressionType
- Add UID for CollectExpressionType request
- Add ExpressionTypeInfo structure
- Add keys to support sourcekitd's CollectExpressionType
- Implement CollectExpressionType request
- Add SwiftLanguageServer.expressionTypeInfos
- Add InlayHint and supporting types
- Add InlayHintsRequest
- Add inlayHints handler stub
- Implement inlay hints request
- Update InlayHint to follow the current proposal
- # This is the commit message #11:
- ...as described in the LSP proposal
- Update doc comment on InlayHintsRequest
- Map inlay hints lazily
- Fix minor style issue
- Add new files to CMakeLists.txt
- Specify commit of the current inlay hints proposal state
- Add public, memberwise initializer for InlayHintsRequest
- assert(false) if deserializing ExpressionTypeInfos fails
- Add dispatch precondition to _expressionTypeInfos
- Add InlayHintsRequest to the builtinRequests
- Factor out function for querying document symbols for URI
- Only render inlay hints after variable bindings
- Test inlay hints on empty document
- Test inlay hints for some simple bindings
- Test ranged inlay hint requests
- Make sure that inlay hints are unique per position
- Test inlay hints for fields
- Apply various PR suggestions regarding inlay hints
- Update inlay hint tests and add case with explicit type annotations
- Continue iterating if an ExpressionTypeInfo fails to deserialize
2021-06-10 16:41:54 +02:00
fwcd
d49b833bb6 Add new sourcekitd diagnostic uids 2021-05-18 13:04:42 +02:00
Ben Langmuir
d9b2d65d03 Merge pull request #353 from ahoppen/crash-recovery-again
Restart sourcekitd and clangd after they have crashed
2021-01-19 09:28:29 -08:00
Alex Hoppen
a0c9b30a2a Restart sourcekitd and clangd after they have crashed 2021-01-18 13:30:35 +01:00
Owen Voorhees
77a81ad9c1 Expose diagnostic educational notes as diagnostic codes 2020-11-09 18:30:02 -08:00
Ben Langmuir
b7ca21f433 [completion] Add server-side filtering UIDs 2020-07-29 09:42:18 -07:00
Ben Langmuir
8bb7086630 [gardening] Sort and organize sourcekitd keys
* The interesting keys to split out are "code-completion options", not
  any key that is used by completion.
* Sort the main key list
* Fix the name of the doc_brief key
2020-07-29 09:42:18 -07:00
Ben Langmuir
f9d26d6bcf [sourcekitd] Move SourceKitD to its own module and lightly refactor 2020-06-03 14:51:03 -07:00