Commit Graph

93 Commits

Author SHA1 Message Date
Ben Langmuir
08f54208eb Fix merge conflict resolution errors 2020-10-16 13:51:24 -07:00
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
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
9d5f54715c [completion] Fix tests when using server-side filtering
With this change, tests pass whether we default to server-side or
client-side filtering. Also duplicate a few interesting tests to run
both ways. A future commit will beef up the test coverage for
server-side filtering specifically.

Conflicts:
	Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift
2020-10-16 12:02:43 -07:00
Ben Langmuir
ffd9690884 [completion] Add initial server-side filtering implementation
Work in progress: add a basic implementation for keeping track of the
current completion session, and use the sourcekitd
complete.open/update/close requests.

Conflicts:
	Sources/SourceKit/sourcekitd/CodeCompletion.swift
	Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift
2020-10-16 11:53:42 -07:00
Ben Langmuir
e0511b9904 [gardening] Split code-completion into its own file
Similar to cursor info, there is enough code here it makes sense to
separate it out.

Conflicts:
	Sources/SourceKit/sourcekitd/CodeCompletion.swift
	Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift
2020-10-16 11:15:56 -07:00
Ben Langmuir
f8f98dd5a9 [completion] Pass through new code-completion options
Conflicts:
	Sources/SourceKit/CodeCompletionOptions.swift
	Sources/SourceKit/SourceKitServer.swift
	Sources/SourceKit/sourcekitd/SwiftLanguageServer.swift
2020-10-16 10:54:02 -07:00
Rintaro Ishizaki
a27470dc71 [sourcekitd] Add an option to completion request to sort results
rdar://problem/60799439
2020-03-26 13:53:40 -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
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
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
8b017afa5b [fixit] Add a descriptive title to quickfixes
While the diagnostic provides the broader context, there can be multiple
fixits and it is helpful to give some way to see what they will do. This
adds a brief "Insert ';'", "Replace 'let a' with '_'", "Remove 'blah'"
description as the title.
2020-02-06 15:04:23 -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
bda0cc48a0 Merge pull request #212 from DavidGoldman/dependencyhandling
Work on implementing dependenciesUpdated part of Build System integration
2020-01-27 15:32:55 -08:00
Alex Hoppen
fd018c9019 Return Fix-its from code actions request 2020-01-27 12:26:25 -08:00
Alex Hoppen
ce5f4774c6 Rename Shutdown to ShutdownRequest 2020-01-23 14:21:45 -08:00
David Goldman
e3b9296bc9 Handle documentDependenciesUpdated with clangd and sourcekitd
Change-Id: I37b5bf4196cd44ab585d36f5b8334c52175c7834
2020-01-23 13:11:39 -05:00
David Goldman
8331bb5146 Work on implementing dependenciesUpdated part of Build System integration
Change-Id: Ieed32d625afb570ced559206f1867bd2d4d2bacf
2020-01-07 15:58:50 -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
c3e70b5933 Update ServerCapabilities to match version 3.14 of the LSP spec 2019-12-12 17:17:35 -08:00
Alex Hoppen
acd8843967 Use SourceKit's not_recommended field to populate deprecated in Code completion responses 2019-12-10 11:49:03 -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
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
bcadf01539 Update DocumentSymbolRequest to match version 3.14 of the LSP 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
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
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
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
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
Bruno Rocha
20c026c8e2 Cleaning Code 2019-09-24 17:59:38 -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
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
cukr
719bed2be0 Response to code review 2019-08-08 23:00:03 +02:00
cukr
7667608eef Implement "textDocument/implementation" request 2019-07-24 14:42:10 +02:00