Commit Graph

26 Commits

Author SHA1 Message Date
Alex Hoppen
6679652cde Remove awaitTask
It turns out that `XCTestCase.setUp` can indeed be `async` and we thus don’t actually need `awaitTask`
2023-10-12 08:30:07 -07:00
Alex Hoppen
0e85e544a2 Remove unused functions from TestClient 2023-10-12 08:28:06 -07:00
Alex Hoppen
efd55c2208 Simplify TestSourceKitServer
- Remove the JSONRPC connection kind between `TestSourceKitServer` and `SourceKitServer`
  - It wasn’t actually used and the connection abstraction just made things more complicated than they needed to be
- Send requests and notifications to `SourceKitServer` by directly calling into `SourceKitServer.handle` instead of going through a `Connection`. This makes the code a lot easier to understand statically
- Make `TestSourceKitServer` conform to `MessageHandler` instead of going through `TestClient`
  - IMO this centralizes all the handling and makes it a lot easier to follow. `TestClient` didn’t do a whole bunch anyway.
- Allow async awaiting of next notifications instead of having to register a `handleNextNotification` handler before expecting the notification to be emitted.
  - This allows us to remove quite a few `XCTExpectation`s in test cases
- Change `sendSync` function that sends a request and returns the result to be `async`
2023-10-12 08:28:06 -07:00
Alex Hoppen
d0fc00ce98 Format using swift-format
Add `.swift-format` to the repo and format the repo with `swift-format`.

This commit does not add any automation to enforce formatting of sourcekit-lsp in CI. The goal of this commit is to get the majority of source changes out of the way so that the diff of actually enforcing formatting will have fewer changes or conflicts.
2023-10-10 13:44:47 -07:00
Alex Hoppen
4495256b35 Remove the queue parameter from Connection.send
We don’t actually care about the queue that we receive the reply on anymore since we migrated everything™ to actors/async/await.
2023-10-06 18:07:20 -07:00
Alex Hoppen
8eed2e24dc Migrate SwiftPMWorkspace to be an actor 2023-10-02 09:47:25 -07:00
Alex Hoppen
b36352b892 Make sourcekit-lsp compatible with SDKs < macOS 13.3 2023-10-02 09:43:45 -07:00
Alex Hoppen
09dc0bc82f Make SourceKitServer an actor
Unfortuantely, we have a few potential out-of-order exeuction possibilities while we migrate everything else to also be asyncronous. But those should be low-probability issues that we can fix in follow-up commits, so I think it’s fine for now. All of these places are marked with `FIXME: (async)`
2023-10-02 09:43:42 -07:00
Alex Hoppen
b22af35eb1 Revert asyncificaiton changes
The asyncification changes caused some non-deterministic test failures. I believe that some of these are due to race conditions that are the result of the partial transition to actors.

Instead of merging the asyncification piece by piece, I will collect the changes asyncification changes in a branch and then qualify that branch througougly (running CI multiple times) before merging it into `main`.
2023-09-30 10:09:59 -07:00
Alex Hoppen
fccbc3973c Migrate SwiftPMWorkspace to be an actor 2023-09-29 16:55:51 -07:00
Alex Hoppen
4263313b20 Make sourcekit-lsp compatible with SDKs < macOS 13.3 2023-09-27 09:48:21 -07:00
Alex Hoppen
351eaa2393 Make SourceKitServer an actor
Unfortuantely, we have a few potential out-of-order exeuction possibilities while we migrate everything else to also be asyncronous. But those should be low-probability issues that we can fix in follow-up commits, so I think it’s fine for now. All of these places are marked with `FIXME: (async)`
2023-09-27 09:48:21 -07:00
Alex Hoppen
bdda582714 Reduce usgaes of try! in tests
The usage of `try!` was still a relict of when `XCTest` didn’t allow throwing test method.
2023-09-18 19:16:49 -07:00
Ben Barham
e540e169bc Revert "Show a progress indicator in the editor if SourceKit-LSP is reloading packages" 2023-07-17 21:56:35 -07:00
Alex Hoppen
24317f1e97 Show a progress indicator in the editor if SourceKit-LSP is reloading packages
I noticed that the initial package loading can take ~5s. It’s good behavior to inform the client that sourcekit-lsp is busy reloading the package, showing the user that semantic functionality might not be ready yet.

https://github.com/apple/sourcekit-lsp/issues/620
rdar://111917300
2023-07-17 11:08:20 -07:00
Alex Hoppen
5af65fb184 Increase default timeout to 60 seconds
The reduced timeout of 15 seconds was causing issues in CI.
2022-07-21 20:20:37 +02:00
Saleem Abdulrasool
d1b1b48908 SourceKitLSPTests: replace some fatalError with XCTFail
This replaces many instances of `fatalError` with `XCTFail`.  Although
these code paths should not come to pass, there are currently failures
in the test suite on Windows where these trigger.  By using `XCTFail`
instead, we allow the tests to continue execution which is helpful for
investigating the current state and make progress towards fixing the
issues.
2022-07-17 17:30:18 -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
2e76be7c96 Remove placeholders from code actions instead of replacinng them by snippets
#481 replaced SourceKit placeholders (like `<#code#>`) by LSP snippets for code actions, which are used to represent SourceKit refactoring and diagnostic Fix-Its. But LSP snippets are only supported for code completion, not for code actions. This results in LSP snippets like ${1:code} being inserted into the editor.

Instead of replacing SourceKit placeholders by LSP placeholders, we should just remove them altogether from the code action response.

rdar://92447079 [#488]
2022-04-28 10:59:33 +02: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
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
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
Alex Hoppen
f167126c8d Fix typo: JSONRPCConnection should be spelled with two 'n' 2019-11-29 10:20:02 -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