Commit Graph

146 Commits

Author SHA1 Message Date
Ben Langmuir
f333b3d489 Shutdown toolchain connections on exit
When using SourceKit-LSP in tests (or otherwise in a library), we do not
want to leak the toolchain connections.

Conflicts:
	Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift
2020-10-16 13:51:24 -07:00
Ben Langmuir
44851919f7 [completion] Enable server-side filtering by default 2020-10-16 13:16:30 -07:00
Ben Langmuir
8c1ef3290c [gardening] Rename CodeCompletionOptions -> SKCompletionOptions
Since it is being used in the LSP protocol layer, give it a name that
clarifies that it is SourceKit-specific.
2020-10-16 13:11:55 -07:00
Ben Langmuir
d8b5a980ee [gardening] Fix copyright headers and formating in modified files
Conflicts:
	Sources/SourceKit/SourceKitServer.swift
	Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift
2020-10-16 13:11:50 -07:00
Ben Langmuir
b97dac9b6f [completion] Add an extension to pass completion options per-request
Conflicts:
	Sources/LanguageServerProtocol/SupportTypes/CodeCompletionOptions.swift
	Sources/SourceKit/CodeCompletionOptions.swift
	Sources/SourceKitLSP/CodeCompletionOptions.swift
2020-10-16 13:09:06 -07:00
Ben Langmuir
34896d2fe1 [log] Improve description of Position
By default, print 1-based line/column numbers using the defacto standard
line:column format. In debug print, continue to use the 0-based values
to match the constructor.
2020-10-16 12:02:47 -07:00
David Goldman
81e2688c5d Support for clangd's go-to-definition for #include/#import (#247)
* Support for clangd's go-to-definition for header files

- By forwarding the request to clangd when it fails to give
  symbol information, we are able to use its built in
  go-to-definition support for headers (jump to header file)

* Add static tibs test for clangd go-to-#include

* Move #include test to SourceKitTests and regenerate linux main

* Fix improper escaping of %40 in file URLs

* Add URL escaping test

* Another attempt to fix broken BuildServerBuildSystemTests test on Linux

- URL's `standardizedFileURL` removes trailing slashes from file URLs,
  but only on Linux
2020-03-13 19:20:25 -04:00
Ben Langmuir
428ab30f5a Add default value to DiagnosticRelatedInformation initializer 2020-02-19 10:41:33 -08:00
Ben Langmuir
a61a2857e4 Merge pull request #243 from DavidGoldman/letsgetvirtual
Disable diagnostics for blacklisted document schemes
2020-02-18 08:18:30 -08:00
David Goldman
47c9428fa2 Disable diagnostics for blacklisted document schemes
- Otherwise can lead to confusing duplicated diagnostics in VSCode
  due to its usage of virtual documents for source control diffbases

- sourcekitd does not properly handle virtual files when the
  `-working-directory` flag is passed

Change-Id: I9b7f435aac3f7c19082dd6c2fd7561c524356352
2020-02-13 18:24:31 -05:00
David Goldman
72e7c5b25f Improve handling/testing of filesDependenciesUpdated for clangd
- Add support for recently upstreamed `forceRebuild` extension (6ff0228c6d).
  Note that until it is merged into Apple-clangd we can't add a test for it with missing headers

- Add a test for the clangd functionality by modifying a generated header file

Change-Id: If53fd88da92e4fc7d9c22af7430300fb3fc0f5ce
2020-02-10 16:22:54 -05:00
Ben Langmuir
206e3646b7 [fixit] Add CodeActions for fixits from notes
Extends the fixit support to also walk notes (related information in LSP
terminology).
2020-02-07 11:40:55 -08:00
Ben Langmuir
2106002459 [cmake] Update CMakeLists.txt for recent file additions 2020-02-07 09:52:12 -08:00
Ben Langmuir
a57dea902f Merge pull request #216 from ahoppen/fixits
Provide Fix-Its through codeActions and PublishDiagnostics
2020-02-04 15:59:04 -08:00
Ben Langmuir
a88ab45e07 [codeActions] Ignore "supportedKinds", which isn't really an opt-in list
The client guarantees that unsupported kinds will be handled, and in
practice some clients, such as Sublime's LSP plugin, use
`"codeActionKind":{"valueSet":[]}`, since they support all kinds anyway.

This behaviour was also clarified in a [spec issue
report](https://github.com/Microsoft/language-server-protocol/issues/620)
where it was confirmed the server can send any actions it wants. It
seems preferable to ignore it.
2020-02-04 13:34:02 -08:00
Alex Hoppen
af1f55ed9f Return a more easily readable string from the Language's description property 2020-01-28 14:32:21 -08:00
Alex Hoppen
6d9b41417b Add all language identifiers listed in the LSP spec 2020-01-27 13:48:19 -08:00
Alex Hoppen
45f001c291 Return Fix-its in PublishDiagnostics as defined in a clangd LSP-extension 2020-01-27 12:23:35 -08:00
Alex Hoppen
ce5f4774c6 Rename Shutdown to ShutdownRequest 2020-01-23 14:21:45 -08:00
David Goldman
76e34ef63c Fix CodingKeys build error
Change-Id: Ifc73f29113b14736f3051c734a32962bef839313
2019-12-17 15:59:43 -05: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
Ben Langmuir
79e312b00e Merge pull request #206 from ahoppen/match-spec-part-2
Part 2: Update the struct definitions to match version 3.14 of the LSP spec
2019-12-13 10:51:21 -08:00
Alex Hoppen
4c07ec76ad Add missing default initializer value in DynamicRegistrationLinkSupportCapability 2019-12-12 17:17:35 -08:00
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
Ben Langmuir
8d2a6e9b7d Merge pull request #207 from ahoppen/diagnostics-document-version
Add a version field to PublishDiagnostics, according to LSP 3.15
2019-12-10 10:51:49 -08:00
Alex Hoppen
36d8a1799c Add a version field to PublishDiagnostics, according to LSP 3.15
LSP Spec 3.15 will add a document version field for PublishDiagnostics.
Cherry-picking field into SourceKit-LSP.
2019-12-09 18:22:18 -08:00
Ben Langmuir
37d0a9381a Merge pull request #205 from compnerd/cmake
build: add CMake build system
2019-12-06 15:42:49 -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
Saleem Abdulrasool
54d5324613 build: add CMake build system 2019-12-04 16:47:34 -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