Commit Graph

153 Commits

Author SHA1 Message Date
Owen Voorhees
77a81ad9c1 Expose diagnostic educational notes as diagnostic codes 2020-11-09 18:30:02 -08:00
Saleem Abdulrasool
67aaa09d70 build: allow building with dispatch and Foundation from the toolchain
This allows building without dispatch and Foundation build roots, which
allows for a multi-phase build.  This is intended to support the Windows
staged build where dispatch and Foundation are part of the SDK and
SourceKit-LSP is part of the devtools.
2020-10-07 19:08:02 -07:00
Saleem Abdulrasool
c55c71d111 build: update CMakeLists.txt
This updates the CMakeLists.txt to allow building SourceKit-LSP with
CMake.
2020-09-06 18:44:34 -07:00
Ben Langmuir
16dc2fb0c9 [completion] Enable server-side filtering by default 2020-07-29 11:06:55 -07:00
Ben Langmuir
bf9053c671 [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-07-29 10:01:24 -07:00
Ben Langmuir
a5832e978b [gardening] Fix copyright headers and formating in modified files 2020-07-29 09:55:02 -07:00
Ben Langmuir
fe283fa2c2 [completion] Add an extension to pass completion options per-request 2020-07-29 09:42:47 -07:00
Ben Langmuir
c45de61a72 [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-07-29 09:42:47 -07:00
David Goldman
5977d611aa Withhold diagnostics when fallback arguments are being used (#281)
While fallback arguments are being used (either from the fallback build system or fallback settings from the primary build system), withhold semantic diagnostics from sourcekitd and all diagnostics from clangd. This helps prevent user confusion from spurious errors.

- Also remove the DocumentURI standardization in favor of proper equality + hash checks to work around the %40 --> @ encoding issue seen on CI.
2020-06-11 11:38:50 -04:00
Ben Langmuir
1040621ae1 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.
2020-06-09 13:20:15 -07:00
Saleem Abdulrasool
f3f0795cdc build: repair build on Windows
This enables building SourceKit-LSP on Windows.  This is sufficient to
repair the build, though it is insufficient to run currently.
2020-06-05 08:28:26 -07:00
David Goldman
8b57352f3b Send didSave notifications to clangd if it supports it (#280)
* Send `didSave` notifications to clangd if it supports it

- Minor update to the LSP protocol for `didSave` and `colorProvider` to be more in line with the spec
- Only send color requests over to clangd if it supports it

Rationale for this change: clangd recently implemented didSave support,
it is used to rebuild preambles when the user edits a header file
referenced by an open file.

Change-Id: Ie6e2198bdeccb9d1b4083806c254475baadc2d2b
2020-06-03 14:20:38 -07:00
David Goldman
cf19900d84 Swap BuildSystem to remove build settings method (#183)
Remove `settings(for:)` from the BuildSystem API in favor of the change callback

- With the `settings(for:)` method removed, we instead block on a
  callback from the `BuildSystemManager` which itself handles
  the primary build system callback in conjunction with the fallback
  system

- We queue up notifications / requests that reference documents
  until we receive the callback.

- Remove language from FileBuildSettings as it is no longer needed,
  Swift-specific working dir fixes are now in SwiftCompileCommand

- registerForChangeNotifications should inform its delegate
  asynchronously instead of immediately
2020-06-01 13:20:15 -04: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