Commit Graph

62 Commits

Author SHA1 Message Date
Ben Langmuir
489da496c4 Merge pull request #453 from ahoppen/pr-5.6/glob-pattern
[5.6] Set didChangedWatchedFiles glob to **/*.ext
2022-01-31 10:00:09 -08:00
Alex Hoppen
070827edca Merge pull request #452 from ahoppen/pr-5.6/semantic-tokens-update
[5.6] Only referesh semantic tokens if SourceKit returned semantic information
2022-01-28 22:04:49 +01:00
Adam Fowler
baa39c54ce Set didChangedWatchedFiles glob to **/*.ext
**.ext will only look in the base folder
2022-01-28 12:08:15 +01:00
Alex Hoppen
0b8a41a5ba Only referesh semantic tokens if SourceKit returned semantic information
In certain race condition scenarios, we might receive a document update to which the 0,0 replacetext request returned only syntactic information. In that case we shouldn’t update the sematnic syntax highlighting tokens.

The race condition rarely surfaced as a test failure of `testSemanticMultiEdit`.
2022-01-28 09:07:53 +01:00
Alex Hoppen
347d550dfe Don't report duplicate folding ranges
I’m not entirely sure when this started occurring but when retrieving folding ranges e.g. for
```
func foo() {
    print("someText")
}
```
We report the folding range of `"someText"` twice: Once as the body of the call to `print` and once as the body of the first argument. Each folding range on its own makes sense because you might want to collapse either all arguments or only a single argument. But it doesn’t make sense to report the same range twice.
2022-01-28 08:37:16 +01:00
Alex Hoppen
ffad5be7ae Only reload SwiftPM package if a file that is relevant to SwiftPM changes 2022-01-24 20:02:42 +01:00
Alex Hoppen
0dcaca5397 Reload Swift Package when new file creation is indicated by DidChangeWatchedFileNotification
Implement rudementary support for `DidChangeWatchedFileNotification` for SwiftPM projects: When a file is added, reload the Swift package to compute build settings for it.

This enables proper semantic functionality added to the project after the LSP server was started.

