Commit Graph

44 Commits

Author SHA1 Message Date
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
Bruno Rocha
3f58e09dcf Add folding range requests
Add remaining foldingRange protocol capabilities

Sending offset data to folding requests

FoldingRange test

Support folding comments

Add test for folded comments
2018-12-08 16:07:54 -02:00
josh
22a49414e8 Fix merge conflicts (Toolchain, SwiftPMWorkspace, SwiftLanguageServer) 2018-12-07 13:39:43 +09:00
Joshua Kaplan
06144c9901 Mark unused completion handler properties as _ 2018-12-07 13:29:16 +09:00
Ben Langmuir
13095fab99 [test] Remove defunct static var allTests everywhere
When we started managing the Linux test lists with the
`--generate-linuxmain` option to swiftpm, these all became dead code.
2018-12-06 09:58:35 -08:00
Ben Langmuir
aabf57a252 Import SourceKit-LSP sources 2018-11-13 15:50:48 -08:00