Commit Graph

26 Commits

Author SHA1 Message Date
Fredrik Wieczerkowski
eaa8c66b25 Update SKDResponseDictionary subscript to actually return optionals 2021-08-24 16:59:18 +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
7e376e0f8c Reimplement inlay hints using CollectVariableType
Query VariableTypeInfos from sourcekitd and return inlay hints for all
variable declarations without an explicit type annotation.
2021-06-24 18:51:53 +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
9b81cb25d1 Add SKDResponseArray.forEachUID 2021-05-18 13:13:49 +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
Ben Langmuir
6eb17c9a7b Merge pull request #358 from hlopko/glibc_fix2
Import Glibc in SKDResponse
2020-12-16 09:05:57 -08:00
Ben Langmuir
ee7ef54e9d Merge pull request #345 from owenv/edu-notes-take-2
Expose diagnostic educational notes as diagnostic codes
2020-12-16 07:46:29 -08:00
Marcel Hlopko
35d44e6339 import Glibc in SKDResponse 2020-12-16 13:43:38 +01:00
Marcel Hlopko
3f506c5725 Import glibc 2020-12-15 17:24:37 +01:00
Owen Voorhees
77a81ad9c1 Expose diagnostic educational notes as diagnostic codes 2020-11-09 18:30:02 -08:00
David Goldman
79795bf4d9 Decrease verbosity of info-level logging (#331)
- Don't log entire LSP notifications/requests for the `info` level, instead log of the form:
  - `Notification<method>` e.g. Notification<textDocument/publishDiagnostics>
  - `Request<method(id)>` e.g. Request<textDocument/hover(6)>
  - `Response<method(id)` e.g. Response<textDocument/hover(6)>

- Only log sourcekitd requests/responses at the debug level
2020-10-08 18:20:56 -04:00
Ben Langmuir
d82c52c003 [logging] Avoid logging cancellation as warnings/errors
Cancellation shows up as an error code, but it is not a real error, so
don't log it like one.

https://bugs.swift.org/browse/SR-13344
2020-08-04 10:04:21 -07: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
4a86e81984 [sourcekitd] Fix registry assertion 2020-06-08 17:58:25 -07:00
Ben Langmuir
8520c8de10 [cmake] Attempt to update the build files for recent changes
Update for files added/removed and the new sourcekitd target.
2020-06-04 09:48:22 -07:00
Ben Langmuir
f6d7701048 [sourcekitd] Add a registry for sourcekitd instances
Protect ourselves from ever having multiple sourcekitd instances for the
same path live at once, which is not safe.
2020-06-03 14:51:04 -07:00
Ben Langmuir
095ca6c904 [sourcekitd] Switch to TSCBasic's Lock for improved block API 2020-06-03 14:51:04 -07:00
Ben Langmuir
d1a997f3de [sourcekitd] Split sourcekitd into class and protocol
For now, we only have one concrete implementation in sourcekit-lsp
itself, but it is useful for libraries to be able to wrap their own
sourcekitd implementation for example if they have an existing external
use of sourcekitd in C code.
2020-06-03 14:51:04 -07:00
Ben Langmuir
9bb269c1b3 [sourcekitd] Wrap initialization/shutdown and notification handlers
The notification handler and initialize/shutdown APIs all modify global
state within the service, so handle them inside the wrapper to prevent
accidental misuse. Also add support for multiplexing the notification
handler, since it can be useful to have multiple handlers, especially
for global notifications.
2020-06-03 14:51:04 -07:00
Ben Langmuir
f9d26d6bcf [sourcekitd] Move SourceKitD to its own module and lightly refactor 2020-06-03 14:51:03 -07:00