Resolves SR-15633
2022-01-24 20:02:42 +01:00
Kyle
6d1b09ad5b Remove available check below macOS 10.15.4
Since the Package.swift declare the minimal target for macOS is 10.15.4,
we can remove the uncessary available check code
2021-12-05 17:07:34 +08:00
David Goldman
d29d1254a4 Add support for clangd commands + code actions (#429)
This adds support for clangd commands for clients which support
dynamic registration (including VS Code), as well as fixes an
issue which prevented clangd's code actions from working.

Also added a test to ensure the clangd code actions work, as well as regenerated the Linux test main (which was missing some other newly added tests).
2021-09-29 09:38:49 -04: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
LebJe
a9a840c900 Provide Data Types in Document Outline; Provide Code Documentation in CompletionItem 2021-08-05 19:55:16 -04:00
LebJe
c90813a8f4 Format links in the documentation markdown from SourceKit 2021-07-14 16:18:26 -04:00
LebJe
3fa636b100 Add syntax highlighting to the code blocks in the markdown returned by SourceKit. 2021-07-13 22:18:05 -04:00
Ben Langmuir
13d3d93d8b Merge pull request #413 from DavidGoldman/foldingrange
Use dynamic registration for folding range options
2021-07-01 16:57:13 -07:00
David Goldman
9cda11628b Use dynamic registration for folding range options
Dynamically register because clangd doesn't currently support it, but
may in the future.

Change-Id: I2bf139ea8aad09b58232ba9d09dfddcd89b977cd
2021-07-01 16:35:46 -04:00
Saleem Abdulrasool
8d252b4805 Update CMakeLists.txt
Repair the SourceKit-LSP CMake based build for Windows targets.
2021-07-01 13:22:39 -07:00
Fredrik Wieczerkowski
a6891c3d3d Support ranged CollectVariableType requests 2021-06-24 18:51:53 +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
2e2ae18e32 Add VariableTypeInfo structure 2021-06-24 18:51:53 +02:00
Fredrik Wieczerkowski
29ff751ddc Apply PR suggestions for inlay hints 2021-06-10 20:29:01 +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
Saleem Abdulrasool
5da9995abe SwiftLanguageServer: correct path detection on Windows
Correct the polarity of the check.  The path being a UNC path or having a drive letter indicates that it *is* a path, as opposed to the inverted representation that was accidentally committed.
2021-05-25 10:39:21 -07:00
Saleem Abdulrasool
0096f9742c SourceKitLSP: properly handle paths on Windows
This corrects the path identification to include Windows paths properly.
Although this is not entirely ideal due to the platform specific code,
but avoids crashing the SourceKit LSP server if it encounters a space in
the path.
2021-05-24 11:06:56 -07:00
fwcd
7c88ddd5d9 Compute diagnostic tags from sourcekitd's categories 2021-05-18 13:16:26 +02:00
fwcd
f5f080caec Parse diagnostic tags from message 2021-05-01 04:56:31 +02:00
David Goldman
ad9b09e335 Add support for clangd's semantic highlighting (#388)
- Add LSP types for semantic highlighting
- Limited to clients which support dynamic registration for semantic highlighting
- Requires clangd 11 or later
2021-04-12 16:44:30 -04:00
David Goldman
3635d2531c Dynamically register completion options for supporting clients (#380)
Using dynamic registration (when supported by the client) allows
us to provide different completion options for ObjC and Swift
files.

We should be able to expand this to other capabilities in the future
(e.g. semantic highlighting, execute command support).
2021-04-06 16:33:05 -04:00
Ben Langmuir
7788bff20d Fix lifetime issues in tests
A number of tests were failing with the -Onone lifetime changes.
Regardless of what happens with that change, I'd like to keep our tests
passing with the stricter rules since we also test in release builds.
2021-04-05 15:54:29 -07:00
Saleem Abdulrasool
487c03b681 SourceKitLSP: handle process termination better
This adjusts the process termination to handle termination on Windows,
which does not provide a `kill` operation, which is Unix specific
2021-02-03 09:59:38 -08:00
Alex Hoppen
e5dedd5b7e Re-enable clang crash recovery tests
We now explicitly crash clangd using a SIGKILL instead of relying on it
crashing when we add a crash pragma to the source code.
2021-02-02 21:10:10 +01: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
Alex Hoppen
78e102d93e Split creation of the clangd shim into shim initialization and starting of clangd
This will later allow us to restart clangd while keeping the same shim.
2020-11-30 19:42:37 +01:00
Alex Hoppen
d7f4755297 Rename clang to clangPath 2020-11-30 19:27:41 +01:00
Owen Voorhees
77a81ad9c1 Expose diagnostic educational notes as diagnostic codes 2020-11-09 18:30:02 -08:00
Ben Langmuir
bb9560f2e2 Merge pull request #341 from compnerd/handling
Fix the Pipe handling on Windows to be correct
2020-11-02 11:56:06 -08:00
Saleem Abdulrasool
6a275d134c Fix the Pipe handling on Windows to be correct
This actually addresses the real issue that was ignored earlier about
pipes on Windows.  The FileHandle cannot provide a non-owning file
descriptor (the returned file descriptor would need to be explicitly
`_close`'d by the receiver).  Foundation now vends a `_handle` accessor
to the OS primitive handle.  Use this to create the dispatch loop for
messaging.  We now create the JSONRPCConnection from handles on Windows
which actually should help enable running some of the tests on Windows
as well.
2020-11-02 09:55:58 -08:00
David Goldman
3f55178908 Don't log the sourcekit code complete request
Seems to be left over from development; SOURCEKIT_LOGGING is
an alternative to trace this.
2020-10-22 12:27:37 -04:00
David Goldman
c537c2920e Fix issue where a code-completion session at a specific offset would get stuck failing
- Fix for https://bugs.swift.org/browse/SR-13561 by making sure the
session close waits for the open to finish

- Add a regression test

Change-Id: Iff7217d7b03bc797e036c5329afb0765dcc1874b
2020-10-14 10:50:35 -04: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
Saleem Abdulrasool
67aaa09d70 build: allow building with dispatch and Foundation from the toolchain
This allows building without dispatch and Foundation build roots, which
allows for a multi-phase build.  This is intended to support the Windows
staged build where dispatch and Foundation are part of the SDK and
SourceKit-LSP is part of the devtools.
2020-10-07 19:08:02 -07:00
David Goldman
ae96dcae4e Improve performance of workspace/symbol for large queries + projects (#317)
- Avoid short queries (< 3 characters) since they are slow and noisy. Xcode does the same thing.

- Limit the number of results returned:
  - Improves performance for queries which match many symbols
  - Currently take the first N results to improve performance for large projects
    but once we support cancellation we should take the top N.
2020-09-28 15:13:36 -04:00
Ben Langmuir
70d5c6dea2 Update references to 'master' to 'main' 2020-09-23 11:40:42 -07:00
Saleem Abdulrasool
c55c71d111 build: update CMakeLists.txt
This updates the CMakeLists.txt to allow building SourceKit-LSP with
CMake.
2020-09-06 18:44:34 -07: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
bbb2a34694 [completion] Add doc comment for CodeCompletionSession 2020-07-29 10:29:20 -07:00
Ben Langmuir
bf9053c671 [gardening] Rename CodeCompletionOptions -> SKCompletionOptions
Since it is being used in the LSP protocol layer, give it a name that
clarifies that it is SourceKit-specific.
2020-07-29 10:01:24 -07:00
Ben Langmuir
a5832e978b [gardening] Fix copyright headers and formating in modified files 2020-07-29 09:55:02 -07:00
Ben Langmuir
fe283fa2c2 [completion] Add an extension to pass completion options per-request 2020-07-29 09:42:47 -07:00