2018-02-06 18:47:30 +08:00
|
|
|
# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
|
|
|
|
# Test initialize request parameters with rootUri
|
2018-03-01 04:31:00 +08:00
|
|
|
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootUri":"test:///workspace","capabilities":{},"trace":"off"}}
|
2018-02-06 18:47:30 +08:00
|
|
|
# CHECK: "id": 0,
|
|
|
|
# CHECK-NEXT: "jsonrpc": "2.0",
|
|
|
|
# CHECK-NEXT: "result": {
|
|
|
|
# CHECK-NEXT: "capabilities": {
|
|
|
|
# CHECK-NEXT: "codeActionProvider": true,
|
|
|
|
# CHECK-NEXT: "completionProvider": {
|
2020-02-19 16:18:38 +08:00
|
|
|
# CHECK-NEXT: "allCommitCharacters": " \t()[]{}<>:;,+-/*%^&#?.=\"'|",
|
2018-02-06 18:47:30 +08:00
|
|
|
# CHECK-NEXT: "resolveProvider": false,
|
|
|
|
# CHECK-NEXT: "triggerCharacters": [
|
|
|
|
# CHECK-NEXT: ".",
|
|
|
|
# CHECK-NEXT: ">",
|
|
|
|
# CHECK-NEXT: ":"
|
|
|
|
# CHECK-NEXT: ]
|
|
|
|
# CHECK-NEXT: },
|
[clangd] Implement textDocument/declaration from LSP 3.14
Summary:
LSP now reflects the declaration/definition distinction.
Language server changes:
- textDocument/definition now returns a definition if one is found, otherwise
the declaration. It no longer returns declaration + definition if they are
distinct.
- textDocument/declaration returns the best declaration we can find.
- For macros, the active macro definition is returned for both methods.
- For include directive, the top of the target file is returned for both.
There doesn't appear to be a discovery mechanism (we can't return everything to
clients that only know about definition), so this changes existing behavior.
In practice, it should greatly reduce the fraction of the time we need to show
the user a menu of options.
C++ API changes:
- findDefinitions is replaced by locateSymbolAt, which returns a
vector<LocatedSymbol> - one for each symbol under the cursor.
- this contains the preferred declaration, the definition (if found), and
the symbol name
This API enables some potentially-neat extensions, like swapping between decl
and def, and exposing the symbol name to the UI in the case of multiple symbols.
Reviewers: hokein
Subscribers: ilya-biryukov, javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Differential Revision: https://reviews.llvm.org/D57388
llvm-svn: 352864
2019-02-01 19:26:13 +08:00
|
|
|
# CHECK-NEXT: "declarationProvider": true,
|
2018-02-06 18:47:30 +08:00
|
|
|
# CHECK-NEXT: "definitionProvider": true,
|
|
|
|
# CHECK-NEXT: "documentFormattingProvider": true,
|
|
|
|
# CHECK-NEXT: "documentHighlightProvider": true,
|
2019-12-17 02:08:51 +08:00
|
|
|
# CHECK-NEXT: "documentLinkProvider": {
|
|
|
|
# CHECK-NEXT: "resolveProvider": false
|
|
|
|
# CHECK-NEXT: }
|
2018-02-06 18:47:30 +08:00
|
|
|
# CHECK-NEXT: "documentOnTypeFormattingProvider": {
|
[clangd] Revamp textDocument/onTypeFormatting.
Summary:
The existing implementation (which triggers on }) is fairly simple and
has flaws:
- doesn't trigger frequently/regularly enough (particularly in editors that type the }
for you)
- often reformats too much code around the edit
- has jarring cases that I don't have clear ideas for fixing
This implementation is designed to trigger on newline, which feels to me more
intuitive than } or ;.
It does have allow for reformatting after other characters - it has a
basic behavior and a model for adding specialized behavior for
particular characters. But at least initially I'd stick to advertising
\n in the capabilities.
This also handles comment splitting: when you insert a line break inside
a line comment, it will make the new line into an aligned line comment.
Working on tests, but want people to patch it in and try it - it's hard to
see if "feel" is right purely by looking at a test.
Reviewers: ilya-biryukov, hokein
Subscribers: mgorny, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D60605
llvm-svn: 362939
2019-06-10 22:26:21 +08:00
|
|
|
# CHECK-NEXT: "firstTriggerCharacter": "\n",
|
2018-02-06 18:47:30 +08:00
|
|
|
# CHECK-NEXT: "moreTriggerCharacter": []
|
|
|
|
# CHECK-NEXT: },
|
|
|
|
# CHECK-NEXT: "documentRangeFormattingProvider": true,
|
2018-07-06 03:35:01 +08:00
|
|
|
# CHECK-NEXT: "documentSymbolProvider": true,
|
2018-02-06 18:47:30 +08:00
|
|
|
# CHECK-NEXT: "executeCommandProvider": {
|
|
|
|
# CHECK-NEXT: "commands": [
|
[clangd] Interfaces for writing code tweaks
Summary:
The code tweaks are an implementation of mini-refactorings exposed
via the LSP code actions. They run in two stages:
- Stage 1. Decides whether the action is available to the user and
collects all the information required to finish the action.
Should be cheap, since this will run over all the actions known to
clangd on each textDocument/codeAction request from the client.
- Stage 2. Uses information from stage 1 to produce the actual edits
that the code action should perform. This stage can be expensive and
will only run if the user chooses to perform the specified action in
the UI.
One unfortunate consequence of this change is increased latency of
processing the textDocument/codeAction requests, which now wait for an
AST. However, we cannot avoid this with what we have available in the LSP
today.
Reviewers: kadircet, ioeric, hokein, sammccall
Reviewed By: sammccall
Subscribers: mgrang, mgorny, MaskRay, jkorous, arphaman, cfe-commits
Differential Revision: https://reviews.llvm.org/D56267
llvm-svn: 352494
2019-01-29 22:17:36 +08:00
|
|
|
# CHECK-NEXT: "clangd.applyFix",
|
|
|
|
# CHECK-NEXT: "clangd.applyTweak"
|
2018-02-06 18:47:30 +08:00
|
|
|
# CHECK-NEXT: ]
|
|
|
|
# CHECK-NEXT: },
|
[clangd] Implement textDocument/hover
Summary: Implemention of textDocument/hover as described in LSP definition.
This patch adds a basic Hover implementation. When hovering a variable,
function, method or namespace, clangd will return a text containing the
declaration's scope, as well as the declaration of the hovered entity.
For example, for a variable:
Declared in class Foo::Bar
int hello = 2
For macros, the macro definition is returned.
This patch doesn't include:
- markdown support (the client I use doesn't support it yet)
- range support (optional in the Hover response)
- comments associated to variables/functions/classes
They are kept as future work to keep this patch simpler.
I added tests in XRefsTests.cpp. hover.test contains one simple
smoketest to make sure the feature works from a black box perspective.
Reviewers: malaperle, krasimir, bkramer, ilya-biryukov
Subscribers: sammccall, mgrang, klimek, rwols, ilya-biryukov, arphaman, cfe-commits
Differential Revision: https://reviews.llvm.org/D35894
Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
Signed-off-by: William Enright <william.enright@polymtl.ca>
llvm-svn: 325395
2018-02-17 05:38:15 +08:00
|
|
|
# CHECK-NEXT: "hoverProvider": true,
|
2018-09-05 19:53:07 +08:00
|
|
|
# CHECK-NEXT: "referencesProvider": true,
|
2018-02-06 18:47:30 +08:00
|
|
|
# CHECK-NEXT: "renameProvider": true,
|
2019-09-24 21:38:33 +08:00
|
|
|
# CHECK-NEXT: "selectionRangeProvider": true,
|
2020-03-24 09:24:47 +08:00
|
|
|
# CHECK-NEXT: "semanticTokensProvider": {
|
[clangd] Support textDocument/semanticTokens/edits
Summary:
This returns incremental highlights as a set of edits against the
previous highlights.
Server-side, we compute the full set of highlights, this just saves
wire-format size.
For now, the diff used is trivial: everything from the first change to
the last change is sent as a single edit.
The wire format is grungy - the replacement offset/length refer to
positions in the encoded array instead of the logical list of tokens.
We use token-oriented structs and translating to LSP forms when serializing.
This departs from LSP (but is consistent with semanticTokens today).
Tested in VSCode insiders (with a patched client to enable experimental
features).
Reviewers: hokein
Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D77225
2020-04-01 22:21:44 +08:00
|
|
|
# CHECK-NEXT: "documentProvider": {
|
|
|
|
# CHECK-NEXT: "edits": true
|
|
|
|
# CHECK-NEXT: },
|
2020-03-24 09:24:47 +08:00
|
|
|
# CHECK-NEXT: "legend": {
|
|
|
|
# CHECK-NEXT: "tokenModifiers": [],
|
|
|
|
# CHECK-NEXT: "tokenTypes": [
|
|
|
|
# CHECK-NEXT: "variable",
|
|
|
|
# CHECK: ]
|
|
|
|
# CHECK-NEXT: },
|
|
|
|
# CHECK-NEXT: "rangeProvider": false
|
|
|
|
# CHECK-NEXT: },
|
2018-02-06 18:47:30 +08:00
|
|
|
# CHECK-NEXT: "signatureHelpProvider": {
|
|
|
|
# CHECK-NEXT: "triggerCharacters": [
|
|
|
|
# CHECK-NEXT: "(",
|
|
|
|
# CHECK-NEXT: ","
|
|
|
|
# CHECK-NEXT: ]
|
|
|
|
# CHECK-NEXT: },
|
[clangd] Implementation of workspace/symbol request
Summary:
This is a basic implementation of the "workspace/symbol" request which is
used to find symbols by a string query. Since this is similar to code completion
in terms of result, this implementation reuses the "fuzzyFind" in order to get
matches. For now, the scoring algorithm is the same as code completion and
improvements could be done in the future.
The index model doesn't contain quite enough symbols for this to cover
common symbols like methods, enum class enumerators, functions in unamed
namespaces, etc. The index model will be augmented separately to achieve this.
Reviewers: sammccall, ilya-biryukov
Reviewed By: sammccall
Subscribers: jkorous, hokein, simark, sammccall, klimek, mgorny, ilya-biryukov, mgrang, jkorous-apple, ioeric, MaskRay, cfe-commits
Differential Revision: https://reviews.llvm.org/D44882
llvm-svn: 330637
2018-04-24 04:00:52 +08:00
|
|
|
# CHECK-NEXT: "textDocumentSync": 2,
|
[clangd] Add support for type hierarchy (super types only for now)
Summary:
Patch by Nathan Ridge(@nridge)!
This is an LSP extension proposed here:
https://github.com/Microsoft/vscode-languageserver-node/pull/426
An example client implementation can be found here:
https://github.com/theia-ide/theia/pull/3802
Reviewers: kadircet, sammccall
Reviewed By: kadircet
Subscribers: jdoerfert, sammccall, cfe-commits, mgorny, dschaefer, simark, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet
Tags: #clang
Differential Revision: https://reviews.llvm.org/D56370
llvm-svn: 356445
2019-03-19 17:27:04 +08:00
|
|
|
# CHECK-NEXT: "typeHierarchyProvider": true
|
[clangd] Implementation of workspace/symbol request
Summary:
This is a basic implementation of the "workspace/symbol" request which is
used to find symbols by a string query. Since this is similar to code completion
in terms of result, this implementation reuses the "fuzzyFind" in order to get
matches. For now, the scoring algorithm is the same as code completion and
improvements could be done in the future.
The index model doesn't contain quite enough symbols for this to cover
common symbols like methods, enum class enumerators, functions in unamed
namespaces, etc. The index model will be augmented separately to achieve this.
Reviewers: sammccall, ilya-biryukov
Reviewed By: sammccall
Subscribers: jkorous, hokein, simark, sammccall, klimek, mgorny, ilya-biryukov, mgrang, jkorous-apple, ioeric, MaskRay, cfe-commits
Differential Revision: https://reviews.llvm.org/D44882
llvm-svn: 330637
2018-04-24 04:00:52 +08:00
|
|
|
# CHECK-NEXT: "workspaceSymbolProvider": true
|
2020-03-03 19:25:46 +08:00
|
|
|
# CHECK-NEXT: },
|
|
|
|
# CHECK-NEXT: "serverInfo": {
|
|
|
|
# CHECK-NEXT: "name": "clangd",
|
|
|
|
# CHECK-NEXT: "version": "{{.*}}clangd version {{.*}}"
|
2018-02-06 18:47:30 +08:00
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
---
|
|
|
|
{"jsonrpc":"2.0","id":3,"method":"shutdown"}
|
|
|
|
# CHECK: "id": 3,
|
|
|
|
# CHECK-NEXT: "jsonrpc": "2.0",
|
|
|
|
# CHECK-NEXT: "result": null
|
|
|
|
---
|
2018-08-15 23:50:45 +08:00
|
|
|
{"jsonrpc":"2.0","method":"exit"}
|