Commit Graph

119 Commits

Author SHA1 Message Date
Alex Hoppen
bfdcccd9a3 In HoverResponse Decode single MarkedString as [MarkedString] with one element 2019-12-12 17:17:35 -08:00
Alex Hoppen
4273342301 Update WorkspaceFoldersRequest to match version 3.14 of the LSP spec 2019-12-12 17:17:35 -08:00
Alex Hoppen
2b0f71a945 Update WorkspaceEdit to match version 3.14 of the LSP spec 2019-12-12 17:17:35 -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
5f0b2bca3d Update decoding error message for HoverRequest to match others 2019-12-06 08:31:44 -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
de7d1e55fa Make unknown case of WorkspaceSettingsChange have an LSPAny associated value 2019-12-06 08:31:19 -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
Alex Hoppen
a75a288a45 Update Completion to match version 3.14 of the spec 2019-12-06 08:31:19 -08:00
Alex Hoppen
585213b569 Update ClientCapabilities to match version 3.14 of the spec 2019-12-04 16:33:24 -08:00
Ben Langmuir
d2cfe7e847 Upgrade CustomCodable to handle optional values using encodeIfPresent
The LSP spec requires us to omit keys for nil values rather than using
the JSON `null` constant in most places. This change to CustomCodable
allows us to do it automatically using CustomCodable, removing one of
the limitations of the property wrapper.

The idea for the adding overloads of `encode` and `decode` came from
https://forums.swift.org/t/pre-pitch-codable-customization-using-propertywrappers/30244/
2019-12-04 08:49:19 -08:00
Alex Hoppen
03dde148a9 Support MarkedStrings in Hover responses 2019-12-03 15:07:17 -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
Alex Hoppen
25cd302cad Remove dependency of LanguageServerProtocol on SKSupport
Apart from removing unnecessary imports, the following changes were
performed:
- Move CancellationToken from SKSupport to LanguageServerProtocol
- Move CustomCodable to its own module
  - CustomCodable belongs in LanguageServerProtocol but moving it there
    causes compilation to fail. As a workaround, move it to its own
    module
2019-11-13 12:02:14 -08:00
Alex Hoppen
1fde01efc0 Move LanguageServer to SKCore 2019-11-12 16:58:25 -08:00
Alex Hoppen
4b3c571db6 Eliminate _IndirectConnection and replace it by closure
This allows us to move the semaphore logic out of the message to the connection where it belongs.
2019-11-12 15:04:44 -08:00
David Goldman
74af4873c7 Fix issue preventing DocumentSymbols from working with clangd
- Clangd uses the HierarchicalDocumentSymbolSupport field of the
  documentSymbol capabilities, if we don't pass it through clangd
  will change its behavior potentially resulting in a response
  error (e.g. in Visual Studio Code)
2019-11-01 15:41:22 -05: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
88b5a1a5c1 Merge pull request #171 from benlangmuir/tsanify-1
[tsan] Fix a few issues caught by TSan
2019-10-08 16:11:58 -07:00
Ben Langmuir
93d3abba14 [tsan] Fix race during logging request 2019-10-04 15:59:11 -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
77d7b44eb8 Make DocumentSymbol fields public 2019-10-02 16:08:56 -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
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
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
Ben Langmuir
e6fc0f017b [cli] Add --sync option for testing
When testing the sourcekit-lsp binary, it is handy to be able to force
requests to be handled synchronously. This only affects the protocol
layer, not the implementation. This option is hidden from the help text
and should only be used for testing/debugging.
2019-08-22 16:19:36 -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
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
4ea77f8dbd [lsp] Move LSPAny into its own file and add brief doc comment" 2019-08-22 14:25:02 -07:00
Ben Langmuir
70575ff318 [lsp] Rename CommandArgumentType to LSPAny
This data type is useful outside of Command arguments.
2019-08-22 14:18: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
Ben Langmuir
b3a89f9491 Remove testable imports of LanguageServerProtocol 2019-08-08 22:00:38 -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
Ben Langmuir
c48cb82b0c Merge pull request #122 from krzyzanowskim/language-struct
Convert Language enum to struct
2019-08-02 08:50:52 -07:00
Ben Langmuir
b8e79ccb4b Merge pull request #123 from literalpie/workspace-symbols
Add workspace/symbols support
2019-08-01 14:44:36 -07:00
cukr
7667608eef Implement "textDocument/implementation" request 2019-07-24 14:42:10 +02:00
Ben Langmuir
3044f7394b Add infrastructure for test projects using Tibs
This builds on the indexer changes to support test projects using the
tibs build system. See the commit message from IndexStoreDB for more
information.

This commit adds a couple of simple tests using test fixtures in the
INPUTS directory. It is a fairly minimal change for using the indexer's
test support code to prove the model works. One missing piece here is
support for mutable sources and updating the index, which is supported
on the IndexStoreDB side, but needs a bit more work here.  This also
doesn't include any tests using swiftpm's build system.
2019-07-22 13:57:04 -07:00