[analysis_server] Update LSP generated classes to latest published version of the spec

No functional changes here but there have been some refactors inside the meta model that required some minor tweaks (URI moved from a type alias to string to a spec-defined base type).

I also improved the handling of some type references in the comments we bring in so they're clickable in more places.

Change-Id: I7c725d01b6d7bc0925979b8118dbfd8952f78724
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297482
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Danny Tuppeny 2023-04-24 15:09:20 +00:00 committed by Commit Queue
parent 3a5b06a9c3
commit d75a4e162e
7 changed files with 593 additions and 509 deletions

File diff suppressed because it is too large Load diff

View file

@ -452,7 +452,7 @@ void main() {
InitializeParamsClientInfo(name: 'server name', version: '1.2.3'),
rootPath: '!root',
capabilities: ClientCapabilities(),
trace: 'off',
trace: TraceValues.Off,
workspaceFolders: workspaceFolders,
);
final json = jsonEncode(obj);

View file

@ -37,7 +37,8 @@ bool enumClassAllowsAnyValue(String name) {
name != 'FailureHandlingKind' &&
name != 'InsertTextFormat' &&
name != 'MarkupKind' &&
name != 'ResourceOperationKind';
name != 'ResourceOperationKind' &&
name != 'TraceValues';
}
String generateDartForTypes(List<LspEntity> types) {

View file

@ -245,6 +245,14 @@ List<LspEntity> getCustomClasses() {
baseType: TypeReference('Uri'),
isRename: false,
),
// The LSP Spec uses "URI" but since that's fairly generic and will show up
// everywhere in code completion, we rename it to "LspUri" before using
// a typedef onto the Dart URI class.
TypeAlias(
name: 'URI',
baseType: TypeReference('LSPUri'),
isRename: true,
),
TypeAlias(
name: 'LSPUri',
baseType: TypeReference('Uri'),

File diff suppressed because it is too large Load diff

View file

@ -1,13 +1,13 @@
This license is for the lsp_meta_model.json file.
lsp_meta_model.license.txt downloaded from: https://microsoft.github.io/language-server-protocol/License.txt
lsp_meta_model.json downloaded from: https://raw.githubusercontent.com/microsoft/vscode-languageserver-node/main/protocol/metaModel.json
lsp_meta_model.json downloaded from: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/metaModel/metaModel.json
--
Copyright (c) Microsoft Corporation.
All rights reserved.
All rights reserved.
Distributed under the following terms:

View file

@ -23,8 +23,30 @@ class LspMetaModelCleaner {
/// level/line length without potentially introducing very short lines.
final _sourceCommentWrappingNewlinesPattern =
RegExp(r'[\w`\]\).]\n[\w`\[\(]');
/// A pattern matching the spec's older HTML links that we can extract type
/// references from.
///
/// A description of [SomeType[]] (#SomeType).
final _sourceCommentDocumentLinksPattern =
RegExp(r'\[([`\w \-.]+)\] ?\((#[^)]+)\)');
RegExp(r'\[`?([\w \-.]+)(?:\[\])?`?\]\s?\((#[^)]+)\)');
/// A pattern matching references in the LSP meta model comments that
/// reference other types.
///
/// {@link TypeName description}
///
/// Type names may have suffixes that shouldn't be included in the group such
/// as
///
/// {@link TypeName[] description}
final _sourceCommentReferencesPattern =
RegExp(r'{@link\s+([\w.]+)[\[\]]*(?:\s+[\w`. ]+[\[\]]*)?}');
/// A pattern that matches references in the LSP meta model comments to the
/// Thenable or Promise types.
final _sourceCommentThenablePromisePattern =
RegExp(r'\b(?:Thenable|Promise)\b');
/// Cleans an entire [LspMetaModel].
LspMetaModel cleanModel(LspMetaModel model) {
@ -86,11 +108,21 @@ class LspMetaModelCleaner {
(match) => match.group(0)!.replaceAll('\n', ' '),
);
// Strip any relative links that are intended for displaying online in the
// HTML spec.
// Replace any references to other types with a format that's valid for
// Dart.
text = text.replaceAllMapped(
_sourceCommentDocumentLinksPattern,
(match) => match.group(1)!,
(match) => '[${match.group(1)!}]',
);
text = text.replaceAllMapped(
_sourceCommentReferencesPattern,
(match) => '[${match.group(1)!}]',
);
// Replace any references to Thenable/Promise to Future.
text = text.replaceAllMapped(
_sourceCommentThenablePromisePattern,
(match) => '[Future]',
);
return text;