Commit Graph

38 Commits

Author SHA1 Message Date
Saleem Abdulrasool
f670c42364 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 12:42:59 -07:00
Saleem Abdulrasool
dbf0267d4f 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 13:20:51 -07: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
Ben Langmuir
232fb7bfe0 [completion] Fix tests when using server-side filtering
With this change, tests pass whether we default to server-side or
client-side filtering. Also duplicate a few interesting tests to run
both ways. A future commit will beef up the test coverage for
server-side filtering specifically.
2020-07-29 09:42:47 -07:00
Ben Langmuir
024ebdd9b7 [completion] Set default maxResults = 200 2020-07-29 09:42:47 -07:00
Ben Langmuir
c9800bf1a1 [completion] Add initial server-side filtering implementation
Work in progress: add a basic implementation for keeping track of the
current completion session, and use the sourcekitd
complete.open/update/close requests.
2020-07-29 09:42:18 -07:00
Ben Langmuir
c719711afd [gardening] Split code-completion into its own file
Similar to cursor info, there is enough code here it makes sense to
separate it out.
2020-07-29 09:42:18 -07:00
Ben Langmuir
c27a76c9c5 [completion] Pass through new code-completion options 2020-07-29 09:42:18 -07:00
David Goldman
2840c7dac9 Forward definition requests when index lookup fails (#294)
* Forward definition requests when index lookup fails

If we're unable to look up a definition or declaration via the
index, forward the request to the language service.

This allows clangd to support go to definition or declaration
for symbols defined/declared in the AST.
2020-07-09 15:41:08 -04:00
David Goldman
5977d611aa Withhold diagnostics when fallback arguments are being used (#281)
While fallback arguments are being used (either from the fallback build system or fallback settings from the primary build system), withhold semantic diagnostics from sourcekitd and all diagnostics from clangd. This helps prevent user confusion from spurious errors.

- Also remove the DocumentURI standardization in favor of proper equality + hash checks to work around the %40 --> @ encoding issue seen on CI.
2020-06-11 11:38:50 -04:00
Ben Langmuir
1040621ae1 Shutdown toolchain connections on exit
When using SourceKit-LSP in tests (or otherwise in a library), we do not
want to leak the toolchain connections.
2020-06-09 13:20:15 -07:00
Ben Langmuir
5449a2acb7 [jsonrpc] Workaround file descriptor lifetime issue
We should solve this in the JSONRPCConnection itself, but in the
meantime workaround by keeping pipes alive until the connection has
closed.
2020-06-09 13:20:15 -07:00
Ben Langmuir
40525486b7 Fix target name after rebase 2020-06-08 09:13:04 -07:00
Saleem Abdulrasool
f3f0795cdc build: repair build on Windows
This enables building SourceKit-LSP on Windows.  This is sufficient to
repair the build, though it is insufficient to run currently.
2020-06-05 08:28:26 -07:00
Ben Langmuir
4ff14d278d Rename module SourceKit -> SourceKitLSP
Clarify its role, since it is not really an LSP-independent interface
right now.
2020-06-04 14:49:00 -07:00