Commit Graph

55 Commits

Author SHA1 Message Date
JCWasmx86
e6ef3717ff Decode locale 2023-06-26 20:29:09 +02:00
JCWasmx86
e8c930df1d Decode clientInfo 2023-06-24 18:13:12 +02:00
Max Desiatov
f5a30d9351 Fix uses of deprecated non-throwing AbsolutePath.init (#709)
These warnings appeared after an update to TSC deprecated this initializer.
2023-02-09 14:04:57 +00:00
Alex Hoppen
ca45a7a62b Return a .serverCancelled error code if the server cancels a request
`.cancelled` should only be returned if the client requested cancellation.
2022-12-05 08:45:36 +01:00
Alex Hoppen
975286d353 Update capability definitions to LSP 3.17 2022-12-04 19:56:51 +01:00
Saleem Abdulrasool
ea6ad5f1ff LanguageServerProtocolJSONRPCTests: silence a warning
`Sleep` is a `void` returning function, which makes the blackhole
redundant.  Remove the unnecessary assignment which also silences
the warning associated with it.
2022-08-28 04:35:09 -07:00
Alex Hoppen
df594e332c Set a default timeout duration
Instead of having ad-hoc timeout durations in all the test cases, specify a default timeout duration that can be used by tests.

This allows us increase the timeout duration for all tests if we discover that e.g. sourcekitd is slower in CI setups.

rdar://91615376
2022-06-14 17:26:06 +02:00
Alex Hoppen
20f5387268 Fix a crash on Linux if a ShutdownRequest was sent without params
Workaround for SR-16097 to avoid hitting SR-16095: VSCode will send shutdown requests without a 'params' key. On macOS getting the superDecoder for a non-existent container returns an empty decoder, on Linux it throws `DecodingError.keyNotFound`, causing a crash.

Perform a targeted fix: If we don't have 'params' and the request is a ShutdownRequest, manually create a `ShutdownRequest` without any parameters.

rdar://91288093
2022-04-22 09:47:41 +02:00
Alex Hoppen
c445225721 Delete LinuxMain and XCTestManifests and automatically discover test on Linux
Automatic test discovery is enabled by default since Swift 5.4. I think we can start relying on it.
2022-01-18 12:52:36 +01: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
Ben Langmuir
cf69c3f76c [test] Stop matching error description text that is not from our code
The underlying JSON parsing error is from Foundation, so we don't want
to try to compare that in our tests. As a quick fix, just compare a
prefix of the string that we control.
2021-03-02 14:00:13 -08:00
Saleem Abdulrasool
cc702e2d16 LanguageServerProtocolJSONRPCTests: add Windows stubs
This set of changes is the last set of changes required to build the
entire test suite on Windows.  Although the tests do not yet fully pass,
this is a prerequisite for getting the test suite passing.
2020-11-16 09:07:30 -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
Joe Heck
c58d6939cc convert tests from #file to using #filePath 2020-10-31 18:29:08 -07:00
Sebastian Fichtner
7a36a51014 Synchronously send error response on message decoding failure (#334)
* Replaces two logs since those don't result in response messages anymore
* Adds a func for sending messages synchronously, to get the two messages out before fatalError
2020-10-16 16:29:46 -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
David Goldman
8b57352f3b Send didSave notifications to clangd if it supports it (#280)
* Send `didSave` notifications to clangd if it supports it

- Minor update to the LSP protocol for `didSave` and `colorProvider` to be more in line with the spec
- Only send color requests over to clangd if it supports it

Rationale for this change: clangd recently implemented didSave support,
it is used to rebuild preambles when the user edits a header file
referenced by an open file.

Change-Id: Ie6e2198bdeccb9d1b4083806c254475baadc2d2b
2020-06-03 14:20:38 -07:00
Ben Langmuir
6445a69029 [test] Fix double close in testCloseRace
Close the fd via the FileHandle rather than directly on the file
descriptor so that it does not get closed again when the pipe is
released. Fixes running test in parallel on Linux.
2020-04-08 11:55:21 -07:00
Ben Langmuir
8b9f019d94 Fix a build warning in ConnectionTests.swift 2020-04-01 10:45:34 -07:00
Ben Langmuir
fae2fe85a7 [JSONRPC] Do not exit until outstanding I/O has finished
Specifically, we care that all outstanding **writes** are finished
before we call the close handler, because otherwise we may (a) send
corrupted output during shutdown, or (b) drop notifications and replies
sent during the shutdown process.  The former is a potential issue for
clients that are not robust about parse failures, and the latter is an
issue for reproducibility and robustness during testing/debugging - in
particular, we have some integration tests that send data without
waiting for individual replies and they need to finish outstanding
replies before exiting.

rdar://60159448
2020-03-10 11:16:34 -07:00
Alex Hoppen
e2d7eedef8 Unify the naming of request and notification types
Request types should always have the suffix Request and notifications
should end with Notification.

Also moved all request and notification types into separate folders to
reduce the number of files in the LanguageServerProtocol folder.
2019-12-13 13:56:10 -08:00
Alex Hoppen
c3e70b5933 Update ServerCapabilities to match version 3.14 of the LSP spec 2019-12-12 17:17:35 -08:00
Alex Hoppen
f167126c8d Fix typo: JSONRPCConnection should be spelled with two 'n' 2019-11-29 10:20:02 -08:00
Ben Langmuir
dfe2a6bc76 [jsonrpc] Move close handler to start
Since the connection and message handler have a reciprocal need to know
about each other, move the closeHandler so that it has the opportunity
to call a method on the message handler if desired.
2019-11-21 11:56:37 -08:00
Alex Hoppen
5c839f8640 Add support for non-URL URIs
According to the LSP specification, arbitrary URIs can be used as
document identifiers. Instead of internally assuming that all URIs are
URLs, use a DocumentURI enum to represent URIs. These can either be file
URLs or other URIs whose value as treated as an opaque string.
2019-11-20 09:41:48 -08:00
Ben Langmuir
10ae122f17 Sink Int extension to JSONRPC
This is the only user of this code, and it's not particularly great.
Sink it to reduce dependency surface area.
2019-11-19 10:52:23 -08:00
Ben Langmuir
f83a9f4476 Sink Result to SKSupport
It's not being used for anything interesting in LSP layers, so sink it
to minimize dependencies.
2019-11-19 10:31:15 -08:00
Ben Langmuir
ec3fd7f940 Sink firstIndex to its only user in JSONRPC
This isn't a particularly good implementation and it only has one user.
Move it down to reduce dependency surface area.
2019-11-19 10:19:09 -08:00
Alex Hoppen
05ecd26d08 Reorganize the repository into a set of bare LSP modules and SourceKit modules
We will be able to split the LSP modules off later. These LSP modules
will provide the ability to write custom LSP servers and clients in
Swift. The sourcekit-lsp repository will build on top of this new
package to provide an LSP implementation that creates a language server
for Swift and C-based-languages.
2019-11-14 10:35:06 -08:00
Ben Langmuir
6e4060732d [tsan] Fix race in testMessageBuffer
We don't need to check the message buffer in the middle of the test; it
suffices that we got the expectation fulfilled at the right times. The
check at the end of the test can be done by synchronizing via close()
before reading.
2019-10-04 16:15:31 -07:00
Ben Langmuir
a964dad129 [tsan] Fix race in a few JSONRPCConnectionTests
These tests don't really need to check the message buffer anyway, it was
mostly a sanity check. There is still a race in testMessageBuffer, which
actually has a reason to look at the buffer and will need to be handled
separately.
2019-10-04 16:11:20 -07:00
Ben Langmuir
38dc0097cf Merge pull request #162 from rmaz/buildtargets
Add workspace/buildTargets request
2019-10-04 14:19:04 -07:00
Ben Langmuir
81e46c7c46 [test] Flip the default value of allowUnexpectedNotification
This is/was mostly useful for testing specific notification
interactions. Most new tests shouldn't need it, so remove the
boilerplate.
2019-10-01 22:30:58 -07:00
Richard Howell
81c50db7e1 add the workspace/buildTargets request 2019-09-25 14:16:30 -07:00
Ben Langmuir
a91f5852a0 [test] Regenerate linuxmain 2019-08-23 14:07:37 -07:00
Ben Langmuir
a5d5d09695 [jsonrpc] Fix race between close() and EOF
We implicitly close the connection when the input file descriptor is
closed, or if it has an error. But we also close things down explicitly
when we see the exit notification. We need to protect against a race
triggering us to call the close handler multiple times. This was
resulting in `sourcekit-lsp` racing to call `exit(0)`, which triggered a
double-free and abort on Linux.
2019-08-23 14:03:47 -07:00
Richard Howell
93982b2f2a messageRegistry -> protocol 2019-08-16 19:18:29 -07:00
Richard Howell
481284be31 fix tests 2019-08-15 15:28:21 -07:00
Ben Langmuir
65b98b383c Remove testable imports of LanguageServerProtocolJSONRPC 2019-08-08 22:22:50 -07:00
Ben Langmuir
ddd096f019 Rename JSONRPCMessageHeader and methods in preparation for making public 2019-08-08 22:14:57 -07:00
Ben Langmuir
119b3fa1cb Rename Message -> JSONRPCMessage in preparation for making it public 2019-08-08 22:06:07 -07:00
cukr
719bed2be0 Response to code review 2019-08-08 23:00:03 +02:00
cukr
7b6197394f Merge remote-tracking branch 'upstream/master' into implementation
# Conflicts:
#	Sources/LanguageServerProtocol/ServerCapabilities.swift
#	Sources/SourceKit/SourceKitServer.swift
#	Tests/LanguageServerProtocolJSONRPCTests/CodingTests.swift
2019-08-07 10:48:30 +02:00
cukr
7667608eef Implement "textDocument/implementation" request 2019-07-24 14:42:10 +02:00
Benjamin Kindle
223d11df92 Add workspace/symbols support
https://bugs.swift.org/browse/SR-10806
2019-07-20 08:36:32 -04:00
Bruno Rocha
5406e861b0 Add codeActions API 2019-06-19 21:57:58 -03:00
Marcin Krzyzanowski
fb2d4d14b8 Embrace Swift.Result in place SwiftPM.Basic.Result 2019-06-10 11:24:53 +02:00
Ben Langmuir
e47c7db081 [test] Disable performance metrics unless ENABLE_PERF_TESTS is defined
When running in debug, or in continuous integration that is not setup
for performance testing, default to not collecting performance metrics
to avoid failures due to slow or high-variability tests (default
max_stddev = 10% in xctest). Instead, run the measured block once and
skip the timing code. This has the nice side effect of speeding up test
runs in debug builds.
2019-01-23 16:25:50 -08:00
Ben Langmuir
af05e94bb0 [test] Update generated files with new toolchain 2019-01-23 11:17:16 -08:00