Commit Graph

12 Commits

Author SHA1 Message Date
Alex Hoppen
16aa082afe Fix a race condition in code completion
Each `sourcekitd` uses a single, global code completion session but we were managing code completion sessions on the `SwiftLanguageServer` level. This had two issues:
- Code completion is considered non-blocking on `SourceKitServer` and thus we could execute two concurrent code completion requests, which would conflict with each other.
- You could have multiple `SwiftLanguageServer`s that each have a connection to `sourcekitd` but share the same `sourcekitd` state. This shouldn't happen in the real world but does happen if we create multiple `SourceKitServer` instances in tests.
2023-10-16 09:59:27 -07:00
Alex Hoppen
68a90aac8b Change CodeCompletionSession to not have a circular reference to SourceKitServer
This just clean up the layering slightly.
2023-10-16 09:57:19 -07:00
Alex Hoppen
d9055b798d Remove client-side filtering for code completion
`SKCompletionOptions.serverSideFiltering` is `true` by default and I know of no editor that disables it. Delete it.

Fixes #863
rdar://116703670
2023-10-16 09:55:22 -07:00
Alex Hoppen
f960d7ed9b Change logging to use OSLog
OSLog is the suggesting logging solution on Apple platforms and we should be using it there, taking advantage of the different log levels and privacy masking.

Switch sourcekit-lsp to use OSLog on Apple platforms and implement a logger that is API-compatible with OSLog for all uses in sourcekit-lsp and which can be used on non-Darwin platforms.

The goal of this commit is to introduce the new logging API. There are still improvements about what we log and we can display more privacy-insensitive information after masking. Those changes will be in follow-up commits.
2023-10-13 13:46:32 -07:00
Alex Hoppen
c4ff9d0592 Fix race conditions in code completion 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
556a58a05e Make DocumentSnapshot not have a reference to its originating Document
The reference just isn’t needed and this makes everything clearer.
2023-10-06 07:26:27 -07:00
Alex Hoppen
19e22c57fa Asyncify codeCompletion 2023-10-05 13:30:41 -07: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
Saleem Abdulrasool
586218448a SourceKitLSP: change an assert to a check
Rather than asserting, raise an error for the user and abort the
operation.  This is motivated by the desire to get the test suite mostly
working on Windows so that the underlying issues can be worked through
more easily.
2022-07-12 12:47:59 -07: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
Ben Langmuir
bbb2a34694 [completion] Add doc comment for CodeCompletionSession 2020-07-29 10:29:20 -07:00