Commit Graph

132 Commits

Author SHA1 Message Date
Alex Hoppen
c3e70b5933 Update ServerCapabilities to match version 3.14 of the LSP spec 2019-12-12 17:17:35 -08:00
Ben Langmuir
156139f0e4 Merge pull request #202 from ahoppen/match-spec
Update the struct definitions to match version 3.14 of the LSP spec
2019-12-06 15:19:17 -08:00
Ben Langmuir
b38e2414d2 Merge pull request #197 from ahoppen/code-completion-new-fields
Add textEdit to code completion responses
2019-12-06 13:06:18 -08:00
Alex Hoppen
2422ddc8cd Add the textEdit parameter to code completion responses 2019-12-06 10:51:13 -08:00
Alex Hoppen
82be88f696 Update ReferencesRequest to match version 3.14 of the LSP spec 2019-12-06 08:31:44 -08:00
Alex Hoppen
7ebf103645 Update ImplementationRequest to match version 3.14 of the LSP spec 2019-12-06 08:31:44 -08:00
Alex Hoppen
bcadf01539 Update DocumentSymbolRequest to match version 3.14 of the LSP spec 2019-12-06 08:31:19 -08:00
Alex Hoppen
711d7827dd Update DefinitionRequest to match version 3.14 of the spec 2019-12-06 08:31:19 -08:00
Alex Hoppen
fa012d7386 Update CompletionItem to match version 3.14 of the spec 2019-12-06 08:31:19 -08:00
Ben Langmuir
0459ee5a5e Merge pull request #201 from ahoppen/hover-marked-string
Support MarkedStrings in Hover responses
2019-12-03 16:14:42 -08:00
Alex Hoppen
03dde148a9 Support MarkedStrings in Hover responses 2019-12-03 15:07:17 -08:00
Alex Hoppen
f167126c8d Fix typo: JSONRPCConnection should be spelled with two 'n' 2019-11-29 10:20:02 -08:00
Ben Langmuir
d78d6fb405 Fix deadlock in exit -> onExit -> close -> closeHandler -> sync 2019-11-21 11:56:38 -08:00
Ben Langmuir
ac630e4617 Be more resilient about trying to flush the index on shutdown
Not all editors send shutdown/exit messages, particularly when you quit
the application (as opposed to a single editor window), so we sprinkle
`prepareForShutdown()` into the connection closed handler as well. I
verified manually in such an editor that this lets us save the index on
quit.
2019-11-21 11:56:38 -08:00
Ben Langmuir
6c66f8021c [index] Attempt to save index on shutdown
If the client is well-behaved and sends a shutdown request, we close the
index in order to flush it to disk. This should speed up reopening the
same project when it is already indexed.
2019-11-21 11:56:37 -08:00
Alex Hoppen
558d7fc664 Change backing storage of DocumentURI to URL
URL can in fact store URIs, it just doesn't have a very nice API to
interact with them. As long as we only operate on absoluteString, we
should be fine though. So instead of implementing the logic for
detecting file URLs ourselves, we can just use a URL as storage for
DocumentURI.
2019-11-20 09:41:48 -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
775e198f77 Rename LSPSupport -> LSPLogging to reflect reduced scope
Ideally we can someday migrate this to something more standard such as
swift-log, and make it explicit how to control logging for the JSONRPC
module.
2019-11-19 11:08:31 -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
Richard Howell
c56bcee9d7 disable clangd indexing 2019-11-12 16:11:36 -08:00
Richard Howell
1d7858e023 call delegate on build targets change 2019-10-21 10:39:22 -07:00
David Goldman
45b103d1c7 Swap to use queue.async for all SwiftLanguageServer methods
Change-Id: I505ed9a8561e81f22635a6e852b22654a737ad61
2019-10-09 16:31:11 -04:00
David Goldman
043d27860d Remove the need to use Connection to talk to internal LSPs
`SourceKitServer` now talks to the `SwiftLanguageServer` and
`ClangLanguageServerShim` directly through the `ToolchainLanguageServer`
protocol.

Each individual `ToolchainLanguageServer` manages its own threading.

