[Analyzer] Update to latest version of LSP spec

Change-Id: I16418caeacad044269fd3d79e28b9b800ce798f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174804
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Danny Tuppeny
2020-12-02 20:11:08 +00:00
committed by commit-bot@chromium.org
parent ca8c43e3ed
commit bb971209d1
9 changed files with 756 additions and 574 deletions
File diff suppressed because it is too large Load Diff
@@ -166,9 +166,6 @@ class CompletionResolveHandler
.trim()
: item.detail,
documentation: documentation,
// The deprecated field is deprecated, but we should still supply it
// for clients that have not adopted CompletionItemTags.
// ignore: deprecated_member_use_from_same_package
deprecated: item.deprecated,
preselect: item.preselect,
sortText: item.sortText,
@@ -41,11 +41,7 @@ class InitializeMessageHandler
}
if (params.rootUri != null) {
openWorkspacePaths.add(Uri.parse(params.rootUri).toFilePath());
// ignore: deprecated_member_use_from_same_package
} else if (params.rootPath != null) {
// This is deprecated according to LSP spec, but we still want to support
// it in case older clients send us it.
// ignore: deprecated_member_use_from_same_package
openWorkspacePaths.add(params.rootPath);
}
}
@@ -210,7 +210,7 @@ class ServerCapabilitiesComputer {
commands: Commands.serverSupportedCommands,
workDoneProgress: true,
),
workspaceSymbolProvider: true,
workspaceSymbolProvider: Either2<bool, WorkspaceSymbolOptions>.t1(true),
workspace: ServerCapabilitiesWorkspace(
workspaceFolders: WorkspaceFoldersServerCapabilities(
supported: true,
@@ -441,7 +441,6 @@ main() {
await openFile(mainFileUri, withoutMarkers(content));
final res = await getCompletion(mainFileUri, positionFromMarker(content));
final item = res.singleWhere((c) => c.label == 'abcdefghij');
// ignore: deprecated_member_use_from_same_package
expect(item.deprecated, isNull);
// If the does not say it supports the deprecated flag, we should show
// '(deprecated)' in the details.
@@ -467,7 +466,6 @@ main() {
await openFile(mainFileUri, withoutMarkers(content));
final res = await getCompletion(mainFileUri, positionFromMarker(content));
final item = res.singleWhere((c) => c.label == 'abcdefghij');
// ignore: deprecated_member_use_from_same_package
expect(item.deprecated, isTrue);
// If the client says it supports the deprecated flag, we should not show
// deprecated in the details.
@@ -327,9 +327,14 @@ void _writeDocCommentsAndAnnotations(
lines = _wrapLines(lines, (80 - 4 - buffer.totalIndent).clamp(0, 80));
lines.forEach((l) => buffer.writeIndentedln('/// $l'.trim()));
}
if (node.isDeprecated) {
buffer.writeIndentedln('@core.deprecated');
}
// Marking LSP-deprecated fields as deprecated in Dart results in a lot
// of warnings because we still often populate these fields for clients that
// may still be using them. This code is useful for enabling temporarily
// and reviewing which deprecated fields we should still support but isn't
// generally useful to keep enabled.
// if (node.isDeprecated) {
// buffer.writeIndentedln('@core.deprecated');
// }
}
void _writeEnumClass(IndentableStringBuffer buffer, Namespace namespace) {
@@ -379,6 +384,10 @@ void _writeEnumClass(IndentableStringBuffer buffer, Namespace namespace) {
..outdent()
..writeIndentedln('}');
namespace.members.whereType<Const>().forEach((cons) {
// We don't use any deprecated enum values, so ommit them entirely.
if (cons.isDeprecated) {
return;
}
_writeDocCommentsAndAnnotations(buffer, cons);
buffer.writeIndentedln(
'static const ${_makeValidIdentifier(cons.name)} = ${namespace.name}$constructorName(${cons.valueAsLiteral});');
@@ -73,7 +73,7 @@ final Uri specUri = Uri.parse(
/// Pattern to extract inline types from the `result: {xx, yy }` notes in the spec.
/// Doesn't parse past full stops as some of these have english sentences tagged on
/// the end that we don't want to parse.
final _resultsInlineTypesPattern = RegExp(r'''\* result:[^\.]*({.*})''');
final _resultsInlineTypesPattern = RegExp(r'''\* result:[^\.{}]*({[^\.`]*})''');
Future<void> downloadSpec() async {
final specResp = await http.get(specUri);
@@ -298,9 +298,10 @@ Future<String> readSpec() => File(localSpecPath).readAsString();
/// Returns whether a script block should be parsed or not.
bool shouldIncludeScriptBlock(String input) {
// We can't parse literal arrays, but this script block is just an example
// and not actually referenced anywhere.
if (input.trim() == r"export const EOL: string[] = ['\n', '\r\n', '\r'];") {
// Skip over some typescript blocks that are known sample code and not part
// of the LSP spec.
if (input.trim() == r"export const EOL: string[] = ['\n', '\r\n', '\r'];" ||
input.startsWith('textDocument.codeAction.resolveSupport =')) {
return false;
}
File diff suppressed because it is too large Load Diff
@@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
final _methodNamesPattern = RegExp(
r'''_(?:Notification|Request):?_:?(?:\r?\n)+\* method: '(.*?)',?\r?\n''',
r'''_(?:Notification|Request):?_:?(?:\r?\n)+\* method: ['`](.*?)[`'],?\r?\n''',
multiLine: true);
final _typeScriptBlockPattern =
RegExp(r'\B```typescript([\S\s]*?)\n```', multiLine: true);