Commit Graph

176 Commits

Author SHA1 Message Date
Ben Langmuir
439428e65d [completion] Add doc comment for CodeCompletionSession
Conflicts:
	Sources/SourceKit/sourcekitd/CodeCompletion.swift
	Sources/SourceKit/sourcekitd/CodeCompletionSession.swift
2020-10-16 13:16:26 -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
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
1f28a7cd03 [completion] Set default maxResults = 200 2020-10-16 11:53:46 -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
198266d775 [completion] Add server-side filtering UIDs 2020-10-16 11:36:06 -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
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
fa8acc142f [fixit] Handle multi-edit fixits
We were treating arrays of fixits as if they were independent actions,
but in reality we have at most one quick-fix per diagnostic, which is
composed of multiple edits. This fixes cases like renaming a deprecated
method where there are multiple edits that need to be combined.
2020-02-07 11:40:55 -08: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
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
e57337dca8 [index] Avoid querying main files for a non-file URL
IndexStoreDB expects a file path, so exit early if we have something
else.
2020-02-06 13:16:08 -08:00
Ben Langmuir
44f535fb91 [buildsystem] Wire up BuildSystemManager to SourceKitServer
Wires up the build system manager in the server, and all existing tests.
2020-02-05 21:53:52 -08:00
Ben Langmuir
89f29cb864 [buildsystem] Introduce BuildSystemManager that handles main-file lookup
The build system manager will integrate with the indexer to provide
header to main file mappings, including keeping those mappings
up-to-date as `#include`s are added and removed. This allows us to
provide accurate compiler arguments for a header based on a real
translation unit. When there are no main files found, we continue to
fallback to asking the build system.

The build system manager also gives us a place to put a client-side
setting cache, since multiple headers may map to a single main file.

For now, the BuildSystemManager is only used by tests. A subsequent
commit will wire it up to the index and server.
2020-02-05 21:53:52 -08:00
Ben Langmuir
a679d4553d [buildsystem] Standardize call between register and settings query NFC
In preparation for injecting doing more during registration, pass
through the same parameters (add language) so that we can call settings
as necessary.
2020-02-05 21:53:52 -08:00
Ben Langmuir
25e3574bc3 Add MainFilesProvider and MainFilesDelegate for index
Introduce types for looking up and receiving notifications about changes
to main file mappings (e.g. header.h -> foo.cpp) in terms of documents.
For now this is only exercised in the test, but the goal is to use this
to correctly lookup main files for headers during build system queries.
2020-02-05 21:53:52 -08:00
Ben Langmuir
47d92d89f9 Remove unused toolchain lookup function NFC
We want to be able to lookup the toolchain by file eventually, but it's
currently dead code.
2020-02-05 21:53:52 -08:00
Ben Langmuir
a22004dd90 [buildsystem] Fix race when settings are updated
Jump onto `queue` when receiving notifications from the build system,
which could be on any queue.
2020-02-05 20:44:25 -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
ddb9a8d964 Make initial workspace load asynchronous
Some editors treat the initialize request as blocking, or otherwise time
out if it takes too long. We have been scraping that edge for swiftpm
projects (time taken to load the manifest and construct a build graph),
and large compilation databases (time taken to parse the json and then
split commands into separate arguments). In practice, a *debug build* of
sourcekit-lsp was failing to open a large compilation database fast
enough for sublime text's lsp plugin (3 second limit).

This change hides the latency for loading the build system and creating
the index by letting it continue beyond the initialize request, blocking
instead the next request. This is not a complete solution. In addition
to hiding latency in between requests, this also is based on editors
being more forgiving about slow requests beyond the first initialize.`

We should also continue to improve the performance of the initial load
of the build system and index. And we should also consider more
prinicipled ways to use asynchronicity, for example by not doing the
initial load on the server's message queue. The main challenge for that
is that we have some assumptions, particularly in tests, that the index
will be created already, and for the index to load we currently block on
the build system load in order to get the index directory.
2020-02-04 09:20:50 -08:00
Ben Langmuir
b917ebe5d9 Infer index store path from compilation database
Find the index store path by searching through the command-line
arguments, and if found, also provide a default database path next to
the index store. Also add command-line arguments so that either of these
can be overridden. We could also easily add these as initialization
options if an LSP client wanted to provide them in the future.
2020-02-03 09:07:01 -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
45f001c291 Return Fix-its in PublishDiagnostics as defined in a clangd LSP-extension 2020-01-27 12:23:35 -08:00
Alex Hoppen
0097a84e28 Merge pull request #215 from ahoppen/shutdown-request
Rename Shutdown to ShutdownRequest
2020-01-27 08:23:40 -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
Butta
a4cec47d70 Android: add native support 2019-12-26 15:49:13 +05:30
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
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
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