Change-Id: I77aa5468f1486bd4e6e6fdb732c6a051ee05c6d1
2019-10-09 13:49:11 -04:00
Ben Langmuir
08a85356e1 [refactoring] Disable "local rename"
This needs similar support to global rename before it actually works.
Disable for now.
2019-10-08 16:10:08 -07:00
Bruno Rocha
9eb2fe4453 Clean implementation 2019-10-04 12:34:09 -03:00
Bruno Rocha
a84eaaa478 Apply review comments (LSPAnyCodable/Cleaning) 2019-10-03 11:37:24 -03:00
Bruno Rocha
8861ac06c1 Add Local Refactoring 2019-10-03 11:20:41 -03:00
Ben Langmuir
56b1f0ba99 [diagnostics] Clear cached diagnostics on close
While we ideally could maintain diagnostics state for closed documents
as the LSP specification encourages, since we have no way to do that
today, it's better to throw out diagnostics for closed documents so that
they do not sit around stale. We do not send a publishDiagnostics
though, so the editor can maintain the list of diagnostics if desired,
but when we reopen the document we can provide completely fresh data.
2019-10-02 16:10:21 -07:00
Ben Langmuir
70af0734cb [diagnostics] Fix caching of diagnostics across files
We were sending back (and clearing) all cached diagnostics, not just the
ones for the current file.
2019-10-02 16:10:20 -07:00
Ben Langmuir
2c460cb2d5 Move custom PositionRange encoding into a property wrapper
This lets us use the `Range<Position>` without manually converting back
and forth in the majority of cases. See the note on HoverResponse for
the behaviour with Optional that makes us have to provide a custom
Codable implementation in two places that used to be synthesized.
2019-10-02 14:38:40 -07:00
Ben Langmuir
71a94b0717 Add -Xclangd to allow forwarding options to clangd command-line
And factor the configuration that we thread through to the sourcekit
server.
2019-09-30 14:29:18 -07:00
Bruno Rocha
20c026c8e2 Cleaning Code 2019-09-24 17:59:38 -03:00
Bruno Rocha
c20fe44c42 Convert CommandArgumentType -> LSPAny references 2019-09-24 17:21:32 -03:00
Bruno Rocha
7180d66e60 Avoid using decoders for retrieving dictionary data 2019-09-24 17:21:32 -03:00
Bruno Rocha
e71965fc7d Inject metadata at commands 2019-09-24 17:21:32 -03:00
Bruno Rocha
cef91670f5 Add ExecuteCommand/ApplyEdit 2019-09-24 17:21:32 -03:00
Ben Langmuir
89b95f5043 [index] Fix default value for listening to unit changes
Was preventing index from being populated by default.
2019-09-11 08:49:01 -07:00
David Goldman
e5caf44fda Add a BuildSystemDelegate which supports notifications for build settings changes
Introduce a `BuildSystemDelegate` to handle notifications from the build system

* `SourceKitServer` is the main delegate to process these notifications
* Currently limited to changes in `FileBuildSettings`
* Delegate informs the `BuildSystem` of files to watch via `registerChangeWatching(for: URL)` and `unregisterChangeWatching(for: URL)`
* In the future we could have more integration for handling changes in dependencies

Handling changes in `FileBuildSettings`

* `SourceKitServer` sends notifications to the internal LSPs informing them of any opened documents that have changes in their compiler flags
    * For clangd, we send a notification to update the compilation database
    * For SourceKit/sourcekitd we must close and reopen the file to force a new AST with the new compiler flags
2019-09-06 17:44:36 -04:00
Ben Langmuir
e1fa70d086 Update SPM -> TSC module name prefixes 2019-09-03 08:29:19 -07:00
Richard Howell
fd6cdfb603 use Codable, start server as part of init, no log on missing config 2019-08-28 15:35:57 -07:00
Richard Howell
366f7d930d Add initial BuildServerBuildSystem based on BSP 2019-08-27 15:47:40 -07:00
Ben Langmuir
3322f35ccc [diagnostics] Keep semantic diagnostics until a semantic update
Sourcekitd returns parse diagnostics immediately after edits, but we do
not want to clear the semantic diagnostics until we have semantic level
diagnostics from after the edit.
2019-08-27 07:13:28 -07:00
Ben Langmuir
32497e6af9 Move diagnostic conversion into its own file 2019-08-26 21:57:37 -07:00
Ben Langmuir
e6392eb179 Fix typo public -> publish 2019-08-26 14:16:37 -07:00
Ben Langmuir
d15071bbd9 [test] Add workspace/_pollIndex extension for testing
Expose the index polling mechanism so it can be used in out-of-process
tests.
2019-08-22 15:57:25 -07:00
Ben Langmuir
ff7d8c1930 [test] Add listenToUnitEvents to initialization options
This should be used along with polling to explicitly control when index
data is read in tests that are outside the sourcekit-lsp process.
2019-08-22 14:53:53 -07:00
Ben Langmuir
9ed80c545e [lsp] Remove InitializationOptions type in favour of LSPAny
While we generally want to be type-safe, initialization options is
LSP-server specific, so just use LSPAny so we can pass arbitrary data
through as needed.
2019-08-22 14:27:44 -07:00
Ben Langmuir
fefd85c26d Merge pull request #144 from rmaz/separateregistries
Pass in MessageRegistry instead of using a singleton
2019-08-19 11:58:08 -07:00
Richard Howell
93982b2f2a messageRegistry -> protocol 2019-08-16 19:18:29 -07:00
Richard Howell
3701f6dcd5 pass in message registry instead of singleton 2019-08-15 15:28:19 -07:00