Update LSP status doc
Change-Id: I8143fb3adae5917cda8ed03088c1187f487c15a7
Reviewed-on: https://dart-review.googlesource.com/c/88720
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
diff --git a/pkg/analysis_server/lib/src/lsp/mapping.dart b/pkg/analysis_server/lib/src/lsp/mapping.dart
index 74b40ef..e97f557 100644
--- a/pkg/analysis_server/lib/src/lsp/mapping.dart
+++ b/pkg/analysis_server/lib/src/lsp/mapping.dart
@@ -325,8 +325,6 @@
? suggestion.displayText
: suggestion.completion;
- final useSnippets =
- completionCapabilities?.completionItem?.snippetSupport == true;
final useDeprecated =
completionCapabilities?.completionItem?.deprecatedSupport == true;
final formats = completionCapabilities?.completionItem?.documentationFormat;
@@ -352,7 +350,8 @@
(1000000 - suggestion.relevance).toString(),
null, // filterText uses label if not set
null, // insertText is deprecated, but also uses label if not set
- useSnippets ? lsp.InsertTextFormat.Snippet : lsp.InsertTextFormat.PlainText,
+ // We don't have completions that use snippets, so we always return PlainText.
+ lsp.InsertTextFormat.PlainText,
new lsp.TextEdit(
// TODO(dantup): If `clientSupportsSnippets == true` then we should map
// `selection` in to a snippet (see how Dart Code does this).
@@ -475,6 +474,10 @@
}
lsp.ParameterInformation toParameterInfo(server.ParameterInfo param) {
+ // LSP 3.14.0 supports providing label offsets (to avoid clients having
+ // to guess based on substrings). We should check the
+ // signatureHelp.signatureInformation.parameterInformation.labelOffsetSupport
+ // capability when deciding to send that.
return new lsp.ParameterInformation(getParamLabel(param), null);
}
@@ -489,7 +492,15 @@
),
],
0, // activeSignature
- null, // activeParameter
+ // TODO(dantup): The LSP spec says this value will default to 0 if it's
+ // not supplied or outside of the value range. However, setting -1 results
+ // in no parameters being selected in VS Code, whereas null/0 will select the first.
+ // We'd like for none to be selected (since we don't support this yet) so
+ // we send -1. I've made a request for LSP to support not selecting a parameter
+ // (because you could also be on param 5 of an invalid call to a function
+ // taking only 3 arguments) here:
+ // https://github.com/Microsoft/language-server-protocol/issues/456#issuecomment-452318297
+ -1, // activeParameter
);
}
diff --git a/pkg/analysis_server/test/lsp/completion_test.dart b/pkg/analysis_server/test/lsp/completion_test.dart
index a58127e..23f9b39 100644
--- a/pkg/analysis_server/test/lsp/completion_test.dart
+++ b/pkg/analysis_server/test/lsp/completion_test.dart
@@ -177,7 +177,7 @@
expect(item.detail, isNot(contains('deprecated')));
}
- test_plainText_simple() async {
+ test_plainText() async {
final content = '''
class MyClass {
String abcdefghij;
@@ -201,41 +201,6 @@
expect(updated, contains('a.abcdefghij'));
}
- test_snippet_simple() async {
- final content = '''
- class MyClass {
- String abcdefghij;
- }
-
- main() {
- MyClass a;
- a.abc^
- }
- ''';
-
- await initialize(
- textDocumentCapabilities: withCompletionItemSnippetSupport(
- emptyTextDocumentClientCapabilities));
- await openFile(mainFileUri, withoutMarkers(content));
- final res = await getCompletion(mainFileUri, positionFromMarker(content));
- expect(res.any((c) => c.label == 'abcdefghij'), isTrue);
- final item = res.singleWhere((c) => c.label == 'abcdefghij');
- // ignore: deprecated_member_use
- expect(item.insertText, anyOf(equals('abcdefghij'), isNull));
- expect(item.insertTextFormat, equals(InsertTextFormat.Snippet));
- final updated = applyTextEdits(withoutMarkers(content), [item.textEdit]);
- expect(updated, contains('a.abcdefghij'));
- expect(item.kind, equals(CompletionItemKind.Field));
- }
-
- @failingTest
- test_snippet_withSelection() async {
- // TODO(dantup): Implement snippet functionality + test.
- // Like above, but one that actually has a selectionOffset and results in
- // a snippet with tabstop.
- fail('NYI');
- }
-
test_unopenFile() async {
final content = '''
class MyClass {
diff --git a/pkg/analysis_server/test/lsp/signature_help_test.dart b/pkg/analysis_server/test/lsp/signature_help_test.dart
index ae051ff..e22eec0 100644
--- a/pkg/analysis_server/test/lsp/signature_help_test.dart
+++ b/pkg/analysis_server/test/lsp/signature_help_test.dart
@@ -288,7 +288,9 @@
final res =
await getSignatureHelp(mainFileUri, positionFromMarker(fileContent));
- expect(res.activeParameter, isNull);
+ // TODO(dantup): Update this when there is clarification on how to handle
+ // no valid selected parameter.
+ expect(res.activeParameter, -1);
expect(res.activeSignature, equals(0));
expect(res.signatures, hasLength(1));
final sig = res.signatures.first;
diff --git a/pkg/analysis_server/tool/lsp_spec/README.md b/pkg/analysis_server/tool/lsp_spec/README.md
index ea9c533..a8ad68e 100644
--- a/pkg/analysis_server/tool/lsp_spec/README.md
+++ b/pkg/analysis_server/tool/lsp_spec/README.md
@@ -19,14 +19,14 @@
Below is a list of LSP methods and their implementation status.
- Method: The LSP method name
-- Basic Impl: This method has a basic implementation but may not support all capabilities
-- Capabilities: All client capabilities (in the spec at time of writing) are supported/handled correctly
+- Basic Impl: This method has an implementation but may assume some client capabilities
+- Capabilities: Only types from the original spec or as advertised in client capabilities are returned
- Tests: Has automated tests
- Tested Client: Has been manually tested in at least one LSP client editor
| Method | Basic Impl | Capabilities | Tests | Tested Client | Notes |
| - | - | - | - | - | - |
-| initialize | ✅ | | ✅ | ✅ | trace and other options NYI
+| initialize | ✅ | ✅ | ✅ | ✅ | trace and other options NYI
| initialized | ✅ | ✅ | ✅ | ✅ |
| shutdown | ✅ | ✅ | ✅ | ✅ | supported but does nothing |
| exit | | | | | |
@@ -47,16 +47,16 @@
| textDocument/willSaveWaitUntil | | | | |
| textDocument/didClose | ✅ | ✅ | ✅ | ✅ |
| textDocument/publishDiagnostics | ✅ | ✅ | ✅ | ✅ |
-| textDocument/completion | ✅ | | ✅ | |
+| textDocument/completion | ✅ | ✅ | ✅ | ✅ |
| completionItem/resolve | | | | | not required |
-| textDocument/hover | ✅ | | ✅ | |
-| textDocument/signatureHelp | ✅ | | ✅ | | correct trigger character handling outstanding
-| textDocument/definition | ✅ | | ✅ | |
+| textDocument/hover | ✅ | ✅ | ✅ | ✅ |
+| textDocument/signatureHelp | ✅ | ✅ | ✅ | ✅ | trigger character handling outstanding
+| textDocument/definition | ✅ | ✅ | ✅ | ✅ |
| textDocument/typeDefinition | | | | |
| textDocument/implementation | | | | |
-| textDocument/references | ✅ | | ✅ | |
+| textDocument/references | ✅ | ✅ | ✅ | ✅ |
| textDocument/documentHighlight | | | | |
-| textDocument/documentSymbol | ✅ | | ✅ | |
+| textDocument/documentSymbol | ✅ | ✅ | ✅ | ✅ |
| textDocument/codeAction (sortMembers) | ✅ | ✅ | ✅ | ✅ |
| textDocument/codeAction (organiseImports) | ✅ | ✅ | ✅ | ✅ |
| textDocument/codeAction (refactors) | | | | |