mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:59:47 +00:00
[analysis_server] Change LSP types to use Uri types instead of Strings
This requires some tweaks to to/from JSON code, and some handling for Maps that previously could be serialised directly but now may contain `Uri`s in keys and need to be converted to strings explicitly (since Uri has no toJson method). Change-Id: I61358d8198ac1da322fae98d6c40747ad08754b7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258927 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
13b5ca415f
commit
b3b2a1cebf
|
@ -16,9 +16,10 @@ import 'package:analysis_server/src/protocol/protocol_internal.dart';
|
|||
|
||||
const jsonEncoder = JsonEncoder.withIndent(' ');
|
||||
|
||||
typedef DocumentUri = String;
|
||||
typedef DocumentUri = Uri;
|
||||
typedef LSPAny = Object?;
|
||||
typedef LSPObject = Object;
|
||||
typedef LSPUri = Uri;
|
||||
typedef TextDocumentEditEdits
|
||||
= List<Either3<AnnotatedTextEdit, SnippetTextEdit, TextEdit>>;
|
||||
|
||||
|
@ -1217,7 +1218,7 @@ class PublishClosingLabelsParams implements ToJsonable {
|
|||
.map((item) => ClosingLabel.fromJson(item as Map<String, Object?>))
|
||||
.toList();
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
return PublishClosingLabelsParams(
|
||||
labels: labels,
|
||||
uri: uri,
|
||||
|
@ -1225,13 +1226,13 @@ class PublishClosingLabelsParams implements ToJsonable {
|
|||
}
|
||||
|
||||
final List<ClosingLabel> labels;
|
||||
final String uri;
|
||||
final Uri uri;
|
||||
|
||||
@override
|
||||
Map<String, Object?> toJson() {
|
||||
var result = <String, Object?>{};
|
||||
result['labels'] = labels.map((item) => item.toJson()).toList();
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1241,7 +1242,7 @@ class PublishClosingLabelsParams implements ToJsonable {
|
|||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
return _canParseString(obj, reporter, 'uri',
|
||||
return _canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false);
|
||||
} else {
|
||||
reporter.reportError('must be of type PublishClosingLabelsParams');
|
||||
|
@ -1283,7 +1284,7 @@ class PublishFlutterOutlineParams implements ToJsonable {
|
|||
final outline =
|
||||
FlutterOutline.fromJson(outlineJson as Map<String, Object?>);
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
return PublishFlutterOutlineParams(
|
||||
outline: outline,
|
||||
uri: uri,
|
||||
|
@ -1291,13 +1292,13 @@ class PublishFlutterOutlineParams implements ToJsonable {
|
|||
}
|
||||
|
||||
final FlutterOutline outline;
|
||||
final String uri;
|
||||
final Uri uri;
|
||||
|
||||
@override
|
||||
Map<String, Object?> toJson() {
|
||||
var result = <String, Object?>{};
|
||||
result['outline'] = outline.toJson();
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1307,7 +1308,7 @@ class PublishFlutterOutlineParams implements ToJsonable {
|
|||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
return _canParseString(obj, reporter, 'uri',
|
||||
return _canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false);
|
||||
} else {
|
||||
reporter.reportError('must be of type PublishFlutterOutlineParams');
|
||||
|
@ -1347,7 +1348,7 @@ class PublishOutlineParams implements ToJsonable {
|
|||
final outlineJson = json['outline'];
|
||||
final outline = Outline.fromJson(outlineJson as Map<String, Object?>);
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
return PublishOutlineParams(
|
||||
outline: outline,
|
||||
uri: uri,
|
||||
|
@ -1355,13 +1356,13 @@ class PublishOutlineParams implements ToJsonable {
|
|||
}
|
||||
|
||||
final Outline outline;
|
||||
final String uri;
|
||||
final Uri uri;
|
||||
|
||||
@override
|
||||
Map<String, Object?> toJson() {
|
||||
var result = <String, Object?>{};
|
||||
result['outline'] = outline.toJson();
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1371,7 +1372,7 @@ class PublishOutlineParams implements ToJsonable {
|
|||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
return _canParseString(obj, reporter, 'uri',
|
||||
return _canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false);
|
||||
} else {
|
||||
reporter.reportError('must be of type PublishOutlineParams');
|
||||
|
@ -2278,6 +2279,32 @@ bool _canParseString(
|
|||
return true;
|
||||
}
|
||||
|
||||
bool _canParseUri(
|
||||
Map<String, Object?> map, LspJsonReporter reporter, String fieldName,
|
||||
{required bool allowsUndefined, required bool allowsNull}) {
|
||||
reporter.push(fieldName);
|
||||
try {
|
||||
if (!allowsUndefined && !map.containsKey(fieldName)) {
|
||||
reporter.reportError('must not be undefined');
|
||||
return false;
|
||||
}
|
||||
final value = map[fieldName];
|
||||
final nullCheck = allowsNull || allowsUndefined;
|
||||
if (!nullCheck && value == null) {
|
||||
reporter.reportError('must not be null');
|
||||
return false;
|
||||
}
|
||||
if ((!nullCheck || value != null) &&
|
||||
(value is! String || Uri.tryParse(value) == null)) {
|
||||
reporter.reportError('must be of type Uri');
|
||||
return false;
|
||||
}
|
||||
} finally {
|
||||
reporter.pop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Either2<int, String> _eitherIntString(Object? value) {
|
||||
return value is int
|
||||
? Either2.t1(value)
|
||||
|
|
|
@ -115,11 +115,6 @@ typedef LSPArray = List<LSPAny>;
|
|||
/// @since 3.17.0
|
||||
typedef LspPattern = String;
|
||||
|
||||
/// A tagging type for string properties that are actually URIs
|
||||
///
|
||||
/// @since 3.16.0
|
||||
typedef LspUri = String;
|
||||
|
||||
/// A notebook document filter denotes a notebook document by different
|
||||
/// properties. The properties will be match against the notebook's URI (same as
|
||||
/// with documents)
|
||||
|
@ -1009,7 +1004,7 @@ class CallHierarchyItem implements ToJsonable {
|
|||
?.map((item) => SymbolTag.fromJson(item as int))
|
||||
.toList();
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
return CallHierarchyItem(
|
||||
data: data,
|
||||
detail: detail,
|
||||
|
@ -1065,7 +1060,7 @@ class CallHierarchyItem implements ToJsonable {
|
|||
if (tags != null) {
|
||||
result['tags'] = tags?.map((item) => item.toJson()).toList();
|
||||
}
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1095,7 +1090,7 @@ class CallHierarchyItem implements ToJsonable {
|
|||
allowsUndefined: true, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
return _canParseString(obj, reporter, 'uri',
|
||||
return _canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false);
|
||||
} else {
|
||||
reporter.reportError('must be of type CallHierarchyItem');
|
||||
|
@ -3045,25 +3040,25 @@ class CodeDescription implements ToJsonable {
|
|||
});
|
||||
static CodeDescription fromJson(Map<String, Object?> json) {
|
||||
final hrefJson = json['href'];
|
||||
final href = hrefJson as String;
|
||||
final href = Uri.parse(hrefJson as String);
|
||||
return CodeDescription(
|
||||
href: href,
|
||||
);
|
||||
}
|
||||
|
||||
/// An URI to open with more information about the diagnostic error.
|
||||
final LspUri href;
|
||||
final LSPUri href;
|
||||
|
||||
@override
|
||||
Map<String, Object?> toJson() {
|
||||
var result = <String, Object?>{};
|
||||
result['href'] = href;
|
||||
result['href'] = href.toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool canParse(Object? obj, LspJsonReporter reporter) {
|
||||
if (obj is Map<String, Object?>) {
|
||||
return _canParseString(obj, reporter, 'href',
|
||||
return _canParseUri(obj, reporter, 'href',
|
||||
allowsUndefined: false, allowsNull: false);
|
||||
} else {
|
||||
reporter.reportError('must be of type CodeDescription');
|
||||
|
@ -6403,7 +6398,7 @@ class CreateFile implements ResourceOperation, ToJsonable {
|
|||
? CreateFileOptions.fromJson(optionsJson as Map<String, Object?>)
|
||||
: null;
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
return CreateFile(
|
||||
annotationId: annotationId,
|
||||
kind: kind,
|
||||
|
@ -6438,7 +6433,7 @@ class CreateFile implements ResourceOperation, ToJsonable {
|
|||
if (options != null) {
|
||||
result['options'] = options?.toJson();
|
||||
}
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -6456,7 +6451,7 @@ class CreateFile implements ResourceOperation, ToJsonable {
|
|||
allowsUndefined: true, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
return _canParseString(obj, reporter, 'uri',
|
||||
return _canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false);
|
||||
} else {
|
||||
reporter.reportError('must be of type CreateFile');
|
||||
|
@ -7311,7 +7306,7 @@ class DeleteFile implements ResourceOperation, ToJsonable {
|
|||
? DeleteFileOptions.fromJson(optionsJson as Map<String, Object?>)
|
||||
: null;
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
return DeleteFile(
|
||||
annotationId: annotationId,
|
||||
kind: kind,
|
||||
|
@ -7346,7 +7341,7 @@ class DeleteFile implements ResourceOperation, ToJsonable {
|
|||
if (options != null) {
|
||||
result['options'] = options?.toJson();
|
||||
}
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -7364,7 +7359,7 @@ class DeleteFile implements ResourceOperation, ToJsonable {
|
|||
allowsUndefined: true, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
return _canParseString(obj, reporter, 'uri',
|
||||
return _canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false);
|
||||
} else {
|
||||
reporter.reportError('must be of type DeleteFile');
|
||||
|
@ -9699,7 +9694,7 @@ class DocumentDiagnosticReportPartialResult implements ToJsonable {
|
|||
final relatedDocumentsJson = json['relatedDocuments'];
|
||||
final relatedDocuments = (relatedDocumentsJson as Map<Object, Object?>).map(
|
||||
(key, value) => MapEntry(
|
||||
key as String,
|
||||
Uri.parse(key as String),
|
||||
_eitherFullDocumentDiagnosticReportUnchangedDocumentDiagnosticReport(
|
||||
value)));
|
||||
return DocumentDiagnosticReportPartialResult(
|
||||
|
@ -9715,13 +9710,14 @@ class DocumentDiagnosticReportPartialResult implements ToJsonable {
|
|||
@override
|
||||
Map<String, Object?> toJson() {
|
||||
var result = <String, Object?>{};
|
||||
result['relatedDocuments'] = relatedDocuments;
|
||||
result['relatedDocuments'] =
|
||||
relatedDocuments.map((key, value) => MapEntry(key.toString(), value));
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool canParse(Object? obj, LspJsonReporter reporter) {
|
||||
if (obj is Map<String, Object?>) {
|
||||
return _canParseMapStringFullDocumentDiagnosticReportUnchangedDocumentDiagnosticReport(
|
||||
return _canParseMapUriFullDocumentDiagnosticReportUnchangedDocumentDiagnosticReport(
|
||||
obj, reporter, 'relatedDocuments',
|
||||
allowsUndefined: false, allowsNull: false);
|
||||
} else {
|
||||
|
@ -12912,7 +12908,7 @@ class FileEvent implements ToJsonable {
|
|||
final typeJson = json['type'];
|
||||
final type = FileChangeType.fromJson(typeJson as int);
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
return FileEvent(
|
||||
type: type,
|
||||
uri: uri,
|
||||
|
@ -12929,7 +12925,7 @@ class FileEvent implements ToJsonable {
|
|||
Map<String, Object?> toJson() {
|
||||
var result = <String, Object?>{};
|
||||
result['type'] = type.toJson();
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -12939,7 +12935,7 @@ class FileEvent implements ToJsonable {
|
|||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
return _canParseString(obj, reporter, 'uri',
|
||||
return _canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false);
|
||||
} else {
|
||||
reporter.reportError('must be of type FileEvent');
|
||||
|
@ -15637,7 +15633,8 @@ class InitializeParams implements WorkDoneProgressParams, ToJsonable {
|
|||
final rootPathJson = json['rootPath'];
|
||||
final rootPath = rootPathJson as String?;
|
||||
final rootUriJson = json['rootUri'];
|
||||
final rootUri = rootUriJson as String?;
|
||||
final rootUri =
|
||||
rootUriJson != null ? Uri.parse(rootUriJson as String) : null;
|
||||
final traceJson = json['trace'];
|
||||
final trace = const {null, 'off', 'messages', 'compact', 'verbose'}
|
||||
.contains(traceJson)
|
||||
|
@ -15734,7 +15731,7 @@ class InitializeParams implements WorkDoneProgressParams, ToJsonable {
|
|||
if (rootPath != null) {
|
||||
result['rootPath'] = rootPath;
|
||||
}
|
||||
result['rootUri'] = rootUri;
|
||||
result['rootUri'] = rootUri?.toString();
|
||||
if (trace != null) {
|
||||
result['trace'] = trace;
|
||||
}
|
||||
|
@ -15770,7 +15767,7 @@ class InitializeParams implements WorkDoneProgressParams, ToJsonable {
|
|||
allowsUndefined: true, allowsNull: true)) {
|
||||
return false;
|
||||
}
|
||||
if (!_canParseString(obj, reporter, 'rootUri',
|
||||
if (!_canParseUri(obj, reporter, 'rootUri',
|
||||
allowsUndefined: false, allowsNull: true)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -18163,7 +18160,7 @@ class Location implements ToJsonable {
|
|||
final rangeJson = json['range'];
|
||||
final range = Range.fromJson(rangeJson as Map<String, Object?>);
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
return Location(
|
||||
range: range,
|
||||
uri: uri,
|
||||
|
@ -18177,7 +18174,7 @@ class Location implements ToJsonable {
|
|||
Map<String, Object?> toJson() {
|
||||
var result = <String, Object?>{};
|
||||
result['range'] = range.toJson();
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -18187,7 +18184,7 @@ class Location implements ToJsonable {
|
|||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
return _canParseString(obj, reporter, 'uri',
|
||||
return _canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false);
|
||||
} else {
|
||||
reporter.reportError('must be of type Location');
|
||||
|
@ -18239,7 +18236,7 @@ class LocationLink implements ToJsonable {
|
|||
final targetSelectionRange =
|
||||
Range.fromJson(targetSelectionRangeJson as Map<String, Object?>);
|
||||
final targetUriJson = json['targetUri'];
|
||||
final targetUri = targetUriJson as String;
|
||||
final targetUri = Uri.parse(targetUriJson as String);
|
||||
return LocationLink(
|
||||
originSelectionRange: originSelectionRange,
|
||||
targetRange: targetRange,
|
||||
|
@ -18276,7 +18273,7 @@ class LocationLink implements ToJsonable {
|
|||
}
|
||||
result['targetRange'] = targetRange.toJson();
|
||||
result['targetSelectionRange'] = targetSelectionRange.toJson();
|
||||
result['targetUri'] = targetUri;
|
||||
result['targetUri'] = targetUri.toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -18294,7 +18291,7 @@ class LocationLink implements ToJsonable {
|
|||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
return _canParseString(obj, reporter, 'targetUri',
|
||||
return _canParseUri(obj, reporter, 'targetUri',
|
||||
allowsUndefined: false, allowsNull: false);
|
||||
} else {
|
||||
reporter.reportError('must be of type LocationLink');
|
||||
|
@ -19558,7 +19555,7 @@ class NotebookCell implements ToJsonable {
|
|||
});
|
||||
static NotebookCell fromJson(Map<String, Object?> json) {
|
||||
final documentJson = json['document'];
|
||||
final document = documentJson as String;
|
||||
final document = Uri.parse(documentJson as String);
|
||||
final executionSummaryJson = json['executionSummary'];
|
||||
final executionSummary = executionSummaryJson != null
|
||||
? ExecutionSummary.fromJson(
|
||||
|
@ -19593,7 +19590,7 @@ class NotebookCell implements ToJsonable {
|
|||
@override
|
||||
Map<String, Object?> toJson() {
|
||||
var result = <String, Object?>{};
|
||||
result['document'] = document;
|
||||
result['document'] = document.toString();
|
||||
if (executionSummary != null) {
|
||||
result['executionSummary'] = executionSummary?.toJson();
|
||||
}
|
||||
|
@ -19606,7 +19603,7 @@ class NotebookCell implements ToJsonable {
|
|||
|
||||
static bool canParse(Object? obj, LspJsonReporter reporter) {
|
||||
if (obj is Map<String, Object?>) {
|
||||
if (!_canParseString(obj, reporter, 'document',
|
||||
if (!_canParseUri(obj, reporter, 'document',
|
||||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -19875,7 +19872,7 @@ class NotebookDocument implements ToJsonable {
|
|||
final notebookTypeJson = json['notebookType'];
|
||||
final notebookType = notebookTypeJson as String;
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
final versionJson = json['version'];
|
||||
final version = versionJson as int;
|
||||
return NotebookDocument(
|
||||
|
@ -19899,7 +19896,7 @@ class NotebookDocument implements ToJsonable {
|
|||
final String notebookType;
|
||||
|
||||
/// The notebook document's uri.
|
||||
final LspUri uri;
|
||||
final LSPUri uri;
|
||||
|
||||
/// The version number of this document (it will increase after each change,
|
||||
/// including undo/redo).
|
||||
|
@ -19913,7 +19910,7 @@ class NotebookDocument implements ToJsonable {
|
|||
result['metadata'] = metadata;
|
||||
}
|
||||
result['notebookType'] = notebookType;
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
result['version'] = version;
|
||||
return result;
|
||||
}
|
||||
|
@ -19932,7 +19929,7 @@ class NotebookDocument implements ToJsonable {
|
|||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
if (!_canParseString(obj, reporter, 'uri',
|
||||
if (!_canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -20654,25 +20651,25 @@ class NotebookDocumentIdentifier implements ToJsonable {
|
|||
});
|
||||
static NotebookDocumentIdentifier fromJson(Map<String, Object?> json) {
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
return NotebookDocumentIdentifier(
|
||||
uri: uri,
|
||||
);
|
||||
}
|
||||
|
||||
/// The notebook document's uri.
|
||||
final LspUri uri;
|
||||
final LSPUri uri;
|
||||
|
||||
@override
|
||||
Map<String, Object?> toJson() {
|
||||
var result = <String, Object?>{};
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool canParse(Object? obj, LspJsonReporter reporter) {
|
||||
if (obj is Map<String, Object?>) {
|
||||
return _canParseString(obj, reporter, 'uri',
|
||||
return _canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false);
|
||||
} else {
|
||||
reporter.reportError('must be of type NotebookDocumentIdentifier');
|
||||
|
@ -21280,7 +21277,7 @@ class OptionalVersionedTextDocumentIdentifier
|
|||
static OptionalVersionedTextDocumentIdentifier fromJson(
|
||||
Map<String, Object?> json) {
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
final versionJson = json['version'];
|
||||
final version = versionJson as int?;
|
||||
return OptionalVersionedTextDocumentIdentifier(
|
||||
|
@ -21304,14 +21301,14 @@ class OptionalVersionedTextDocumentIdentifier
|
|||
@override
|
||||
Map<String, Object?> toJson() {
|
||||
var result = <String, Object?>{};
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
result['version'] = version;
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool canParse(Object? obj, LspJsonReporter reporter) {
|
||||
if (obj is Map<String, Object?>) {
|
||||
if (!_canParseString(obj, reporter, 'uri',
|
||||
if (!_canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -21946,7 +21943,7 @@ class PreviousResultId implements ToJsonable {
|
|||
});
|
||||
static PreviousResultId fromJson(Map<String, Object?> json) {
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
final valueJson = json['value'];
|
||||
final value = valueJson as String;
|
||||
return PreviousResultId(
|
||||
|
@ -21964,14 +21961,14 @@ class PreviousResultId implements ToJsonable {
|
|||
@override
|
||||
Map<String, Object?> toJson() {
|
||||
var result = <String, Object?>{};
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
result['value'] = value;
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool canParse(Object? obj, LspJsonReporter reporter) {
|
||||
if (obj is Map<String, Object?>) {
|
||||
if (!_canParseString(obj, reporter, 'uri',
|
||||
if (!_canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -22276,7 +22273,7 @@ class PublishDiagnosticsParams implements ToJsonable {
|
|||
.map((item) => Diagnostic.fromJson(item as Map<String, Object?>))
|
||||
.toList();
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
final versionJson = json['version'];
|
||||
final version = versionJson as int?;
|
||||
return PublishDiagnosticsParams(
|
||||
|
@ -22302,7 +22299,7 @@ class PublishDiagnosticsParams implements ToJsonable {
|
|||
Map<String, Object?> toJson() {
|
||||
var result = <String, Object?>{};
|
||||
result['diagnostics'] = diagnostics.map((item) => item.toJson()).toList();
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
if (version != null) {
|
||||
result['version'] = version;
|
||||
}
|
||||
|
@ -22315,7 +22312,7 @@ class PublishDiagnosticsParams implements ToJsonable {
|
|||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
if (!_canParseString(obj, reporter, 'uri',
|
||||
if (!_canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -23040,7 +23037,7 @@ class RelatedFullDocumentDiagnosticReport
|
|||
final relatedDocumentsJson = json['relatedDocuments'];
|
||||
final relatedDocuments = (relatedDocumentsJson as Map<Object, Object?>?)
|
||||
?.map((key, value) => MapEntry(
|
||||
key as String,
|
||||
Uri.parse(key as String),
|
||||
_eitherFullDocumentDiagnosticReportUnchangedDocumentDiagnosticReport(
|
||||
value)));
|
||||
final resultIdJson = json['resultId'];
|
||||
|
@ -23084,7 +23081,8 @@ class RelatedFullDocumentDiagnosticReport
|
|||
result['items'] = items.map((item) => item.toJson()).toList();
|
||||
result['kind'] = kind;
|
||||
if (relatedDocuments != null) {
|
||||
result['relatedDocuments'] = relatedDocuments;
|
||||
result['relatedDocuments'] = relatedDocuments
|
||||
?.map((key, value) => MapEntry(key.toString(), value));
|
||||
}
|
||||
if (resultId != null) {
|
||||
result['resultId'] = resultId;
|
||||
|
@ -23102,7 +23100,7 @@ class RelatedFullDocumentDiagnosticReport
|
|||
allowsUndefined: false, allowsNull: false, literal: 'full')) {
|
||||
return false;
|
||||
}
|
||||
if (!_canParseMapStringFullDocumentDiagnosticReportUnchangedDocumentDiagnosticReport(
|
||||
if (!_canParseMapUriFullDocumentDiagnosticReportUnchangedDocumentDiagnosticReport(
|
||||
obj, reporter, 'relatedDocuments',
|
||||
allowsUndefined: true, allowsNull: false)) {
|
||||
return false;
|
||||
|
@ -23173,7 +23171,7 @@ class RelatedUnchangedDocumentDiagnosticReport
|
|||
final relatedDocumentsJson = json['relatedDocuments'];
|
||||
final relatedDocuments = (relatedDocumentsJson as Map<Object, Object?>?)
|
||||
?.map((key, value) => MapEntry(
|
||||
key as String,
|
||||
Uri.parse(key as String),
|
||||
_eitherFullDocumentDiagnosticReportUnchangedDocumentDiagnosticReport(
|
||||
value)));
|
||||
final resultIdJson = json['resultId'];
|
||||
|
@ -23212,7 +23210,8 @@ class RelatedUnchangedDocumentDiagnosticReport
|
|||
var result = <String, Object?>{};
|
||||
result['kind'] = kind;
|
||||
if (relatedDocuments != null) {
|
||||
result['relatedDocuments'] = relatedDocuments;
|
||||
result['relatedDocuments'] = relatedDocuments
|
||||
?.map((key, value) => MapEntry(key.toString(), value));
|
||||
}
|
||||
result['resultId'] = resultId;
|
||||
return result;
|
||||
|
@ -23224,7 +23223,7 @@ class RelatedUnchangedDocumentDiagnosticReport
|
|||
allowsUndefined: false, allowsNull: false, literal: 'unchanged')) {
|
||||
return false;
|
||||
}
|
||||
if (!_canParseMapStringFullDocumentDiagnosticReportUnchangedDocumentDiagnosticReport(
|
||||
if (!_canParseMapUriFullDocumentDiagnosticReportUnchangedDocumentDiagnosticReport(
|
||||
obj, reporter, 'relatedDocuments',
|
||||
allowsUndefined: true, allowsNull: false)) {
|
||||
return false;
|
||||
|
@ -23284,7 +23283,7 @@ class RelativePattern implements ToJsonable {
|
|||
});
|
||||
static RelativePattern fromJson(Map<String, Object?> json) {
|
||||
final baseUriJson = json['baseUri'];
|
||||
final baseUri = _eitherStringWorkspaceFolder(baseUriJson);
|
||||
final baseUri = _eitherUriWorkspaceFolder(baseUriJson);
|
||||
final patternJson = json['pattern'];
|
||||
final pattern = patternJson as String;
|
||||
return RelativePattern(
|
||||
|
@ -23295,7 +23294,7 @@ class RelativePattern implements ToJsonable {
|
|||
|
||||
/// A workspace folder or a base URI to which this pattern will be matched
|
||||
/// against relatively.
|
||||
final Either2<LspUri, WorkspaceFolder> baseUri;
|
||||
final Either2<LSPUri, WorkspaceFolder> baseUri;
|
||||
|
||||
/// The actual glob pattern;
|
||||
final LspPattern pattern;
|
||||
|
@ -23310,7 +23309,7 @@ class RelativePattern implements ToJsonable {
|
|||
|
||||
static bool canParse(Object? obj, LspJsonReporter reporter) {
|
||||
if (obj is Map<String, Object?>) {
|
||||
if (!_canParseStringWorkspaceFolder(obj, reporter, 'baseUri',
|
||||
if (!_canParseUriWorkspaceFolder(obj, reporter, 'baseUri',
|
||||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -23486,9 +23485,9 @@ class RenameFile implements ResourceOperation, ToJsonable {
|
|||
final kindJson = json['kind'];
|
||||
final kind = kindJson as String;
|
||||
final newUriJson = json['newUri'];
|
||||
final newUri = newUriJson as String;
|
||||
final newUri = Uri.parse(newUriJson as String);
|
||||
final oldUriJson = json['oldUri'];
|
||||
final oldUri = oldUriJson as String;
|
||||
final oldUri = Uri.parse(oldUriJson as String);
|
||||
final optionsJson = json['options'];
|
||||
final options = optionsJson != null
|
||||
? RenameFileOptions.fromJson(optionsJson as Map<String, Object?>)
|
||||
|
@ -23528,8 +23527,8 @@ class RenameFile implements ResourceOperation, ToJsonable {
|
|||
result['annotationId'] = annotationId;
|
||||
}
|
||||
result['kind'] = kind;
|
||||
result['newUri'] = newUri;
|
||||
result['oldUri'] = oldUri;
|
||||
result['newUri'] = newUri.toString();
|
||||
result['oldUri'] = oldUri.toString();
|
||||
if (options != null) {
|
||||
result['options'] = options?.toJson();
|
||||
}
|
||||
|
@ -23546,11 +23545,11 @@ class RenameFile implements ResourceOperation, ToJsonable {
|
|||
allowsUndefined: false, allowsNull: false, literal: 'rename')) {
|
||||
return false;
|
||||
}
|
||||
if (!_canParseString(obj, reporter, 'newUri',
|
||||
if (!_canParseUri(obj, reporter, 'newUri',
|
||||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
if (!_canParseString(obj, reporter, 'oldUri',
|
||||
if (!_canParseUri(obj, reporter, 'oldUri',
|
||||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -27158,7 +27157,7 @@ class ShowDocumentParams implements ToJsonable {
|
|||
final takeFocusJson = json['takeFocus'];
|
||||
final takeFocus = takeFocusJson as bool?;
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
return ShowDocumentParams(
|
||||
external: external,
|
||||
selection: selection,
|
||||
|
@ -27183,7 +27182,7 @@ class ShowDocumentParams implements ToJsonable {
|
|||
final bool? takeFocus;
|
||||
|
||||
/// The document uri to show.
|
||||
final LspUri uri;
|
||||
final LSPUri uri;
|
||||
|
||||
@override
|
||||
Map<String, Object?> toJson() {
|
||||
|
@ -27197,7 +27196,7 @@ class ShowDocumentParams implements ToJsonable {
|
|||
if (takeFocus != null) {
|
||||
result['takeFocus'] = takeFocus;
|
||||
}
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -27215,7 +27214,7 @@ class ShowDocumentParams implements ToJsonable {
|
|||
allowsUndefined: true, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
return _canParseString(obj, reporter, 'uri',
|
||||
return _canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false);
|
||||
} else {
|
||||
reporter.reportError('must be of type ShowDocumentParams');
|
||||
|
@ -30105,7 +30104,7 @@ class TextDocumentIdentifier implements ToJsonable {
|
|||
return OptionalVersionedTextDocumentIdentifier.fromJson(json);
|
||||
}
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
return TextDocumentIdentifier(
|
||||
uri: uri,
|
||||
);
|
||||
|
@ -30117,13 +30116,13 @@ class TextDocumentIdentifier implements ToJsonable {
|
|||
@override
|
||||
Map<String, Object?> toJson() {
|
||||
var result = <String, Object?>{};
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool canParse(Object? obj, LspJsonReporter reporter) {
|
||||
if (obj is Map<String, Object?>) {
|
||||
return _canParseString(obj, reporter, 'uri',
|
||||
return _canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false);
|
||||
} else {
|
||||
reporter.reportError('must be of type TextDocumentIdentifier');
|
||||
|
@ -30164,7 +30163,7 @@ class TextDocumentItem implements ToJsonable {
|
|||
final textJson = json['text'];
|
||||
final text = textJson as String;
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
final versionJson = json['version'];
|
||||
final version = versionJson as int;
|
||||
return TextDocumentItem(
|
||||
|
@ -30193,7 +30192,7 @@ class TextDocumentItem implements ToJsonable {
|
|||
var result = <String, Object?>{};
|
||||
result['languageId'] = languageId;
|
||||
result['text'] = text;
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
result['version'] = version;
|
||||
return result;
|
||||
}
|
||||
|
@ -30208,7 +30207,7 @@ class TextDocumentItem implements ToJsonable {
|
|||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
if (!_canParseString(obj, reporter, 'uri',
|
||||
if (!_canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -31466,7 +31465,7 @@ class TypeHierarchyItem implements ToJsonable {
|
|||
?.map((item) => SymbolTag.fromJson(item as int))
|
||||
.toList();
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
return TypeHierarchyItem(
|
||||
data: data,
|
||||
detail: detail,
|
||||
|
@ -31524,7 +31523,7 @@ class TypeHierarchyItem implements ToJsonable {
|
|||
if (tags != null) {
|
||||
result['tags'] = tags?.map((item) => item.toJson()).toList();
|
||||
}
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -31554,7 +31553,7 @@ class TypeHierarchyItem implements ToJsonable {
|
|||
allowsUndefined: true, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
return _canParseString(obj, reporter, 'uri',
|
||||
return _canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false);
|
||||
} else {
|
||||
reporter.reportError('must be of type TypeHierarchyItem');
|
||||
|
@ -32299,7 +32298,7 @@ class VersionedNotebookDocumentIdentifier implements ToJsonable {
|
|||
static VersionedNotebookDocumentIdentifier fromJson(
|
||||
Map<String, Object?> json) {
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
final versionJson = json['version'];
|
||||
final version = versionJson as int;
|
||||
return VersionedNotebookDocumentIdentifier(
|
||||
|
@ -32309,7 +32308,7 @@ class VersionedNotebookDocumentIdentifier implements ToJsonable {
|
|||
}
|
||||
|
||||
/// The notebook document's uri.
|
||||
final LspUri uri;
|
||||
final LSPUri uri;
|
||||
|
||||
/// The version number of this notebook document.
|
||||
final int version;
|
||||
|
@ -32317,14 +32316,14 @@ class VersionedNotebookDocumentIdentifier implements ToJsonable {
|
|||
@override
|
||||
Map<String, Object?> toJson() {
|
||||
var result = <String, Object?>{};
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
result['version'] = version;
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool canParse(Object? obj, LspJsonReporter reporter) {
|
||||
if (obj is Map<String, Object?>) {
|
||||
if (!_canParseString(obj, reporter, 'uri',
|
||||
if (!_canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -32369,7 +32368,7 @@ class VersionedTextDocumentIdentifier
|
|||
});
|
||||
static VersionedTextDocumentIdentifier fromJson(Map<String, Object?> json) {
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
final versionJson = json['version'];
|
||||
final version = versionJson as int;
|
||||
return VersionedTextDocumentIdentifier(
|
||||
|
@ -32388,14 +32387,14 @@ class VersionedTextDocumentIdentifier
|
|||
@override
|
||||
Map<String, Object?> toJson() {
|
||||
var result = <String, Object?>{};
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
result['version'] = version;
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool canParse(Object? obj, LspJsonReporter reporter) {
|
||||
if (obj is Map<String, Object?>) {
|
||||
if (!_canParseString(obj, reporter, 'uri',
|
||||
if (!_canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -33970,7 +33969,7 @@ class WorkspaceEdit implements ToJsonable {
|
|||
final changesJson = json['changes'];
|
||||
final changes = (changesJson as Map<Object, Object?>?)?.map((key, value) =>
|
||||
MapEntry(
|
||||
key as String,
|
||||
Uri.parse(key as String),
|
||||
(value as List<Object?>)
|
||||
.map((item) => TextEdit.fromJson(item as Map<String, Object?>))
|
||||
.toList()));
|
||||
|
@ -34021,7 +34020,8 @@ class WorkspaceEdit implements ToJsonable {
|
|||
result['changeAnnotations'] = changeAnnotations;
|
||||
}
|
||||
if (changes != null) {
|
||||
result['changes'] = changes;
|
||||
result['changes'] = changes?.map((key, value) => MapEntry(
|
||||
key.toString(), value.map((item) => item.toJson()).toList()));
|
||||
}
|
||||
if (documentChanges != null) {
|
||||
result['documentChanges'] = documentChanges;
|
||||
|
@ -34036,7 +34036,7 @@ class WorkspaceEdit implements ToJsonable {
|
|||
allowsUndefined: true, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
if (!_canParseMapStringListTextEdit(obj, reporter, 'changes',
|
||||
if (!_canParseMapUriListTextEdit(obj, reporter, 'changes',
|
||||
allowsUndefined: true, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -34299,7 +34299,7 @@ class WorkspaceFolder implements ToJsonable {
|
|||
final nameJson = json['name'];
|
||||
final name = nameJson as String;
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
return WorkspaceFolder(
|
||||
name: name,
|
||||
uri: uri,
|
||||
|
@ -34311,13 +34311,13 @@ class WorkspaceFolder implements ToJsonable {
|
|||
final String name;
|
||||
|
||||
/// The associated URI for this workspace folder.
|
||||
final LspUri uri;
|
||||
final LSPUri uri;
|
||||
|
||||
@override
|
||||
Map<String, Object?> toJson() {
|
||||
var result = <String, Object?>{};
|
||||
result['name'] = name;
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -34327,7 +34327,7 @@ class WorkspaceFolder implements ToJsonable {
|
|||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
return _canParseString(obj, reporter, 'uri',
|
||||
return _canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false);
|
||||
} else {
|
||||
reporter.reportError('must be of type WorkspaceFolder');
|
||||
|
@ -34539,7 +34539,7 @@ class WorkspaceFullDocumentDiagnosticReport
|
|||
final resultIdJson = json['resultId'];
|
||||
final resultId = resultIdJson as String?;
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
final versionJson = json['version'];
|
||||
final version = versionJson as int?;
|
||||
return WorkspaceFullDocumentDiagnosticReport(
|
||||
|
@ -34579,7 +34579,7 @@ class WorkspaceFullDocumentDiagnosticReport
|
|||
if (resultId != null) {
|
||||
result['resultId'] = resultId;
|
||||
}
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
result['version'] = version;
|
||||
return result;
|
||||
}
|
||||
|
@ -34598,7 +34598,7 @@ class WorkspaceFullDocumentDiagnosticReport
|
|||
allowsUndefined: true, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
if (!_canParseString(obj, reporter, 'uri',
|
||||
if (!_canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -35090,7 +35090,7 @@ class WorkspaceSymbolLocation implements ToJsonable {
|
|||
});
|
||||
static WorkspaceSymbolLocation fromJson(Map<String, Object?> json) {
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
return WorkspaceSymbolLocation(
|
||||
uri: uri,
|
||||
);
|
||||
|
@ -35101,13 +35101,13 @@ class WorkspaceSymbolLocation implements ToJsonable {
|
|||
@override
|
||||
Map<String, Object?> toJson() {
|
||||
var result = <String, Object?>{};
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool canParse(Object? obj, LspJsonReporter reporter) {
|
||||
if (obj is Map<String, Object?>) {
|
||||
return _canParseString(obj, reporter, 'uri',
|
||||
return _canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false);
|
||||
} else {
|
||||
reporter.reportError('must be of type WorkspaceSymbolLocation');
|
||||
|
@ -35406,7 +35406,7 @@ class WorkspaceUnchangedDocumentDiagnosticReport
|
|||
final resultIdJson = json['resultId'];
|
||||
final resultId = resultIdJson as String;
|
||||
final uriJson = json['uri'];
|
||||
final uri = uriJson as String;
|
||||
final uri = Uri.parse(uriJson as String);
|
||||
final versionJson = json['version'];
|
||||
final version = versionJson as int?;
|
||||
return WorkspaceUnchangedDocumentDiagnosticReport(
|
||||
|
@ -35439,7 +35439,7 @@ class WorkspaceUnchangedDocumentDiagnosticReport
|
|||
var result = <String, Object?>{};
|
||||
result['kind'] = kind;
|
||||
result['resultId'] = resultId;
|
||||
result['uri'] = uri;
|
||||
result['uri'] = uri.toString();
|
||||
result['version'] = version;
|
||||
return result;
|
||||
}
|
||||
|
@ -35454,7 +35454,7 @@ class WorkspaceUnchangedDocumentDiagnosticReport
|
|||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
if (!_canParseString(obj, reporter, 'uri',
|
||||
if (!_canParseUri(obj, reporter, 'uri',
|
||||
allowsUndefined: false, allowsNull: false)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -40201,7 +40201,7 @@ bool _canParseMapStringChangeAnnotation(
|
|||
}
|
||||
|
||||
bool
|
||||
_canParseMapStringFullDocumentDiagnosticReportUnchangedDocumentDiagnosticReport(
|
||||
_canParseMapUriFullDocumentDiagnosticReportUnchangedDocumentDiagnosticReport(
|
||||
Map<String, Object?> map, LspJsonReporter reporter, String fieldName,
|
||||
{required bool allowsUndefined, required bool allowsNull}) {
|
||||
reporter.push(fieldName);
|
||||
|
@ -40219,7 +40219,7 @@ bool
|
|||
if ((!nullCheck || value != null) &&
|
||||
(value is! Map ||
|
||||
(value.keys.any((item) =>
|
||||
item is! String ||
|
||||
(item is! String || Uri.tryParse(item) == null) ||
|
||||
value.values.any((item) =>
|
||||
!FullDocumentDiagnosticReport.canParse(item, reporter) &&
|
||||
!UnchangedDocumentDiagnosticReport.canParse(
|
||||
|
@ -40234,7 +40234,7 @@ bool
|
|||
return true;
|
||||
}
|
||||
|
||||
bool _canParseMapStringListTextEdit(
|
||||
bool _canParseMapUriListTextEdit(
|
||||
Map<String, Object?> map, LspJsonReporter reporter, String fieldName,
|
||||
{required bool allowsUndefined, required bool allowsNull}) {
|
||||
reporter.push(fieldName);
|
||||
|
@ -40252,7 +40252,7 @@ bool _canParseMapStringListTextEdit(
|
|||
if ((!nullCheck || value != null) &&
|
||||
(value is! Map ||
|
||||
(value.keys.any((item) =>
|
||||
item is! String ||
|
||||
(item is! String || Uri.tryParse(item) == null) ||
|
||||
value.values.any((item) =>
|
||||
item is! List<Object?> ||
|
||||
item.any(
|
||||
|
@ -41641,32 +41641,6 @@ bool _canParseStringRelativePattern(
|
|||
return true;
|
||||
}
|
||||
|
||||
bool _canParseStringWorkspaceFolder(
|
||||
Map<String, Object?> map, LspJsonReporter reporter, String fieldName,
|
||||
{required bool allowsUndefined, required bool allowsNull}) {
|
||||
reporter.push(fieldName);
|
||||
try {
|
||||
if (!allowsUndefined && !map.containsKey(fieldName)) {
|
||||
reporter.reportError('must not be undefined');
|
||||
return false;
|
||||
}
|
||||
final value = map[fieldName];
|
||||
final nullCheck = allowsNull || allowsUndefined;
|
||||
if (!nullCheck && value == null) {
|
||||
reporter.reportError('must not be null');
|
||||
return false;
|
||||
}
|
||||
if ((!nullCheck || value != null) &&
|
||||
(value is! String && !WorkspaceFolder.canParse(value, reporter))) {
|
||||
reporter.reportError('must be of type Either2<LspUri, WorkspaceFolder>');
|
||||
return false;
|
||||
}
|
||||
} finally {
|
||||
reporter.pop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _canParseSymbolKind(
|
||||
Map<String, Object?> map, LspJsonReporter reporter, String fieldName,
|
||||
{required bool allowsUndefined, required bool allowsNull}) {
|
||||
|
@ -42033,6 +42007,59 @@ bool _canParseUniquenessLevel(
|
|||
return true;
|
||||
}
|
||||
|
||||
bool _canParseUri(
|
||||
Map<String, Object?> map, LspJsonReporter reporter, String fieldName,
|
||||
{required bool allowsUndefined, required bool allowsNull}) {
|
||||
reporter.push(fieldName);
|
||||
try {
|
||||
if (!allowsUndefined && !map.containsKey(fieldName)) {
|
||||
reporter.reportError('must not be undefined');
|
||||
return false;
|
||||
}
|
||||
final value = map[fieldName];
|
||||
final nullCheck = allowsNull || allowsUndefined;
|
||||
if (!nullCheck && value == null) {
|
||||
reporter.reportError('must not be null');
|
||||
return false;
|
||||
}
|
||||
if ((!nullCheck || value != null) &&
|
||||
(value is! String || Uri.tryParse(value) == null)) {
|
||||
reporter.reportError('must be of type Uri');
|
||||
return false;
|
||||
}
|
||||
} finally {
|
||||
reporter.pop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _canParseUriWorkspaceFolder(
|
||||
Map<String, Object?> map, LspJsonReporter reporter, String fieldName,
|
||||
{required bool allowsUndefined, required bool allowsNull}) {
|
||||
reporter.push(fieldName);
|
||||
try {
|
||||
if (!allowsUndefined && !map.containsKey(fieldName)) {
|
||||
reporter.reportError('must not be undefined');
|
||||
return false;
|
||||
}
|
||||
final value = map[fieldName];
|
||||
final nullCheck = allowsNull || allowsUndefined;
|
||||
if (!nullCheck && value == null) {
|
||||
reporter.reportError('must not be null');
|
||||
return false;
|
||||
}
|
||||
if ((!nullCheck || value != null) &&
|
||||
((value is! String || Uri.tryParse(value) == null) &&
|
||||
!WorkspaceFolder.canParse(value, reporter))) {
|
||||
reporter.reportError('must be of type Either2<LSPUri, WorkspaceFolder>');
|
||||
return false;
|
||||
}
|
||||
} finally {
|
||||
reporter.pop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _canParseVersionedNotebookDocumentIdentifier(
|
||||
Map<String, Object?> map, LspJsonReporter reporter, String fieldName,
|
||||
{required bool allowsUndefined, required bool allowsNull}) {
|
||||
|
@ -42910,14 +42937,6 @@ Either2<LspPattern, RelativePattern> _eitherStringRelativePattern(
|
|||
: throw '$value was not one of (LspPattern, RelativePattern)';
|
||||
}
|
||||
|
||||
Either2<LspUri, WorkspaceFolder> _eitherStringWorkspaceFolder(Object? value) {
|
||||
return value is String
|
||||
? Either2.t1(value)
|
||||
: WorkspaceFolder.canParse(value, nullLspJsonReporter)
|
||||
? Either2.t2(WorkspaceFolder.fromJson(value as Map<String, Object?>))
|
||||
: throw '$value was not one of (LspUri, WorkspaceFolder)';
|
||||
}
|
||||
|
||||
Either2<TextDocumentContentChangeEvent1, TextDocumentContentChangeEvent2>
|
||||
_eitherTextDocumentContentChangeEvent1TextDocumentContentChangeEvent2(
|
||||
Object? value) {
|
||||
|
@ -42940,6 +42959,14 @@ Either2<TextDocumentSyncKind, TextDocumentSyncOptions>
|
|||
: throw '$value was not one of (TextDocumentSyncKind, TextDocumentSyncOptions)';
|
||||
}
|
||||
|
||||
Either2<LSPUri, WorkspaceFolder> _eitherUriWorkspaceFolder(Object? value) {
|
||||
return (value is String && Uri.tryParse(value) != null)
|
||||
? Either2.t1(Uri.parse(value))
|
||||
: WorkspaceFolder.canParse(value, nullLspJsonReporter)
|
||||
? Either2.t2(WorkspaceFolder.fromJson(value as Map<String, Object?>))
|
||||
: throw '$value was not one of (LSPUri, WorkspaceFolder)';
|
||||
}
|
||||
|
||||
Either2<WorkspaceFullDocumentDiagnosticReport,
|
||||
WorkspaceUnchangedDocumentDiagnosticReport>
|
||||
_eitherWorkspaceFullDocumentDiagnosticReportWorkspaceUnchangedDocumentDiagnosticReport(
|
||||
|
|
|
@ -244,7 +244,7 @@ abstract class _AbstractCallHierarchyCallsHandler<P, R, C>
|
|||
}
|
||||
|
||||
final pos = item.selectionRange.start;
|
||||
final path = pathOfUri(Uri.parse(item.uri));
|
||||
final path = pathOfUri(item.uri);
|
||||
final unit = await path.mapResult(requireResolvedUnit);
|
||||
final offset = await unit.mapResult((unit) => toOffset(unit.lineInfo, pos));
|
||||
return offset.mapResult((offset) async {
|
||||
|
@ -373,7 +373,7 @@ mixin _CallHierarchyUtils {
|
|||
name: item.displayName,
|
||||
detail: item.containerName,
|
||||
kind: toSymbolKind(supportedSymbolKinds, item.kind),
|
||||
uri: Uri.file(item.file).toString(),
|
||||
uri: Uri.file(item.file),
|
||||
range: sourceRangeToRange(lineInfo, item.codeRange),
|
||||
selectionRange: sourceRangeToRange(lineInfo, item.nameRange),
|
||||
);
|
||||
|
@ -399,7 +399,7 @@ mixin _CallHierarchyUtils {
|
|||
displayName: item.name,
|
||||
containerName: item.detail,
|
||||
kind: fromSymbolKind(item.kind),
|
||||
file: Uri.parse(item.uri).toFilePath(),
|
||||
file: item.uri.toFilePath(),
|
||||
nameRange: nameRange.result,
|
||||
codeRange: codeRange.result,
|
||||
);
|
||||
|
|
|
@ -41,6 +41,6 @@ class WorkspaceFoldersHandler
|
|||
/// Return the result of converting the list of workspace [folders] to file
|
||||
/// paths.
|
||||
List<String> _convertWorkspaceFolders(List<WorkspaceFolder> folders) {
|
||||
return folders.map((wf) => Uri.parse(wf.uri).toFilePath()).toList();
|
||||
return folders.map((wf) => wf.uri.toFilePath()).toList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,9 +151,9 @@ class DefinitionHandler extends MessageHandler<TextDocumentPositionParams,
|
|||
/// line/location) generically, handling either type of Location class.
|
||||
List<T> _filterResults<T>(
|
||||
List<T> results,
|
||||
String sourceUri,
|
||||
Uri sourceUri,
|
||||
int sourceLineNumber,
|
||||
String Function(T) uriSelector,
|
||||
Uri Function(T) uriSelector,
|
||||
Range Function(T) rangeSelector,
|
||||
) {
|
||||
// If we fetch navigation on a keyword like `var`, the results will include
|
||||
|
|
|
@ -65,7 +65,7 @@ class DocumentSymbolHandler extends MessageHandler<DocumentSymbolParams,
|
|||
SymbolInformation? _asSymbolInformation(
|
||||
String? containerName,
|
||||
Set<SymbolKind> supportedKinds,
|
||||
String documentUri,
|
||||
Uri documentUri,
|
||||
LineInfo lineInfo,
|
||||
Outline outline,
|
||||
) {
|
||||
|
@ -112,7 +112,7 @@ class DocumentSymbolHandler extends MessageHandler<DocumentSymbolParams,
|
|||
} else {
|
||||
// Otherwise, we need to use the original flat SymbolInformation.
|
||||
final allSymbols = <SymbolInformation>[];
|
||||
final documentUri = Uri.file(path).toString();
|
||||
final documentUri = Uri.file(path);
|
||||
|
||||
// Adds a symbol and it's children recursively, supplying the parent
|
||||
// name as required by SymbolInformation.
|
||||
|
|
|
@ -93,7 +93,7 @@ class ImplementationHandler
|
|||
}
|
||||
|
||||
return Location(
|
||||
uri: Uri.file(elementLocation.file).toString(),
|
||||
uri: Uri.file(elementLocation.file),
|
||||
range: toRange(
|
||||
lineInfo, elementLocation.offset, elementLocation.length),
|
||||
);
|
||||
|
|
|
@ -39,7 +39,7 @@ class InitializeMessageHandler
|
|||
if (!server.initializationOptions.onlyAnalyzeProjectsWithOpenFiles) {
|
||||
if (workspaceFolders != null) {
|
||||
for (var wf in workspaceFolders) {
|
||||
final uri = Uri.parse(wf.uri);
|
||||
final uri = wf.uri;
|
||||
// Only file URIs are supported, but there's no way to signal this to
|
||||
// the LSP client (and certainly not before initialization).
|
||||
if (uri.isScheme('file')) {
|
||||
|
@ -48,9 +48,8 @@ class InitializeMessageHandler
|
|||
}
|
||||
}
|
||||
if (rootUri != null) {
|
||||
final uri = Uri.parse(rootUri);
|
||||
if (uri.isScheme('file')) {
|
||||
workspacePaths.add(uri.toFilePath());
|
||||
if (rootUri.isScheme('file')) {
|
||||
workspacePaths.add(rootUri.toFilePath());
|
||||
}
|
||||
} else if (rootPath != null) {
|
||||
workspacePaths.add(rootPath);
|
||||
|
|
|
@ -80,7 +80,7 @@ class ReferencesHandler
|
|||
return null;
|
||||
}
|
||||
return Location(
|
||||
uri: Uri.file(result.file).toString(),
|
||||
uri: Uri.file(result.file),
|
||||
range: toRange(
|
||||
file.lineInfo,
|
||||
result.sourceRange.offset,
|
||||
|
|
|
@ -123,7 +123,7 @@ class TypeDefinitionHandler extends MessageHandler<TypeDefinitionParams,
|
|||
/// Creates an LSP [Location] for the server [location].
|
||||
Location _toLocation(plugin.Location location, LineInfo lineInfo) {
|
||||
return Location(
|
||||
uri: Uri.file(location.file).toString(),
|
||||
uri: Uri.file(location.file),
|
||||
range: toRange(lineInfo, location.offset, location.length),
|
||||
);
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ class TypeDefinitionHandler extends MessageHandler<TypeDefinitionParams,
|
|||
return LocationLink(
|
||||
originSelectionRange:
|
||||
toRange(originLineInfo, originEntity.offset, originEntity.length),
|
||||
targetUri: Uri.file(targetLocation.file).toString(),
|
||||
targetUri: Uri.file(targetLocation.file),
|
||||
targetRange: codeRange,
|
||||
targetSelectionRange: nameRange,
|
||||
);
|
||||
|
|
|
@ -91,7 +91,7 @@ class WorkspaceSymbolHandler
|
|||
declaration.codeLength,
|
||||
);
|
||||
final location = Location(
|
||||
uri: Uri.file(filePath).toString(),
|
||||
uri: Uri.file(filePath),
|
||||
range: range,
|
||||
);
|
||||
|
||||
|
|
|
@ -308,8 +308,7 @@ class LspAnalysisServer extends AnalysisServer {
|
|||
OptionalVersionedTextDocumentIdentifier getVersionedDocumentIdentifier(
|
||||
String path) {
|
||||
return OptionalVersionedTextDocumentIdentifier(
|
||||
uri: Uri.file(path).toString(),
|
||||
version: documentVersions[path]?.version);
|
||||
uri: Uri.file(path), version: documentVersions[path]?.version);
|
||||
}
|
||||
|
||||
void handleClientConnection(
|
||||
|
@ -552,8 +551,8 @@ class LspAnalysisServer extends AnalysisServer {
|
|||
}
|
||||
|
||||
void publishClosingLabels(String path, List<ClosingLabel> labels) {
|
||||
final params = PublishClosingLabelsParams(
|
||||
uri: Uri.file(path).toString(), labels: labels);
|
||||
final params =
|
||||
PublishClosingLabelsParams(uri: Uri.file(path), labels: labels);
|
||||
final message = NotificationMessage(
|
||||
method: CustomMethods.publishClosingLabels,
|
||||
params: params,
|
||||
|
@ -563,8 +562,8 @@ class LspAnalysisServer extends AnalysisServer {
|
|||
}
|
||||
|
||||
void publishDiagnostics(String path, List<Diagnostic> errors) {
|
||||
final params = PublishDiagnosticsParams(
|
||||
uri: Uri.file(path).toString(), diagnostics: errors);
|
||||
final params =
|
||||
PublishDiagnosticsParams(uri: Uri.file(path), diagnostics: errors);
|
||||
final message = NotificationMessage(
|
||||
method: Method.textDocument_publishDiagnostics,
|
||||
params: params,
|
||||
|
@ -574,8 +573,8 @@ class LspAnalysisServer extends AnalysisServer {
|
|||
}
|
||||
|
||||
void publishFlutterOutline(String path, FlutterOutline outline) {
|
||||
final params = PublishFlutterOutlineParams(
|
||||
uri: Uri.file(path).toString(), outline: outline);
|
||||
final params =
|
||||
PublishFlutterOutlineParams(uri: Uri.file(path), outline: outline);
|
||||
final message = NotificationMessage(
|
||||
method: CustomMethods.publishFlutterOutline,
|
||||
params: params,
|
||||
|
@ -585,8 +584,7 @@ class LspAnalysisServer extends AnalysisServer {
|
|||
}
|
||||
|
||||
void publishOutline(String path, Outline outline) {
|
||||
final params =
|
||||
PublishOutlineParams(uri: Uri.file(path).toString(), outline: outline);
|
||||
final params = PublishOutlineParams(uri: Uri.file(path), outline: outline);
|
||||
final message = NotificationMessage(
|
||||
method: CustomMethods.publishOutline,
|
||||
params: params,
|
||||
|
|
|
@ -93,8 +93,8 @@ WorkspaceEdit createRenameEdit(String oldPath, String newPath) {
|
|||
<Either4<CreateFile, DeleteFile, RenameFile, TextDocumentEdit>>[];
|
||||
|
||||
final rename = RenameFile(
|
||||
oldUri: Uri.file(oldPath).toString(),
|
||||
newUri: Uri.file(newPath).toString(),
|
||||
oldUri: Uri.file(oldPath),
|
||||
newUri: Uri.file(newPath),
|
||||
);
|
||||
|
||||
final renameUnion =
|
||||
|
@ -426,7 +426,7 @@ List<lsp.DiagnosticTag>? getDiagnosticTags(
|
|||
|
||||
bool isDartDocument(lsp.TextDocumentIdentifier doc) => isDartUri(doc.uri);
|
||||
|
||||
bool isDartUri(String uri) => uri.endsWith('.dart');
|
||||
bool isDartUri(Uri uri) => uri.path.endsWith('.dart');
|
||||
|
||||
/// Converts a [server.Location] to an [lsp.Range] by translating the
|
||||
/// offset/length using a `LineInfo`.
|
||||
|
@ -480,7 +480,7 @@ lsp.Location navigationTargetToLocation(
|
|||
server.LineInfo targetLineInfo,
|
||||
) {
|
||||
return lsp.Location(
|
||||
uri: Uri.file(targetFilePath).toString(),
|
||||
uri: Uri.file(targetFilePath),
|
||||
range: toRange(targetLineInfo, target.offset, target.length),
|
||||
);
|
||||
}
|
||||
|
@ -501,19 +501,17 @@ lsp.LocationLink? navigationTargetToLocationLink(
|
|||
|
||||
return lsp.LocationLink(
|
||||
originSelectionRange: toRange(regionLineInfo, region.offset, region.length),
|
||||
targetUri: Uri.file(targetFilePath).toString(),
|
||||
targetUri: Uri.file(targetFilePath),
|
||||
targetRange: codeRange,
|
||||
targetSelectionRange: nameRange,
|
||||
);
|
||||
}
|
||||
|
||||
/// Returns the file system path for a TextDocumentIdentifier.
|
||||
ErrorOr<String> pathOfDoc(lsp.TextDocumentIdentifier doc) =>
|
||||
pathOfUri(Uri.tryParse(doc.uri));
|
||||
ErrorOr<String> pathOfDoc(lsp.TextDocumentIdentifier doc) => pathOfUri(doc.uri);
|
||||
|
||||
/// Returns the file system path for a TextDocumentItem.
|
||||
ErrorOr<String> pathOfDocItem(lsp.TextDocumentItem doc) =>
|
||||
pathOfUri(Uri.tryParse(doc.uri));
|
||||
ErrorOr<String> pathOfDocItem(lsp.TextDocumentItem doc) => pathOfUri(doc.uri);
|
||||
|
||||
/// Returns the file system path for a file URI.
|
||||
ErrorOr<String> pathOfUri(Uri? uri) {
|
||||
|
@ -597,7 +595,7 @@ lsp.Diagnostic pluginToDiagnostic(
|
|||
// Only include codeDescription if the client explicitly supports it
|
||||
// (a minor optimization to avoid unnecessary payload/(de)serialization).
|
||||
codeDescription: clientSupportsCodeDescription && documentationUrl != null
|
||||
? CodeDescription(href: documentationUrl)
|
||||
? CodeDescription(href: Uri.parse(documentationUrl))
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
@ -614,7 +612,7 @@ lsp.DiagnosticRelatedInformation? pluginToDiagnosticRelatedInformation(
|
|||
}
|
||||
return lsp.DiagnosticRelatedInformation(
|
||||
location: lsp.Location(
|
||||
uri: Uri.file(file).toString(),
|
||||
uri: Uri.file(file),
|
||||
// TODO(dantup): Switch to using line/col information from the context
|
||||
// message once confirmed that AnalyzerConverter is not using the wrong
|
||||
// LineInfo.
|
||||
|
@ -1118,7 +1116,7 @@ List<lsp.DocumentHighlight> toHighlights(
|
|||
|
||||
lsp.Location toLocation(server.Location location, server.LineInfo lineInfo) =>
|
||||
lsp.Location(
|
||||
uri: Uri.file(location.file).toString(),
|
||||
uri: Uri.file(location.file),
|
||||
range: toRange(
|
||||
lineInfo,
|
||||
location.offset,
|
||||
|
@ -1378,15 +1376,15 @@ lsp.WorkspaceEdit toWorkspaceEdit(
|
|||
}
|
||||
}
|
||||
|
||||
Map<String, List<lsp.TextEdit>> toWorkspaceEditChanges(
|
||||
Map<Uri, List<lsp.TextEdit>> toWorkspaceEditChanges(
|
||||
List<FileEditInformation> edits) {
|
||||
MapEntry<String, List<lsp.TextEdit>> createEdit(FileEditInformation file) {
|
||||
MapEntry<Uri, List<lsp.TextEdit>> createEdit(FileEditInformation file) {
|
||||
final edits =
|
||||
file.edits.map((edit) => toTextEdit(file.lineInfo, edit)).toList();
|
||||
return MapEntry(file.doc.uri, edits);
|
||||
}
|
||||
|
||||
return Map<String, List<lsp.TextEdit>>.fromEntries(edits.map(createEdit));
|
||||
return Map<Uri, List<lsp.TextEdit>>.fromEntries(edits.map(createEdit));
|
||||
}
|
||||
|
||||
lsp.MarkupContent _asMarkup(
|
||||
|
|
|
@ -38,7 +38,7 @@ class LspNotificationManager extends AbstractNotificationManager {
|
|||
.toList();
|
||||
|
||||
final params = PublishDiagnosticsParams(
|
||||
uri: Uri.file(filePath).toString(), diagnostics: diagnostics);
|
||||
uri: Uri.file(filePath), diagnostics: diagnostics);
|
||||
final message = NotificationMessage(
|
||||
method: Method.textDocument_publishDiagnostics,
|
||||
params: params,
|
||||
|
|
|
@ -40,7 +40,7 @@ void f() {
|
|||
expect(relatedInformation, hasLength(1));
|
||||
final relatedInfo = relatedInformation.first;
|
||||
expect(relatedInfo.message, equals("The declaration of 'x' is here."));
|
||||
expect(relatedInfo.location.uri, equals('$mainFileUri'));
|
||||
expect(relatedInfo.location.uri, equals(mainFileUri));
|
||||
expect(relatedInfo.location.range, equals(rangeFromMarkers(content)));
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ class IncomingCallHierarchyTest extends AbstractLspAnalysisServerTest {
|
|||
name: 'Bar',
|
||||
detail: 'other.dart',
|
||||
kind: SymbolKind.Class,
|
||||
uri: otherFileUri.toString(),
|
||||
uri: otherFileUri,
|
||||
range: rangeOfPattern(
|
||||
otherContents, RegExp(r'class Bar \{.*\}', dotAll: true)),
|
||||
selectionRange: rangeOfString(otherContents, 'Bar'),
|
||||
|
@ -111,7 +111,7 @@ class IncomingCallHierarchyTest extends AbstractLspAnalysisServerTest {
|
|||
name: 'other.dart',
|
||||
detail: null,
|
||||
kind: SymbolKind.File,
|
||||
uri: otherFileUri.toString(),
|
||||
uri: otherFileUri,
|
||||
range: entireRange(otherContents),
|
||||
selectionRange: startOfDocRange,
|
||||
),
|
||||
|
@ -147,7 +147,7 @@ class IncomingCallHierarchyTest extends AbstractLspAnalysisServerTest {
|
|||
name: 'main',
|
||||
detail: 'main.dart',
|
||||
kind: SymbolKind.Function,
|
||||
uri: mainFileUri.toString(),
|
||||
uri: mainFileUri,
|
||||
range: rangeOfPattern(
|
||||
contents, RegExp(r'void main\(\) \{.*\}', dotAll: true)),
|
||||
selectionRange: rangeOfString(contents, 'main'),
|
||||
|
@ -188,7 +188,7 @@ class IncomingCallHierarchyTest extends AbstractLspAnalysisServerTest {
|
|||
name: 'bar',
|
||||
detail: 'B',
|
||||
kind: SymbolKind.Method,
|
||||
uri: otherFileUri.toString(),
|
||||
uri: otherFileUri,
|
||||
range: rangeOfPattern(otherContents,
|
||||
RegExp(r'String bar\(\) \{.*\ }', dotAll: true)),
|
||||
selectionRange: rangeOfString(otherContents, 'bar'),
|
||||
|
@ -227,7 +227,7 @@ class IncomingCallHierarchyTest extends AbstractLspAnalysisServerTest {
|
|||
name: 'Bar',
|
||||
detail: 'other.dart',
|
||||
kind: SymbolKind.Class,
|
||||
uri: otherFileUri.toString(),
|
||||
uri: otherFileUri,
|
||||
range: rangeOfPattern(
|
||||
otherContents, RegExp(r'class Bar \{.*\}', dotAll: true)),
|
||||
selectionRange: rangeOfString(otherContents, 'Bar'),
|
||||
|
@ -304,7 +304,7 @@ class OutgoingCallHierarchyTest extends AbstractLspAnalysisServerTest {
|
|||
name: 'Bar',
|
||||
detail: 'Bar',
|
||||
kind: SymbolKind.Constructor,
|
||||
uri: otherFileUri.toString(),
|
||||
uri: otherFileUri,
|
||||
range: rangeOfString(otherContents, 'Bar();'),
|
||||
selectionRange:
|
||||
rangeStartingAtString(otherContents, 'Bar();', 'Bar'),
|
||||
|
@ -341,7 +341,7 @@ class OutgoingCallHierarchyTest extends AbstractLspAnalysisServerTest {
|
|||
name: 'bar',
|
||||
detail: 'other.dart',
|
||||
kind: SymbolKind.Function,
|
||||
uri: otherFileUri.toString(),
|
||||
uri: otherFileUri,
|
||||
range: rangeOfString(otherContents, 'void bar() {}'),
|
||||
selectionRange: rangeOfString(otherContents, 'bar'),
|
||||
),
|
||||
|
@ -379,7 +379,7 @@ class OutgoingCallHierarchyTest extends AbstractLspAnalysisServerTest {
|
|||
name: 'Bar',
|
||||
detail: 'Bar',
|
||||
kind: SymbolKind.Constructor,
|
||||
uri: otherFileUri.toString(),
|
||||
uri: otherFileUri,
|
||||
range: rangeOfString(otherContents, 'class Bar {}'),
|
||||
selectionRange: rangeOfString(otherContents, 'Bar'),
|
||||
),
|
||||
|
@ -420,7 +420,7 @@ class OutgoingCallHierarchyTest extends AbstractLspAnalysisServerTest {
|
|||
name: 'bar',
|
||||
detail: 'Bar',
|
||||
kind: SymbolKind.Method,
|
||||
uri: otherFileUri.toString(),
|
||||
uri: otherFileUri,
|
||||
range: rangeOfString(otherContents, 'void bar() {}'),
|
||||
selectionRange: rangeOfString(otherContents, 'bar'),
|
||||
),
|
||||
|
@ -460,7 +460,7 @@ class OutgoingCallHierarchyTest extends AbstractLspAnalysisServerTest {
|
|||
name: 'Bar.named',
|
||||
detail: 'Bar',
|
||||
kind: SymbolKind.Constructor,
|
||||
uri: otherFileUri.toString(),
|
||||
uri: otherFileUri,
|
||||
range: rangeOfString(otherContents, 'Bar.named();'),
|
||||
selectionRange: rangeOfString(otherContents, 'named'),
|
||||
),
|
||||
|
@ -545,7 +545,7 @@ class PrepareCallHierarchyTest extends AbstractLspAnalysisServerTest {
|
|||
name: 'Foo',
|
||||
detail: 'Foo', // Containing class name
|
||||
kind: SymbolKind.Constructor,
|
||||
uri: mainFileUri.toString(),
|
||||
uri: mainFileUri,
|
||||
range: rangeOfString(contents, 'Foo(String a) {}'),
|
||||
selectionRange: rangeFromMarkers(contents)),
|
||||
);
|
||||
|
@ -573,7 +573,7 @@ class PrepareCallHierarchyTest extends AbstractLspAnalysisServerTest {
|
|||
name: 'Foo',
|
||||
detail: 'Foo', // Containing class name
|
||||
kind: SymbolKind.Constructor,
|
||||
uri: otherFileUri.toString(),
|
||||
uri: otherFileUri,
|
||||
range: rangeOfString(otherContents, 'Foo();'),
|
||||
selectionRange: rangeFromMarkers(otherContents)));
|
||||
}
|
||||
|
@ -589,7 +589,7 @@ class PrepareCallHierarchyTest extends AbstractLspAnalysisServerTest {
|
|||
name: 'myFunction',
|
||||
detail: 'main.dart', // Containing file name
|
||||
kind: SymbolKind.Function,
|
||||
uri: mainFileUri.toString(),
|
||||
uri: mainFileUri,
|
||||
range: rangeOfString(contents, 'void myFunction() {}'),
|
||||
selectionRange: rangeOfString(contents, 'myFunction')),
|
||||
);
|
||||
|
@ -615,7 +615,7 @@ class PrepareCallHierarchyTest extends AbstractLspAnalysisServerTest {
|
|||
name: 'myFunction',
|
||||
detail: 'other.dart', // Containing file name
|
||||
kind: SymbolKind.Function,
|
||||
uri: otherFileUri.toString(),
|
||||
uri: otherFileUri,
|
||||
range: rangeOfString(otherContents, 'void myFunction() {}'),
|
||||
selectionRange: rangeOfString(otherContents, 'myFunction')),
|
||||
);
|
||||
|
@ -644,7 +644,7 @@ class PrepareCallHierarchyTest extends AbstractLspAnalysisServerTest {
|
|||
name: 'Foo',
|
||||
detail: 'Foo', // Containing class name
|
||||
kind: SymbolKind.Constructor,
|
||||
uri: otherFileUri.toString(),
|
||||
uri: otherFileUri,
|
||||
range: rangeOfString(otherContents, 'class Foo {}'),
|
||||
selectionRange: rangeOfString(otherContents, 'Foo')),
|
||||
);
|
||||
|
@ -663,7 +663,7 @@ class PrepareCallHierarchyTest extends AbstractLspAnalysisServerTest {
|
|||
name: 'myMethod',
|
||||
detail: 'Foo', // Containing class name
|
||||
kind: SymbolKind.Method,
|
||||
uri: mainFileUri.toString(),
|
||||
uri: mainFileUri,
|
||||
range: rangeOfString(contents, 'void myMethod() {}'),
|
||||
selectionRange: rangeOfString(contents, 'myMethod')),
|
||||
);
|
||||
|
@ -691,7 +691,7 @@ class PrepareCallHierarchyTest extends AbstractLspAnalysisServerTest {
|
|||
name: 'myMethod',
|
||||
detail: 'Foo', // Containing class name
|
||||
kind: SymbolKind.Method,
|
||||
uri: otherFileUri.toString(),
|
||||
uri: otherFileUri,
|
||||
range: rangeOfString(otherContents, 'void myMethod() {}'),
|
||||
selectionRange: rangeOfString(otherContents, 'myMethod')),
|
||||
);
|
||||
|
@ -710,7 +710,7 @@ class PrepareCallHierarchyTest extends AbstractLspAnalysisServerTest {
|
|||
name: 'Foo.Bar',
|
||||
detail: 'Foo', // Containing class name
|
||||
kind: SymbolKind.Constructor,
|
||||
uri: mainFileUri.toString(),
|
||||
uri: mainFileUri,
|
||||
range: rangeOfString(contents, 'Foo.Bar(String a) {}'),
|
||||
selectionRange: rangeOfString(contents, 'Bar')),
|
||||
);
|
||||
|
@ -738,7 +738,7 @@ class PrepareCallHierarchyTest extends AbstractLspAnalysisServerTest {
|
|||
name: 'Foo.Bar',
|
||||
detail: 'Foo', // Containing class name
|
||||
kind: SymbolKind.Constructor,
|
||||
uri: otherFileUri.toString(),
|
||||
uri: otherFileUri,
|
||||
range: rangeOfString(otherContents, 'Foo.Bar();'),
|
||||
selectionRange: rangeOfString(otherContents, 'Bar')),
|
||||
);
|
||||
|
|
|
@ -33,7 +33,7 @@ void f() {
|
|||
final completionRequest = makeRequest(
|
||||
Method.textDocument_completion,
|
||||
CompletionParams(
|
||||
textDocument: TextDocumentIdentifier(uri: mainFileUri.toString()),
|
||||
textDocument: TextDocumentIdentifier(uri: mainFileUri),
|
||||
position: positionFromMarker(content),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -19,7 +19,7 @@ abstract class AbstractCodeActionsTest extends AbstractLspAnalysisServerTest {
|
|||
bool asCommand = false,
|
||||
}) async {
|
||||
final codeActions =
|
||||
await getCodeActions(uri.toString(), range: range, position: position);
|
||||
await getCodeActions(uri, range: range, position: position);
|
||||
final codeAction = findCommand(codeActions, command)!;
|
||||
|
||||
codeAction.map(
|
||||
|
|
|
@ -51,8 +51,8 @@ class AssistsCodeActionsTest extends AbstractCodeActionsTest {
|
|||
withDocumentChangesSupport(emptyWorkspaceClientCapabilities),
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final assist = findEditAction(
|
||||
codeActions,
|
||||
CodeActionKind('refactor.add.showCombinator'),
|
||||
|
@ -90,8 +90,8 @@ class AssistsCodeActionsTest extends AbstractCodeActionsTest {
|
|||
emptyTextDocumentClientCapabilities, [CodeActionKind.Refactor]),
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final assistAction = findEditAction(
|
||||
codeActions,
|
||||
CodeActionKind('refactor.add.showCombinator'),
|
||||
|
@ -128,7 +128,7 @@ class AssistsCodeActionsTest extends AbstractCodeActionsTest {
|
|||
_RawParams('''
|
||||
{
|
||||
"textDocument": {
|
||||
"uri": "${mainFileUri.toString()}"
|
||||
"uri": "$mainFileUri"
|
||||
},
|
||||
"context": {
|
||||
"diagnostics": []
|
||||
|
@ -186,7 +186,7 @@ Widget build() {
|
|||
},
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
final codeActions = await getCodeActions(mainFileUri,
|
||||
position: positionFromMarker(content));
|
||||
final assist = findEditAction(codeActions,
|
||||
CodeActionKind('refactor.flutter.wrap.center'), 'Wrap with Center')!;
|
||||
|
@ -207,7 +207,7 @@ Widget build() {
|
|||
);
|
||||
|
||||
final codeActions =
|
||||
await getCodeActions(pubspecFileUri.toString(), range: startOfDocRange);
|
||||
await getCodeActions(pubspecFileUri, range: startOfDocRange);
|
||||
expect(codeActions, isEmpty);
|
||||
}
|
||||
|
||||
|
@ -240,8 +240,8 @@ Widget build() {
|
|||
emptyTextDocumentClientCapabilities, [CodeActionKind.Refactor]),
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final assist = findEditAction(codeActions,
|
||||
CodeActionKind('refactor.fooToBar'), "Change 'foo' to 'bar'")!;
|
||||
|
||||
|
@ -277,8 +277,8 @@ Widget build() {
|
|||
emptyTextDocumentClientCapabilities, [CodeActionKind.Refactor]),
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final codeActionTitles = codeActions.map((action) =>
|
||||
action.map((command) => command.title, (action) => action.title));
|
||||
|
||||
|
@ -339,7 +339,7 @@ Widget build() {
|
|||
},
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
final codeActions = await getCodeActions(mainFileUri,
|
||||
position: positionFromMarker(content));
|
||||
final assist = findEditAction(
|
||||
codeActions,
|
||||
|
@ -411,7 +411,7 @@ Widget build() {
|
|||
},
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
final codeActions = await getCodeActions(mainFileUri,
|
||||
position: positionFromMarker(content));
|
||||
final assist = findEditAction(
|
||||
codeActions,
|
||||
|
@ -472,7 +472,7 @@ Widget build() {
|
|||
withDocumentChangesSupport(emptyWorkspaceClientCapabilities),
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
final codeActions = await getCodeActions(mainFileUri,
|
||||
position: positionFromMarker(content));
|
||||
final assist = findEditAction(
|
||||
codeActions,
|
||||
|
@ -514,7 +514,7 @@ Widget build() {
|
|||
withDocumentChangesSupport(emptyWorkspaceClientCapabilities),
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
final codeActions = await getCodeActions(mainFileUri,
|
||||
position: positionFromMarker(content));
|
||||
final names = codeActions.map(
|
||||
(e) => e.map((command) => command.title, (action) => action.title),
|
||||
|
@ -558,8 +558,8 @@ void f() {
|
|||
},
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final assist = findEditAction(codeActions,
|
||||
CodeActionKind('refactor.surround.if'), "Surround with 'if'")!;
|
||||
|
||||
|
|
|
@ -42,8 +42,8 @@ class FixesCodeActionsTest extends AbstractCodeActionsTest {
|
|||
withDocumentChangesSupport(emptyWorkspaceClientCapabilities),
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final fixAction = findEditAction(
|
||||
codeActions,
|
||||
CodeActionKind('quickfix.remove.unusedImport'),
|
||||
|
@ -82,8 +82,8 @@ class FixesCodeActionsTest extends AbstractCodeActionsTest {
|
|||
emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final fixAction = findEditAction(
|
||||
codeActions,
|
||||
CodeActionKind('quickfix.remove.unusedImport'),
|
||||
|
@ -118,8 +118,8 @@ class FixesCodeActionsTest extends AbstractCodeActionsTest {
|
|||
emptyWorkspaceClientCapabilities, [ResourceOperationKind.Create]),
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final fixAction = findEditAction(codeActions,
|
||||
CodeActionKind('quickfix.create.file'), "Create file 'newfile.dart'")!;
|
||||
|
||||
|
@ -145,7 +145,7 @@ class FixesCodeActionsTest extends AbstractCodeActionsTest {
|
|||
await initialize();
|
||||
|
||||
ofKind(CodeActionKind kind) => getCodeActions(
|
||||
mainFileUri.toString(),
|
||||
mainFileUri,
|
||||
range: rangeFromMarkers(content),
|
||||
kinds: [kind],
|
||||
);
|
||||
|
@ -172,8 +172,8 @@ var b = bar();
|
|||
emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
|
||||
);
|
||||
|
||||
final allFixes = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final allFixes =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
|
||||
// Expect only the single-fix, there should be no apply-all.
|
||||
expect(allFixes, hasLength(1));
|
||||
|
@ -194,8 +194,8 @@ void f(String a) {
|
|||
emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final fixAction = findEditAction(
|
||||
codeActions, CodeActionKind('quickfix'), "Remove '!'s in file");
|
||||
|
||||
|
@ -223,8 +223,8 @@ void f(String a) {
|
|||
emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final fixAction = findEditAction(
|
||||
codeActions, CodeActionKind('quickfix'), "Remove '!'s in file")!;
|
||||
|
||||
|
@ -267,8 +267,8 @@ Future foo;''';
|
|||
);
|
||||
|
||||
// Find the ignore action.
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final fixAction = findEditAction(
|
||||
codeActions,
|
||||
CodeActionKind('quickfix.ignore.file'),
|
||||
|
@ -302,8 +302,8 @@ Future foo;''';
|
|||
);
|
||||
|
||||
// Find the ignore action.
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final fixAction = findEditAction(
|
||||
codeActions,
|
||||
CodeActionKind('quickfix.ignore.line'),
|
||||
|
@ -336,7 +336,7 @@ void f() {
|
|||
emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
final codeActions = await getCodeActions(mainFileUri,
|
||||
position: positionFromMarker(content));
|
||||
final removeNnaAction = findEditActions(codeActions,
|
||||
CodeActionKind('quickfix.remove.nonNullAssertion'), "Remove the '!'");
|
||||
|
@ -364,8 +364,8 @@ void f() {
|
|||
emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final createClassActions = findEditActions(codeActions,
|
||||
CodeActionKind('quickfix.create.class'), "Create class 'Test'");
|
||||
|
||||
|
@ -385,8 +385,8 @@ void f() {
|
|||
workspaceCapabilities: withApplyEditSupport(
|
||||
withDocumentChangesSupport(emptyWorkspaceClientCapabilities)));
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final createClassActions = findEditActions(codeActions,
|
||||
CodeActionKind('quickfix.create.class'), "Create class 'Test'");
|
||||
|
||||
|
@ -402,7 +402,7 @@ void f() {
|
|||
);
|
||||
|
||||
final codeActions =
|
||||
await getCodeActions(pubspecFileUri.toString(), range: startOfDocRange);
|
||||
await getCodeActions(pubspecFileUri, range: startOfDocRange);
|
||||
expect(codeActions, isEmpty);
|
||||
}
|
||||
|
||||
|
@ -436,8 +436,8 @@ ProcessInfo b;
|
|||
emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final fixAction = findEditAction(codeActions,
|
||||
CodeActionKind('quickfix.organize.imports'), 'Organize Imports')!;
|
||||
|
||||
|
@ -464,7 +464,7 @@ ProcessInfo b;
|
|||
);
|
||||
|
||||
final codeActions = await getCodeActions(
|
||||
otherFileUri.toString(),
|
||||
otherFileUri,
|
||||
position: startOfDocPos,
|
||||
);
|
||||
expect(codeActions, isEmpty);
|
||||
|
@ -510,8 +510,8 @@ ProcessInfo b;
|
|||
emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final assist = findEditAction(codeActions,
|
||||
CodeActionKind('quickfix.fooToBar'), "Change 'foo' to 'bar'")!;
|
||||
|
||||
|
@ -560,8 +560,8 @@ ProcessInfo b;
|
|||
emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final codeActionTitles = codeActions.map((action) =>
|
||||
action.map((command) => command.title, (action) => action.title));
|
||||
|
||||
|
@ -603,7 +603,7 @@ class A {
|
|||
},
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
final codeActions = await getCodeActions(mainFileUri,
|
||||
position: positionFromMarker(content));
|
||||
final fixAction = findEditAction(codeActions,
|
||||
CodeActionKind('quickfix.create.method'), "Create method 'c'")!;
|
||||
|
@ -651,7 +651,7 @@ useFunction(int g(a, b)) {}
|
|||
},
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
final codeActions = await getCodeActions(mainFileUri,
|
||||
position: positionFromMarker(content));
|
||||
final fixAction = findEditAction(
|
||||
codeActions,
|
||||
|
|
|
@ -49,7 +49,7 @@ void f() {
|
|||
newFile(mainFilePath, withoutMarkers(content));
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
final codeActions = await getCodeActions(mainFileUri,
|
||||
position: positionFromMarker(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, refactorTitle)!;
|
||||
|
@ -66,7 +66,7 @@ set ^a(String value) {}
|
|||
newFile(mainFilePath, withoutMarkers(content));
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
final codeActions = await getCodeActions(mainFileUri,
|
||||
position: positionFromMarker(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, refactorTitle);
|
||||
|
@ -88,7 +88,7 @@ class A {
|
|||
newFile(mainFilePath, withoutMarkers(content));
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
final codeActions = await getCodeActions(mainFileUri,
|
||||
position: positionFromMarker(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, refactorTitle);
|
||||
|
@ -114,7 +114,7 @@ void f() {
|
|||
newFile(mainFilePath, withoutMarkers(content));
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
final codeActions = await getCodeActions(mainFileUri,
|
||||
position: positionFromMarker(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, refactorTitle)!;
|
||||
|
@ -182,8 +182,8 @@ void newMethod() {
|
|||
newFile(mainFilePath, withoutMarkers(content));
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, extractMethodTitle)!;
|
||||
|
||||
|
@ -211,8 +211,8 @@ void newMethod() {
|
|||
newFile(mainFilePath, withoutMarkers(content));
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, extractMethodTitle)!;
|
||||
|
||||
|
@ -255,8 +255,8 @@ void f() {
|
|||
await initialize();
|
||||
await openFile(mainFileUri, withoutMarkers(content));
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, extractMethodTitle)!;
|
||||
|
||||
|
@ -286,7 +286,7 @@ void f() {
|
|||
);
|
||||
|
||||
ofKind(CodeActionKind kind) => getCodeActions(
|
||||
mainFileUri.toString(),
|
||||
mainFileUri,
|
||||
range: rangeFromMarkers(content),
|
||||
kinds: [kind],
|
||||
);
|
||||
|
@ -340,8 +340,8 @@ Object Text(Object text) => null;
|
|||
newFile(mainFilePath, withoutMarkers(content));
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, extractMethodTitle)!;
|
||||
|
||||
|
@ -358,7 +358,7 @@ void f() {}
|
|||
newFile(mainFilePath, withoutMarkers(content));
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
final codeActions = await getCodeActions(mainFileUri,
|
||||
position: positionFromMarker(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, extractMethodTitle);
|
||||
|
@ -374,7 +374,7 @@ i^o.File a;
|
|||
newFile(mainFilePath, withoutMarkers(content));
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
final codeActions = await getCodeActions(mainFileUri,
|
||||
position: positionFromMarker(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, extractMethodTitle);
|
||||
|
@ -407,8 +407,8 @@ void newMethod() {
|
|||
// token was supplied by us (the client).
|
||||
expect(progressUpdates, emitsInOrder(['BEGIN', 'END']));
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, extractMethodTitle)!;
|
||||
|
||||
|
@ -442,8 +442,8 @@ void newMethod() {
|
|||
.where((n) => n.method == Method.progress)
|
||||
.listen((_) => didGetProgressNotifications = true);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, extractMethodTitle)!;
|
||||
|
||||
|
@ -475,8 +475,8 @@ void newMethod() {
|
|||
windowCapabilities:
|
||||
withWorkDoneProgressSupport(emptyWindowClientCapabilities));
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, extractMethodTitle)!;
|
||||
|
||||
|
@ -501,8 +501,8 @@ void doFoo(void Function() a) => a();
|
|||
newFile(mainFilePath, withoutMarkers(content));
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, extractMethodTitle)!;
|
||||
|
||||
|
@ -545,8 +545,8 @@ void doFoo(void Function() a) => a();
|
|||
failTestOnAnyErrorNotification: false,
|
||||
);
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, extractMethodTitle)!;
|
||||
|
||||
|
@ -584,8 +584,8 @@ void doFoo(void Function() a) => a();
|
|||
newFile(mainFilePath, withoutMarkers(content));
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, extractMethodTitle)!;
|
||||
|
||||
|
@ -633,8 +633,8 @@ void foo(int arg) {}
|
|||
newFile(mainFilePath, withoutMarkers(content));
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final codeAction = findCommand(
|
||||
codeActions, Commands.performRefactor, extractVariableTitle)!;
|
||||
|
||||
|
@ -663,8 +663,8 @@ void foo(int arg) {}
|
|||
newFile(mainFilePath, withoutMarkers(content));
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final codeAction = findCommand(
|
||||
codeActions, Commands.performRefactor, extractVariableTitle)!;
|
||||
|
||||
|
@ -745,8 +745,8 @@ class NewWidget extends StatelessWidget {
|
|||
newFile(mainFilePath, withoutMarkers(content));
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
range: rangeFromMarkers(content));
|
||||
final codeActions =
|
||||
await getCodeActions(mainFileUri, range: rangeFromMarkers(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, extractWidgetTitle)!;
|
||||
|
||||
|
@ -763,7 +763,7 @@ void f() {}
|
|||
newFile(mainFilePath, withoutMarkers(content));
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
final codeActions = await getCodeActions(mainFileUri,
|
||||
position: positionFromMarker(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, extractWidgetTitle);
|
||||
|
@ -809,7 +809,7 @@ void f() {
|
|||
newFile(mainFilePath, withoutMarkers(content));
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
final codeActions = await getCodeActions(mainFileUri,
|
||||
position: positionFromMarker(content));
|
||||
final codeAction = findCommand(
|
||||
codeActions, Commands.performRefactor, inlineVariableTitle)!;
|
||||
|
@ -853,7 +853,7 @@ void bar() {
|
|||
newFile(mainFilePath, withoutMarkers(content));
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
final codeActions = await getCodeActions(mainFileUri,
|
||||
position: positionFromMarker(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, inlineMethodTitle)!;
|
||||
|
@ -888,7 +888,7 @@ void foo2() {
|
|||
newFile(mainFilePath, withoutMarkers(content));
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getCodeActions(mainFileUri.toString(),
|
||||
final codeActions = await getCodeActions(mainFileUri,
|
||||
position: positionFromMarker(content));
|
||||
final codeAction =
|
||||
findCommand(codeActions, Commands.performRefactor, inlineMethodTitle)!;
|
||||
|
|
|
@ -42,7 +42,7 @@ abstract class AbstractSourceCodeActionsTest extends AbstractCodeActionsTest {
|
|||
/// Wrapper around [getCodeActions] for Source actions where position/range is
|
||||
/// irrelevant (so uses [startOfDocPos]).
|
||||
Future<List<Either2<Command, CodeAction>>> getSourceCodeActions(
|
||||
String fileUri, {
|
||||
Uri fileUri, {
|
||||
List<CodeActionKind>? kinds,
|
||||
CodeActionTriggerKind? triggerKind,
|
||||
}) {
|
||||
|
@ -81,7 +81,7 @@ linter:
|
|||
workspaceCapabilities:
|
||||
withApplyEditSupport(emptyWorkspaceClientCapabilities));
|
||||
|
||||
final codeActions = await getSourceCodeActions(mainFileUri.toString());
|
||||
final codeActions = await getSourceCodeActions(mainFileUri);
|
||||
final codeAction = findCommand(codeActions, Commands.fixAll)!;
|
||||
|
||||
await verifyCodeActionEdits(codeAction, content, expectedContent);
|
||||
|
@ -112,7 +112,7 @@ int minified(int x, int y) => min(x, y);
|
|||
workspaceCapabilities: withApplyEditSupport(
|
||||
withDocumentChangesSupport(emptyWorkspaceClientCapabilities)));
|
||||
|
||||
final codeActions = await getSourceCodeActions(mainFileUri.toString());
|
||||
final codeActions = await getSourceCodeActions(mainFileUri);
|
||||
final codeAction = findCommand(codeActions, Commands.organizeImports)!;
|
||||
|
||||
await verifyCodeActionEdits(codeAction, content, expectedContent,
|
||||
|
@ -140,7 +140,7 @@ int minified(int x, int y) => min(x, y);
|
|||
workspaceCapabilities:
|
||||
withApplyEditSupport(emptyWorkspaceClientCapabilities));
|
||||
|
||||
final codeActions = await getSourceCodeActions(mainFileUri.toString());
|
||||
final codeActions = await getSourceCodeActions(mainFileUri);
|
||||
final codeAction = findCommand(codeActions, Commands.organizeImports)!;
|
||||
|
||||
await verifyCodeActionEdits(codeAction, content, expectedContent);
|
||||
|
@ -184,7 +184,7 @@ int minified(int x, int y) => min(x, y);
|
|||
withApplyEditSupport(emptyWorkspaceClientCapabilities));
|
||||
|
||||
final codeActions = await getSourceCodeActions(
|
||||
mainFileUri.toString(),
|
||||
mainFileUri,
|
||||
triggerKind: CodeActionTriggerKind.Automatic,
|
||||
);
|
||||
final codeAction = findCommand(codeActions, Commands.organizeImports)!;
|
||||
|
@ -206,7 +206,7 @@ int minified(int x, int y) => min(x, y);
|
|||
workspaceCapabilities:
|
||||
withApplyEditSupport(emptyWorkspaceClientCapabilities));
|
||||
|
||||
final codeActions = await getSourceCodeActions(mainFileUri.toString());
|
||||
final codeActions = await getSourceCodeActions(mainFileUri);
|
||||
final codeAction = findCommand(codeActions, Commands.organizeImports)!;
|
||||
|
||||
final command = codeAction.map(
|
||||
|
@ -227,7 +227,7 @@ int minified(int x, int y) => min(x, y);
|
|||
withApplyEditSupport(emptyWorkspaceClientCapabilities));
|
||||
|
||||
ofKind(CodeActionKind kind) => getSourceCodeActions(
|
||||
mainFileUri.toString(),
|
||||
mainFileUri,
|
||||
kinds: [kind],
|
||||
);
|
||||
|
||||
|
@ -252,7 +252,7 @@ int minified(int x, int y) => min(x, y);
|
|||
workspaceCapabilities:
|
||||
withApplyEditSupport(emptyWorkspaceClientCapabilities));
|
||||
|
||||
final codeActions = await getSourceCodeActions(mainFileUri.toString());
|
||||
final codeActions = await getSourceCodeActions(mainFileUri);
|
||||
final codeAction = findCommand(codeActions, Commands.organizeImports)!;
|
||||
|
||||
final command = codeAction.map(
|
||||
|
@ -275,7 +275,7 @@ int minified(int x, int y) => min(x, y);
|
|||
workspaceCapabilities:
|
||||
withApplyEditSupport(emptyWorkspaceClientCapabilities));
|
||||
|
||||
final codeActions = await getSourceCodeActions(mainFileUri.toString());
|
||||
final codeActions = await getSourceCodeActions(mainFileUri);
|
||||
final codeAction = findCommand(codeActions, Commands.organizeImports);
|
||||
expect(codeAction, isNull);
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ int minified(int x, int y) => min(x, y);
|
|||
newFile(mainFilePath, '');
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getSourceCodeActions(mainFileUri.toString());
|
||||
final codeActions = await getSourceCodeActions(mainFileUri);
|
||||
final codeAction = findCommand(codeActions, Commands.organizeImports);
|
||||
expect(codeAction, isNull);
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ class SortMembersSourceCodeActionsTest extends AbstractSourceCodeActionsTest {
|
|||
workspaceCapabilities: withApplyEditSupport(
|
||||
withDocumentChangesSupport(emptyWorkspaceClientCapabilities)));
|
||||
|
||||
final codeActions = await getSourceCodeActions(mainFileUri.toString());
|
||||
final codeActions = await getSourceCodeActions(mainFileUri);
|
||||
final codeAction = findCommand(codeActions, Commands.sortMembers)!;
|
||||
|
||||
await verifyCodeActionEdits(codeAction, content, expectedContent,
|
||||
|
@ -327,7 +327,7 @@ class SortMembersSourceCodeActionsTest extends AbstractSourceCodeActionsTest {
|
|||
workspaceCapabilities:
|
||||
withApplyEditSupport(emptyWorkspaceClientCapabilities));
|
||||
|
||||
final codeActions = await getSourceCodeActions(mainFileUri.toString());
|
||||
final codeActions = await getSourceCodeActions(mainFileUri);
|
||||
final codeAction = findCommand(codeActions, Commands.sortMembers)!;
|
||||
|
||||
await verifyCodeActionEdits(codeAction, content, expectedContent);
|
||||
|
@ -373,7 +373,7 @@ class SortMembersSourceCodeActionsTest extends AbstractSourceCodeActionsTest {
|
|||
workspaceCapabilities:
|
||||
withApplyEditSupport(emptyWorkspaceClientCapabilities));
|
||||
|
||||
final codeActions = await getSourceCodeActions(mainFileUri.toString());
|
||||
final codeActions = await getSourceCodeActions(mainFileUri);
|
||||
final codeAction = findCommand(codeActions, Commands.sortMembers)!;
|
||||
|
||||
final command = codeAction.map(
|
||||
|
@ -407,7 +407,7 @@ class SortMembersSourceCodeActionsTest extends AbstractSourceCodeActionsTest {
|
|||
withApplyEditSupport(emptyWorkspaceClientCapabilities));
|
||||
|
||||
final codeActions = await getSourceCodeActions(
|
||||
mainFileUri.toString(),
|
||||
mainFileUri,
|
||||
triggerKind: CodeActionTriggerKind.Automatic,
|
||||
);
|
||||
final codeAction = findCommand(codeActions, Commands.sortMembers)!;
|
||||
|
@ -429,7 +429,7 @@ class SortMembersSourceCodeActionsTest extends AbstractSourceCodeActionsTest {
|
|||
workspaceCapabilities:
|
||||
withApplyEditSupport(emptyWorkspaceClientCapabilities));
|
||||
|
||||
final codeActions = await getSourceCodeActions(mainFileUri.toString());
|
||||
final codeActions = await getSourceCodeActions(mainFileUri);
|
||||
final codeAction = findCommand(codeActions, Commands.sortMembers)!;
|
||||
|
||||
final command = codeAction.map(
|
||||
|
@ -451,7 +451,7 @@ class SortMembersSourceCodeActionsTest extends AbstractSourceCodeActionsTest {
|
|||
workspaceCapabilities:
|
||||
withApplyEditSupport(emptyWorkspaceClientCapabilities));
|
||||
|
||||
final codeActions = await getSourceCodeActions(pubspecFileUri.toString());
|
||||
final codeActions = await getSourceCodeActions(pubspecFileUri);
|
||||
expect(codeActions, isEmpty);
|
||||
}
|
||||
|
||||
|
@ -463,7 +463,7 @@ class SortMembersSourceCodeActionsTest extends AbstractSourceCodeActionsTest {
|
|||
workspaceCapabilities:
|
||||
withApplyEditSupport(emptyWorkspaceClientCapabilities));
|
||||
|
||||
final codeActions = await getSourceCodeActions(mainFileUri.toString());
|
||||
final codeActions = await getSourceCodeActions(mainFileUri);
|
||||
final codeAction = findCommand(codeActions, Commands.sortMembers);
|
||||
expect(codeAction, isNull);
|
||||
}
|
||||
|
@ -472,7 +472,7 @@ class SortMembersSourceCodeActionsTest extends AbstractSourceCodeActionsTest {
|
|||
newFile(mainFilePath, '');
|
||||
await initialize();
|
||||
|
||||
final codeActions = await getSourceCodeActions(mainFileUri.toString());
|
||||
final codeActions = await getSourceCodeActions(mainFileUri);
|
||||
final codeAction = findCommand(codeActions, Commands.sortMembers);
|
||||
expect(codeAction, isNull);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ class DefinitionTest extends AbstractLspAnalysisServerTest {
|
|||
expect(res, hasLength(1));
|
||||
var loc = res.single;
|
||||
expect(loc.range, equals(rangeFromMarkers(referencedContents)));
|
||||
expect(loc.uri, equals(referencedFileUri.toString()));
|
||||
expect(loc.uri, equals(referencedFileUri));
|
||||
}
|
||||
|
||||
Future<void> test_atDeclaration_class() async {
|
||||
|
@ -286,7 +286,7 @@ class A {
|
|||
equals(lsp.Range(
|
||||
start: lsp.Position(line: 0, character: 0),
|
||||
end: lsp.Position(line: 0, character: 5))));
|
||||
expect(loc.uri, equals(pluginAnalyzedFileUri.toString()));
|
||||
expect(loc.uri, equals(pluginAnalyzedFileUri));
|
||||
}
|
||||
|
||||
Future<void> test_function() async {
|
||||
|
@ -334,7 +334,7 @@ class A {
|
|||
expect(res, hasLength(1));
|
||||
var loc = res.single;
|
||||
expect(loc.originSelectionRange, equals(rangeFromMarkers(mainContents)));
|
||||
expect(loc.targetUri, equals(referencedFileUri.toString()));
|
||||
expect(loc.targetUri, equals(referencedFileUri));
|
||||
expect(loc.targetRange, equals(rangeFromMarkers(referencedContents)));
|
||||
expect(
|
||||
loc.targetSelectionRange,
|
||||
|
@ -377,7 +377,7 @@ class A {
|
|||
expect(res, hasLength(1));
|
||||
var loc = res.single;
|
||||
expect(loc.originSelectionRange, equals(rangeFromMarkers(mainContents)));
|
||||
expect(loc.targetUri, equals(referencedFileUri.toString()));
|
||||
expect(loc.targetUri, equals(referencedFileUri));
|
||||
expect(loc.targetRange, equals(rangeFromMarkers(referencedContents)));
|
||||
expect(
|
||||
loc.targetSelectionRange,
|
||||
|
@ -435,7 +435,7 @@ class A {
|
|||
expect(res, hasLength(1));
|
||||
var loc = res.single;
|
||||
expect(loc.originSelectionRange, equals(rangeFromMarkers(mainContents)));
|
||||
expect(loc.targetUri, equals(partFileUri.toString()));
|
||||
expect(loc.targetUri, equals(partFileUri));
|
||||
expect(loc.targetRange, equals(rangeFromMarkers(partContents)));
|
||||
expect(
|
||||
loc.targetSelectionRange,
|
||||
|
@ -460,7 +460,7 @@ part of 'main.dart';
|
|||
final res = await getDefinitionAsLocation(
|
||||
mainFileUri, positionFromMarker(mainContents));
|
||||
|
||||
expect(res.single.uri, equals(partFileUri.toString()));
|
||||
expect(res.single.uri, equals(partFileUri));
|
||||
}
|
||||
|
||||
Future<void> test_partOfFilename() async {
|
||||
|
@ -480,7 +480,7 @@ part of 'ma^in.dart';
|
|||
final res = await getDefinitionAsLocation(
|
||||
partFileUri, positionFromMarker(partContents));
|
||||
|
||||
expect(res.single.uri, equals(mainFileUri.toString()));
|
||||
expect(res.single.uri, equals(mainFileUri));
|
||||
}
|
||||
|
||||
Future<void> test_sameLine() async {
|
||||
|
@ -550,6 +550,6 @@ class [[A]] {}
|
|||
expect(res, hasLength(1));
|
||||
var loc = res.single;
|
||||
expect(loc.range, equals(rangeFromMarkers(contents)));
|
||||
expect(loc.uri, equals(mainFileUri.toString()));
|
||||
expect(loc.uri, equals(mainFileUri));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -245,7 +245,8 @@ void f() {
|
|||
expect(diagnostic.code, equals('built_in_identifier_in_declaration'));
|
||||
expect(
|
||||
diagnostic.codeDescription!.href,
|
||||
equals('https://dart.dev/diagnostics/built_in_identifier_in_declaration'),
|
||||
equals(Uri.parse(
|
||||
'https://dart.dev/diagnostics/built_in_identifier_in_declaration')),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class DocumentColorPresentationTest extends AbstractLspAnalysisServerTest {
|
|||
await initialize();
|
||||
|
||||
final colorPresentations = await getColorPresentation(
|
||||
mainFileUri.toString(),
|
||||
mainFileUri,
|
||||
colorRange,
|
||||
Color(alpha: 1, red: 1, green: 1, blue: 1),
|
||||
);
|
||||
|
@ -64,7 +64,7 @@ class DocumentColorPresentationTest extends AbstractLspAnalysisServerTest {
|
|||
await initialize();
|
||||
|
||||
final colors = await getColorPresentation(
|
||||
pubspecFileUri.toString(),
|
||||
pubspecFileUri,
|
||||
startOfDocRange,
|
||||
Color(alpha: 1, red: 1, green: 1, blue: 1),
|
||||
);
|
||||
|
@ -84,7 +84,7 @@ class DocumentColorPresentationTest extends AbstractLspAnalysisServerTest {
|
|||
await initialize();
|
||||
|
||||
final colorPresentations = await getColorPresentation(
|
||||
Uri.file(outsideRootFilePath).toString(),
|
||||
Uri.file(outsideRootFilePath),
|
||||
colorRange,
|
||||
Color(alpha: 1, red: 1, green: 0, blue: 0),
|
||||
);
|
||||
|
@ -106,7 +106,7 @@ class DocumentColorPresentationTest extends AbstractLspAnalysisServerTest {
|
|||
await initialize();
|
||||
|
||||
final colorPresentations = await getColorPresentation(
|
||||
mainFileUri.toString(),
|
||||
mainFileUri,
|
||||
colorRange,
|
||||
// Send a different color to what's in the source to simulate the user
|
||||
// having changed in the color picker. This is the one that we should be
|
||||
|
@ -158,7 +158,7 @@ class DocumentColorTest extends AbstractLspAnalysisServerTest {
|
|||
newFile(pubspecFilePath, simplePubspecContent);
|
||||
await initialize();
|
||||
|
||||
final colors = await getDocumentColors(pubspecFileUri.toString());
|
||||
final colors = await getDocumentColors(pubspecFileUri);
|
||||
expect(colors, isEmpty);
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ class DocumentColorTest extends AbstractLspAnalysisServerTest {
|
|||
newFile(mainFilePath, withoutMarkers(content));
|
||||
await initialize();
|
||||
|
||||
final colors = await getDocumentColors(mainFileUri.toString());
|
||||
final colors = await getDocumentColors(mainFileUri);
|
||||
expect(colors, hasLength(1));
|
||||
|
||||
final color = colors[0];
|
||||
|
|
|
@ -20,7 +20,7 @@ void main() {
|
|||
class FormatTest extends AbstractLspAnalysisServerTest {
|
||||
Future<List<TextEdit>> expectFormattedContents(
|
||||
Uri uri, String original, String expected) async {
|
||||
final formatEdits = (await formatDocument(uri.toString()))!;
|
||||
final formatEdits = (await formatDocument(uri))!;
|
||||
final formattedContents = applyTextEdits(original, formatEdits);
|
||||
expect(formattedContents, equals(expected));
|
||||
return formatEdits;
|
||||
|
@ -28,8 +28,7 @@ class FormatTest extends AbstractLspAnalysisServerTest {
|
|||
|
||||
Future<List<TextEdit>> expectRangeFormattedContents(
|
||||
Uri uri, String original, String expected) async {
|
||||
final formatEdits =
|
||||
(await formatRange(uri.toString(), rangeFromMarkers(original)))!;
|
||||
final formatEdits = (await formatRange(uri, rangeFromMarkers(original)))!;
|
||||
final formattedContents =
|
||||
applyTextEdits(withoutMarkers(original), formatEdits);
|
||||
expect(formattedContents, equals(expected));
|
||||
|
@ -44,7 +43,7 @@ class FormatTest extends AbstractLspAnalysisServerTest {
|
|||
await initialize();
|
||||
await openFile(mainFileUri, contents);
|
||||
|
||||
final formatEdits = await formatDocument(mainFileUri.toString());
|
||||
final formatEdits = await formatDocument(mainFileUri);
|
||||
expect(formatEdits, isNull);
|
||||
}
|
||||
|
||||
|
@ -179,8 +178,8 @@ ErrorOr<Pair<A, List<B>>> c(
|
|||
await initialize();
|
||||
await openFile(mainFileUri, withoutMarkers(contents));
|
||||
|
||||
final formatEdits = (await formatOnType(
|
||||
mainFileUri.toString(), positionFromMarker(contents), '}'))!;
|
||||
final formatEdits =
|
||||
(await formatOnType(mainFileUri, positionFromMarker(contents), '}'))!;
|
||||
final formattedContents =
|
||||
applyTextEdits(withoutMarkers(contents), formatEdits);
|
||||
expect(formattedContents, equals(expected));
|
||||
|
@ -244,7 +243,7 @@ void f()
|
|||
await initialize();
|
||||
await openFile(mainFileUri, withoutMarkers(contents));
|
||||
final formatRangeRequest = formatRange(
|
||||
mainFileUri.toString(),
|
||||
mainFileUri,
|
||||
Range(
|
||||
start: Position(line: 0, character: 0),
|
||||
end: Position(line: 10000, character: 0)),
|
||||
|
@ -323,7 +322,7 @@ int b;
|
|||
await initialize();
|
||||
await openFile(mainFileUri, contents);
|
||||
|
||||
final formatEdits = await formatDocument(mainFileUri.toString());
|
||||
final formatEdits = await formatDocument(mainFileUri);
|
||||
expect(formatEdits, isNull);
|
||||
}
|
||||
|
||||
|
@ -629,8 +628,7 @@ void f() {
|
|||
await initialize();
|
||||
await openFile(pubspecFileUri, simplePubspecContent);
|
||||
|
||||
final formatEdits =
|
||||
await formatOnType(pubspecFileUri.toString(), startOfDocPos, '}');
|
||||
final formatEdits = await formatOnType(pubspecFileUri, startOfDocPos, '}');
|
||||
expect(formatEdits, isNull);
|
||||
}
|
||||
|
||||
|
@ -638,8 +636,7 @@ void f() {
|
|||
await initialize();
|
||||
|
||||
await expectLater(
|
||||
formatDocument(
|
||||
Uri.file(join(projectFolderPath, 'missing.dart')).toString()),
|
||||
formatDocument(Uri.file(join(projectFolderPath, 'missing.dart'))),
|
||||
throwsA(isResponseError(ServerErrorCodes.InvalidFilePath,
|
||||
message: 'File does not exist')),
|
||||
);
|
||||
|
@ -649,8 +646,10 @@ void f() {
|
|||
await initialize();
|
||||
|
||||
await expectLater(
|
||||
// Add some invalid path characters to the end of a valid file:// URI.
|
||||
formatDocument(mainFileUri.toString() + r'***###\\\///:::.dart'),
|
||||
formatDocument(
|
||||
// Add some invalid path characters to the end of a valid file:// URI.
|
||||
Uri.parse(mainFileUri.toString() + r'###***\\\///:::.dart'),
|
||||
),
|
||||
throwsA(isResponseError(ServerErrorCodes.InvalidFilePath,
|
||||
message: 'File URI did not contain a valid file path')),
|
||||
);
|
||||
|
@ -660,7 +659,7 @@ void f() {
|
|||
await initialize();
|
||||
|
||||
await expectLater(
|
||||
formatDocument('a:/a.dart'),
|
||||
formatDocument(Uri.parse('a:/a.dart')),
|
||||
throwsA(isResponseError(ServerErrorCodes.InvalidFilePath,
|
||||
message: 'URI was not a valid file:// URI')),
|
||||
);
|
||||
|
|
|
@ -177,7 +177,7 @@ class ImplementationTest extends AbstractLspAnalysisServerTest {
|
|||
);
|
||||
|
||||
final expectedLocations = rangesFromMarkers(content)
|
||||
.map((r) => Location(uri: mainFileUri.toString(), range: r));
|
||||
.map((r) => Location(uri: mainFileUri, range: r));
|
||||
|
||||
if (expectResults) {
|
||||
expect(res, equals(expectedLocations));
|
||||
|
|
|
@ -54,13 +54,12 @@ class ReferencesTest extends AbstractLspAnalysisServerTest {
|
|||
expect(res, hasLength(2));
|
||||
expect(
|
||||
res,
|
||||
contains(Location(
|
||||
uri: mainFileUri.toString(),
|
||||
range: rangeFromMarkers(mainContents))));
|
||||
contains(
|
||||
Location(uri: mainFileUri, range: rangeFromMarkers(mainContents))));
|
||||
expect(
|
||||
res,
|
||||
contains(Location(
|
||||
uri: referencedFileUri.toString(),
|
||||
uri: referencedFileUri,
|
||||
range: rangeFromMarkers(referencedContents))));
|
||||
}
|
||||
|
||||
|
@ -98,7 +97,7 @@ class ReferencesTest extends AbstractLspAnalysisServerTest {
|
|||
expect(res, hasLength(1));
|
||||
var loc = res.single;
|
||||
expect(loc.range, equals(rangeFromMarkers(mainContents)));
|
||||
expect(loc.uri, equals(mainFileUri.toString()));
|
||||
expect(loc.uri, equals(mainFileUri));
|
||||
}
|
||||
|
||||
Future<void> test_nonDartFile() async {
|
||||
|
@ -124,8 +123,7 @@ class ReferencesTest extends AbstractLspAnalysisServerTest {
|
|||
expect(
|
||||
res,
|
||||
contains(
|
||||
Location(
|
||||
uri: mainFileUri.toString(), range: rangeFromMarkers(contents)),
|
||||
Location(uri: mainFileUri, range: rangeFromMarkers(contents)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -145,8 +143,7 @@ class ReferencesTest extends AbstractLspAnalysisServerTest {
|
|||
expect(
|
||||
res,
|
||||
contains(
|
||||
Location(
|
||||
uri: mainFileUri.toString(), range: rangeFromMarkers(contents)),
|
||||
Location(uri: mainFileUri, range: rangeFromMarkers(contents)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ class RenameTest extends AbstractLspAnalysisServerTest {
|
|||
final request = makeRequest(
|
||||
Method.textDocument_prepareRename,
|
||||
TextDocumentPositionParams(
|
||||
textDocument: TextDocumentIdentifier(uri: mainFileUri.toString()),
|
||||
textDocument: TextDocumentIdentifier(uri: mainFileUri),
|
||||
position: positionFromMarker(content),
|
||||
),
|
||||
);
|
||||
|
@ -546,7 +546,7 @@ class RenameTest extends AbstractLspAnalysisServerTest {
|
|||
Method.textDocument_rename,
|
||||
RenameParams(
|
||||
newName: 'Object2',
|
||||
textDocument: TextDocumentIdentifier(uri: mainFileUri.toString()),
|
||||
textDocument: TextDocumentIdentifier(uri: mainFileUri),
|
||||
position: positionFromMarker(content),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -712,10 +712,10 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
|
||||
void applyChanges(
|
||||
Map<String, String> fileContents,
|
||||
Map<String, List<TextEdit>> changes,
|
||||
Map<Uri, List<TextEdit>> changes,
|
||||
) {
|
||||
changes.forEach((fileUri, edits) {
|
||||
final path = Uri.parse(fileUri).toFilePath();
|
||||
final path = fileUri.toFilePath();
|
||||
fileContents[path] = applyTextEdits(fileContents[path]!, edits);
|
||||
});
|
||||
}
|
||||
|
@ -750,7 +750,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
|
||||
void applyResourceCreate(
|
||||
Map<String, String> oldFileContent, CreateFile create) {
|
||||
final path = Uri.parse(create.uri).toFilePath();
|
||||
final path = create.uri.toFilePath();
|
||||
if (oldFileContent.containsKey(path)) {
|
||||
throw 'Received create instruction for $path which already existed.';
|
||||
}
|
||||
|
@ -759,8 +759,8 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
|
||||
void applyResourceRename(
|
||||
Map<String, String> oldFileContent, RenameFile rename) {
|
||||
final oldPath = Uri.parse(rename.oldUri).toFilePath();
|
||||
final newPath = Uri.parse(rename.newUri).toFilePath();
|
||||
final oldPath = rename.oldUri.toFilePath();
|
||||
final newPath = rename.newUri.toFilePath();
|
||||
if (!oldFileContent.containsKey(oldPath)) {
|
||||
throw 'Received rename instruction for $oldPath which did not exist.';
|
||||
}
|
||||
|
@ -775,7 +775,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
void applyTextDocumentEdits(
|
||||
Map<String, String> oldFileContent, List<TextDocumentEdit> edits) {
|
||||
for (var edit in edits) {
|
||||
final path = Uri.parse(edit.textDocument.uri).toFilePath();
|
||||
final path = edit.textDocument.uri.toFilePath();
|
||||
if (!oldFileContent.containsKey(path)) {
|
||||
throw 'Received edits for $path which was not provided as a file to be edited. '
|
||||
'Perhaps a CreateFile change was missing from the edits?';
|
||||
|
@ -883,8 +883,8 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
var notification = makeNotification(
|
||||
Method.textDocument_didChange,
|
||||
DidChangeTextDocumentParams(
|
||||
textDocument: VersionedTextDocumentIdentifier(
|
||||
version: newVersion, uri: uri.toString()),
|
||||
textDocument:
|
||||
VersionedTextDocumentIdentifier(version: newVersion, uri: uri),
|
||||
contentChanges: changes,
|
||||
),
|
||||
);
|
||||
|
@ -908,7 +908,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
var notification = makeNotification(
|
||||
Method.textDocument_didClose,
|
||||
DidCloseTextDocumentParams(
|
||||
textDocument: TextDocumentIdentifier(uri: uri.toString())),
|
||||
textDocument: TextDocumentIdentifier(uri: uri)),
|
||||
);
|
||||
await sendNotificationToServer(notification);
|
||||
}
|
||||
|
@ -952,7 +952,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
TextDocumentEdit edit,
|
||||
Map<String, int> expectedVersions,
|
||||
) {
|
||||
final path = Uri.parse(edit.textDocument.uri).toFilePath();
|
||||
final path = edit.textDocument.uri.toFilePath();
|
||||
final expectedVersion = expectedVersions[path];
|
||||
|
||||
expect(edit.textDocument.version, equals(expectedVersion));
|
||||
|
@ -1024,7 +1024,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
Future<T> expectSuccessfulResponseTo<T, R>(
|
||||
RequestMessage request, T Function(R) fromJson);
|
||||
|
||||
Future<List<TextEdit>?> formatDocument(String fileUri) {
|
||||
Future<List<TextEdit>?> formatDocument(Uri fileUri) {
|
||||
final request = makeRequest(
|
||||
Method.textDocument_formatting,
|
||||
DocumentFormattingParams(
|
||||
|
@ -1039,7 +1039,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
}
|
||||
|
||||
Future<List<TextEdit>?> formatOnType(
|
||||
String fileUri, Position pos, String character) {
|
||||
Uri fileUri, Position pos, String character) {
|
||||
final request = makeRequest(
|
||||
Method.textDocument_onTypeFormatting,
|
||||
DocumentOnTypeFormattingParams(
|
||||
|
@ -1055,7 +1055,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
request, _fromJsonList(TextEdit.fromJson));
|
||||
}
|
||||
|
||||
Future<List<TextEdit>?> formatRange(String fileUri, Range range) {
|
||||
Future<List<TextEdit>?> formatRange(Uri fileUri, Range range) {
|
||||
final request = makeRequest(
|
||||
Method.textDocument_rangeFormatting,
|
||||
DocumentRangeFormattingParams(
|
||||
|
@ -1071,7 +1071,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
}
|
||||
|
||||
Future<List<Either2<Command, CodeAction>>> getCodeActions(
|
||||
String fileUri, {
|
||||
Uri fileUri, {
|
||||
Range? range,
|
||||
Position? position,
|
||||
List<CodeActionKind>? kinds,
|
||||
|
@ -1103,7 +1103,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
}
|
||||
|
||||
Future<List<ColorPresentation>> getColorPresentation(
|
||||
String fileUri, Range range, Color color) {
|
||||
Uri fileUri, Range range, Color color) {
|
||||
final request = makeRequest(
|
||||
Method.textDocument_colorPresentation,
|
||||
ColorPresentationParams(
|
||||
|
@ -1130,7 +1130,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
Method.textDocument_completion,
|
||||
CompletionParams(
|
||||
context: context,
|
||||
textDocument: TextDocumentIdentifier(uri: uri.toString()),
|
||||
textDocument: TextDocumentIdentifier(uri: uri),
|
||||
position: pos,
|
||||
),
|
||||
);
|
||||
|
@ -1142,7 +1142,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
final request = makeRequest(
|
||||
Method.textDocument_definition,
|
||||
TextDocumentPositionParams(
|
||||
textDocument: TextDocumentIdentifier(uri: uri.toString()),
|
||||
textDocument: TextDocumentIdentifier(uri: uri),
|
||||
position: pos,
|
||||
),
|
||||
);
|
||||
|
@ -1181,7 +1181,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
return expectSuccessfulResponseTo(request, DartDiagnosticServer.fromJson);
|
||||
}
|
||||
|
||||
Future<List<ColorInformation>> getDocumentColors(String fileUri) {
|
||||
Future<List<ColorInformation>> getDocumentColors(Uri fileUri) {
|
||||
final request = makeRequest(
|
||||
Method.textDocument_documentColor,
|
||||
DocumentColorParams(
|
||||
|
@ -1199,7 +1199,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
final request = makeRequest(
|
||||
Method.textDocument_documentHighlight,
|
||||
TextDocumentPositionParams(
|
||||
textDocument: TextDocumentIdentifier(uri: uri.toString()),
|
||||
textDocument: TextDocumentIdentifier(uri: uri),
|
||||
position: pos,
|
||||
),
|
||||
);
|
||||
|
@ -1212,7 +1212,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
final request = makeRequest(
|
||||
Method.textDocument_documentSymbol,
|
||||
DocumentSymbolParams(
|
||||
textDocument: TextDocumentIdentifier(uri: uri.toString()),
|
||||
textDocument: TextDocumentIdentifier(uri: uri),
|
||||
),
|
||||
);
|
||||
return expectSuccessfulResponseTo(
|
||||
|
@ -1229,7 +1229,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
final request = makeRequest(
|
||||
Method.textDocument_foldingRange,
|
||||
FoldingRangeParams(
|
||||
textDocument: TextDocumentIdentifier(uri: uri.toString()),
|
||||
textDocument: TextDocumentIdentifier(uri: uri),
|
||||
),
|
||||
);
|
||||
return expectSuccessfulResponseTo(
|
||||
|
@ -1240,8 +1240,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
final request = makeRequest(
|
||||
Method.textDocument_hover,
|
||||
TextDocumentPositionParams(
|
||||
textDocument: TextDocumentIdentifier(uri: uri.toString()),
|
||||
position: pos),
|
||||
textDocument: TextDocumentIdentifier(uri: uri), position: pos),
|
||||
);
|
||||
return expectSuccessfulResponseTo(request, Hover.fromJson);
|
||||
}
|
||||
|
@ -1254,7 +1253,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
final request = makeRequest(
|
||||
Method.textDocument_implementation,
|
||||
TextDocumentPositionParams(
|
||||
textDocument: TextDocumentIdentifier(uri: uri.toString()),
|
||||
textDocument: TextDocumentIdentifier(uri: uri),
|
||||
position: pos,
|
||||
),
|
||||
);
|
||||
|
@ -1266,7 +1265,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
final request = makeRequest(
|
||||
Method.textDocument_inlayHint,
|
||||
InlayHintParams(
|
||||
textDocument: TextDocumentIdentifier(uri: uri.toString()),
|
||||
textDocument: TextDocumentIdentifier(uri: uri),
|
||||
range: range,
|
||||
),
|
||||
);
|
||||
|
@ -1283,7 +1282,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
Method.textDocument_references,
|
||||
ReferenceParams(
|
||||
context: ReferenceContext(includeDeclaration: includeDeclarations),
|
||||
textDocument: TextDocumentIdentifier(uri: uri.toString()),
|
||||
textDocument: TextDocumentIdentifier(uri: uri),
|
||||
position: pos,
|
||||
),
|
||||
);
|
||||
|
@ -1310,8 +1309,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
final request = makeRequest(
|
||||
Method.textDocument_selectionRange,
|
||||
SelectionRangeParams(
|
||||
textDocument: TextDocumentIdentifier(uri: uri.toString()),
|
||||
positions: positions),
|
||||
textDocument: TextDocumentIdentifier(uri: uri), positions: positions),
|
||||
);
|
||||
return expectSuccessfulResponseTo(
|
||||
request, _fromJsonList(SelectionRange.fromJson));
|
||||
|
@ -1321,7 +1319,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
final request = makeRequest(
|
||||
Method.textDocument_semanticTokens_full,
|
||||
SemanticTokensParams(
|
||||
textDocument: TextDocumentIdentifier(uri: uri.toString()),
|
||||
textDocument: TextDocumentIdentifier(uri: uri),
|
||||
),
|
||||
);
|
||||
return expectSuccessfulResponseTo(request, SemanticTokens.fromJson);
|
||||
|
@ -1331,7 +1329,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
final request = makeRequest(
|
||||
Method.textDocument_semanticTokens_range,
|
||||
SemanticTokensRangeParams(
|
||||
textDocument: TextDocumentIdentifier(uri: uri.toString()),
|
||||
textDocument: TextDocumentIdentifier(uri: uri),
|
||||
range: range,
|
||||
),
|
||||
);
|
||||
|
@ -1343,7 +1341,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
final request = makeRequest(
|
||||
Method.textDocument_signatureHelp,
|
||||
SignatureHelpParams(
|
||||
textDocument: TextDocumentIdentifier(uri: uri.toString()),
|
||||
textDocument: TextDocumentIdentifier(uri: uri),
|
||||
position: pos,
|
||||
context: context,
|
||||
),
|
||||
|
@ -1358,7 +1356,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
final request = makeRequest(
|
||||
CustomMethods.super_,
|
||||
TextDocumentPositionParams(
|
||||
textDocument: TextDocumentIdentifier(uri: uri.toString()),
|
||||
textDocument: TextDocumentIdentifier(uri: uri),
|
||||
position: pos,
|
||||
),
|
||||
);
|
||||
|
@ -1370,7 +1368,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
final request = makeRequest(
|
||||
Method.textDocument_typeDefinition,
|
||||
TypeDefinitionParams(
|
||||
textDocument: TextDocumentIdentifier(uri: uri.toString()),
|
||||
textDocument: TextDocumentIdentifier(uri: uri),
|
||||
position: pos,
|
||||
),
|
||||
);
|
||||
|
@ -1545,7 +1543,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
Method.initialize,
|
||||
InitializeParams(
|
||||
rootPath: rootPath,
|
||||
rootUri: rootUri?.toString(),
|
||||
rootUri: rootUri,
|
||||
initializationOptions:
|
||||
initializationOptions ?? defaultInitializationOptions,
|
||||
capabilities: clientCapabilities,
|
||||
|
@ -1582,8 +1580,8 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
RequestMessage makeRenameRequest(
|
||||
int? version, Uri uri, Position pos, String newName) {
|
||||
final docIdentifier = version != null
|
||||
? VersionedTextDocumentIdentifier(version: version, uri: uri.toString())
|
||||
: TextDocumentIdentifier(uri: uri.toString());
|
||||
? VersionedTextDocumentIdentifier(version: version, uri: uri)
|
||||
: TextDocumentIdentifier(uri: uri);
|
||||
final request = makeRequest(
|
||||
Method.textDocument_rename,
|
||||
RenameParams(
|
||||
|
@ -1662,7 +1660,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
Method.textDocument_didOpen,
|
||||
DidOpenTextDocumentParams(
|
||||
textDocument: TextDocumentItem(
|
||||
uri: uri.toString(),
|
||||
uri: uri,
|
||||
languageId: dartLanguageId,
|
||||
version: version,
|
||||
text: content)),
|
||||
|
@ -1693,7 +1691,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
final request = makeRequest(
|
||||
Method.textDocument_prepareCallHierarchy,
|
||||
CallHierarchyPrepareParams(
|
||||
textDocument: TextDocumentIdentifier(uri: uri.toString()),
|
||||
textDocument: TextDocumentIdentifier(uri: uri),
|
||||
position: pos,
|
||||
),
|
||||
);
|
||||
|
@ -1705,7 +1703,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
final request = makeRequest(
|
||||
Method.textDocument_prepareRename,
|
||||
TextDocumentPositionParams(
|
||||
textDocument: TextDocumentIdentifier(uri: uri.toString()),
|
||||
textDocument: TextDocumentIdentifier(uri: uri),
|
||||
position: pos,
|
||||
),
|
||||
);
|
||||
|
@ -1921,7 +1919,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
|
||||
WorkspaceFolder toWorkspaceFolder(Uri uri) {
|
||||
return WorkspaceFolder(
|
||||
uri: uri.toString(),
|
||||
uri: uri,
|
||||
name: path.basename(uri.path),
|
||||
);
|
||||
}
|
||||
|
@ -1993,7 +1991,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
closingLabelsParams = PublishClosingLabelsParams.fromJson(
|
||||
message.params as Map<String, Object?>);
|
||||
|
||||
return closingLabelsParams.uri == uri.toString();
|
||||
return closingLabelsParams.uri == uri;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
@ -2008,7 +2006,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
message.method == Method.textDocument_publishDiagnostics) {
|
||||
diagnosticParams = PublishDiagnosticsParams.fromJson(
|
||||
message.params as Map<String, Object?>);
|
||||
return diagnosticParams!.uri == uri.toString();
|
||||
return diagnosticParams!.uri == uri;
|
||||
}
|
||||
return false;
|
||||
}, orElse: () => null);
|
||||
|
@ -2023,7 +2021,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
outlineParams = PublishFlutterOutlineParams.fromJson(
|
||||
message.params as Map<String, Object?>);
|
||||
|
||||
return outlineParams.uri == uri.toString();
|
||||
return outlineParams.uri == uri;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
@ -2038,7 +2036,7 @@ mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
|
|||
outlineParams = PublishOutlineParams.fromJson(
|
||||
message.params as Map<String, Object?>);
|
||||
|
||||
return outlineParams.uri == uri.toString();
|
||||
return outlineParams.uri == uri;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
|
|
@ -86,8 +86,10 @@ class ServerTest extends AbstractLspAnalysisServerTest {
|
|||
Future<void> test_path_invalidFormat() async {
|
||||
await initialize();
|
||||
await expectLater(
|
||||
// Add some invalid path characters to the end of a valid file:// URI.
|
||||
formatDocument(mainFileUri.toString() + r'***###\\\///:::.dart'),
|
||||
formatDocument(
|
||||
// Add some invalid path characters to the end of a valid file:// URI.
|
||||
Uri.parse(mainFileUri.toString() + r'###***\\\///:::.dart'),
|
||||
),
|
||||
throwsA(isResponseError(ServerErrorCodes.InvalidFilePath,
|
||||
message: 'File URI did not contain a valid file path')),
|
||||
);
|
||||
|
|
|
@ -31,10 +31,8 @@ class C^ extends B {}
|
|||
positionFromMarker(content),
|
||||
);
|
||||
|
||||
expect(
|
||||
res,
|
||||
equals(Location(
|
||||
uri: mainFileUri.toString(), range: rangeFromMarkers(content))));
|
||||
expect(res,
|
||||
equals(Location(uri: mainFileUri, range: rangeFromMarkers(content))));
|
||||
}
|
||||
|
||||
Future<void> test_insideClass() async {
|
||||
|
@ -54,10 +52,8 @@ class C extends B {
|
|||
positionFromMarker(content),
|
||||
);
|
||||
|
||||
expect(
|
||||
res,
|
||||
equals(Location(
|
||||
uri: mainFileUri.toString(), range: rangeFromMarkers(content))));
|
||||
expect(res,
|
||||
equals(Location(uri: mainFileUri, range: rangeFromMarkers(content))));
|
||||
}
|
||||
|
||||
Future<void> test_insideMethod() async {
|
||||
|
@ -82,10 +78,8 @@ class C extends B {
|
|||
positionFromMarker(content),
|
||||
);
|
||||
|
||||
expect(
|
||||
res,
|
||||
equals(Location(
|
||||
uri: mainFileUri.toString(), range: rangeFromMarkers(content))));
|
||||
expect(res,
|
||||
equals(Location(uri: mainFileUri, range: rangeFromMarkers(content))));
|
||||
}
|
||||
|
||||
Future<void> test_methodName() async {
|
||||
|
@ -110,10 +104,8 @@ class C extends B {
|
|||
positionFromMarker(content),
|
||||
);
|
||||
|
||||
expect(
|
||||
res,
|
||||
equals(Location(
|
||||
uri: mainFileUri.toString(), range: rangeFromMarkers(content))));
|
||||
expect(res,
|
||||
equals(Location(uri: mainFileUri, range: rangeFromMarkers(content))));
|
||||
}
|
||||
|
||||
Future<void> test_methodReturnType() async {
|
||||
|
@ -138,9 +130,7 @@ class C extends B {
|
|||
positionFromMarker(content),
|
||||
);
|
||||
|
||||
expect(
|
||||
res,
|
||||
equals(Location(
|
||||
uri: mainFileUri.toString(), range: rangeFromMarkers(content))));
|
||||
expect(res,
|
||||
equals(Location(uri: mainFileUri, range: rangeFromMarkers(content))));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ final [[a^]] = A();
|
|||
final originRange = ranges[1];
|
||||
final result = await _getResult(contents);
|
||||
expect(result.originSelectionRange, originRange);
|
||||
expect(result.targetUri, mainFileUri.toString());
|
||||
expect(result.targetUri, mainFileUri);
|
||||
expect(result.targetSelectionRange, targetRange);
|
||||
expect(result.targetRange, rangeOfString(contents, 'class A {}'));
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ const a^ = 'test string';
|
|||
''';
|
||||
|
||||
final result = await _getLocationResult(contents);
|
||||
expect(result.uri, '$sdkCoreUri');
|
||||
expect(result.uri, sdkCoreUri);
|
||||
_expectNameRange(result.range, 'String');
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ class [[A]] {}
|
|||
newFile(otherFilePath, withoutMarkers(otherContents));
|
||||
final result = await _getResult(contents);
|
||||
expect(result.originSelectionRange, rangeFromMarkers(contents));
|
||||
expect(result.targetUri, otherFileUri.toString());
|
||||
expect(result.targetUri, otherFileUri);
|
||||
expect(result.targetSelectionRange, rangeFromMarkers(otherContents));
|
||||
expect(result.targetRange, rangeOfString(otherContents, 'class A {}'));
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ void f() {
|
|||
/// This is used for SDK sources where the exact location is not known to the
|
||||
/// test.
|
||||
void _expectSdkCoreType(LocationLink result, String typeName) {
|
||||
expect(result.targetUri, '$sdkCoreUri');
|
||||
expect(result.targetUri, sdkCoreUri);
|
||||
_expectNameRange(result.targetSelectionRange, typeName);
|
||||
_expectCodeRange(result.targetRange);
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ class WorkspaceSymbolsTest extends AbstractLspAnalysisServerTest {
|
|||
final topLevel = symbols.firstWhere((s) => s.name == 'topLevel');
|
||||
expect(topLevel.kind, equals(SymbolKind.Variable));
|
||||
expect(topLevel.containerName, isNull);
|
||||
expect(topLevel.location.uri, equals(mainFileUri.toString()));
|
||||
expect(topLevel.location.uri, equals(mainFileUri));
|
||||
expect(topLevel.location.range, equals(rangeFromMarkers(content)));
|
||||
|
||||
// Ensure we didn't get some things that definitely do not match.
|
||||
|
@ -117,7 +117,7 @@ class WorkspaceSymbolsTest extends AbstractLspAnalysisServerTest {
|
|||
final field = symbols.firstWhere((s) => s.name == 'myField');
|
||||
expect(field.kind, equals(SymbolKind.Field));
|
||||
expect(field.containerName, equals('MyClass'));
|
||||
expect(field.location.uri, equals(mainFileUri.toString()));
|
||||
expect(field.location.uri, equals(mainFileUri));
|
||||
expect(field.location.range, equals(rangeFromMarkers(content)));
|
||||
|
||||
// Ensure we didn't get some things that definitely do not match.
|
||||
|
@ -192,25 +192,25 @@ class WorkspaceSymbolsTest extends AbstractLspAnalysisServerTest {
|
|||
final field = symbols.firstWhere((s) => s.name == 'myField');
|
||||
expect(field.kind, equals(SymbolKind.Field));
|
||||
expect(field.containerName, equals('MyClass'));
|
||||
expect(field.location.uri, equals(mainFileUri.toString()));
|
||||
expect(field.location.uri, equals(mainFileUri));
|
||||
expect(field.location.range, equals(fieldRange));
|
||||
|
||||
final klass = symbols.firstWhere((s) => s.name == 'MyClass');
|
||||
expect(klass.kind, equals(SymbolKind.Class));
|
||||
expect(klass.containerName, isNull);
|
||||
expect(klass.location.uri, equals(mainFileUri.toString()));
|
||||
expect(klass.location.uri, equals(mainFileUri));
|
||||
|
||||
final method = symbols.firstWhere((s) => s.name == 'myMethod()');
|
||||
expect(method.kind, equals(SymbolKind.Method));
|
||||
expect(method.containerName, equals('MyClass'));
|
||||
expect(method.location.uri, equals(mainFileUri.toString()));
|
||||
expect(method.location.uri, equals(mainFileUri));
|
||||
expect(method.location.range, equals(methodRange));
|
||||
|
||||
final methodWithArgs =
|
||||
symbols.firstWhere((s) => s.name == 'myMethodWithArgs(…)');
|
||||
expect(methodWithArgs.kind, equals(SymbolKind.Method));
|
||||
expect(methodWithArgs.containerName, equals('MyClass'));
|
||||
expect(methodWithArgs.location.uri, equals(mainFileUri.toString()));
|
||||
expect(methodWithArgs.location.uri, equals(mainFileUri));
|
||||
expect(methodWithArgs.location.range, equals(methodWithArgsRange));
|
||||
|
||||
// Ensure we didn't get some things that definitely do not match.
|
||||
|
|
|
@ -74,7 +74,7 @@ abstract class RefactoringTest extends AbstractLspAnalysisServerTest {
|
|||
expect(changes.length, changedFiles.length);
|
||||
var contents = <String, String>{};
|
||||
for (var entry in changes.entries) {
|
||||
var filePath = Uri.parse(entry.key).path;
|
||||
var filePath = entry.key.path;
|
||||
expect(changedFiles[filePath], isNotNull);
|
||||
var file = resourceProvider.getFile(filePath);
|
||||
if (file.exists) {
|
||||
|
|
|
@ -8,8 +8,8 @@ import 'package:test/test.dart';
|
|||
void main() {
|
||||
group('generated classes', () {
|
||||
test('can be checked for equality', () {
|
||||
final a = TextDocumentIdentifier(uri: '/a');
|
||||
final b = TextDocumentIdentifier(uri: '/a');
|
||||
final a = TextDocumentIdentifier(uri: Uri.file('/a'));
|
||||
final b = TextDocumentIdentifier(uri: Uri.file('/a'));
|
||||
|
||||
expect(a, equals(b));
|
||||
expect(a.hashCode, equals(b.hashCode));
|
||||
|
@ -41,7 +41,7 @@ void main() {
|
|||
|
||||
test('with map fields can be checked for equality', () {
|
||||
final a = WorkspaceEdit(changes: {
|
||||
'a': [
|
||||
Uri.file('/a'): [
|
||||
TextEdit(
|
||||
range: Range(
|
||||
start: Position(line: 0, character: 0),
|
||||
|
@ -50,7 +50,7 @@ void main() {
|
|||
]
|
||||
});
|
||||
final b = WorkspaceEdit(changes: {
|
||||
'a': [
|
||||
Uri.file('/a'): [
|
||||
TextEdit(
|
||||
range: Range(
|
||||
start: Position(line: 0, character: 0),
|
||||
|
|
|
@ -38,7 +38,7 @@ void main() {
|
|||
Either2<List<Location>, Location>.t1([
|
||||
Location(
|
||||
range: range,
|
||||
uri: '!uri',
|
||||
uri: Uri.parse('http://example.org/'),
|
||||
)
|
||||
])),
|
||||
jsonrpc: jsonRpcVersion,
|
||||
|
@ -49,23 +49,27 @@ void main() {
|
|||
equals(
|
||||
'{"id":1,"jsonrpc":"2.0",'
|
||||
'"result":[{"range":{"end":{"character":2,"line":2},"start":{"character":1,"line":1}},'
|
||||
'"uri":"!uri"}]}',
|
||||
'"uri":"http://example.org/"}]}',
|
||||
));
|
||||
});
|
||||
|
||||
test('returns correct output for union types containing interface types',
|
||||
() {
|
||||
final params = Either2<String, TextDocumentItem>.t2(TextDocumentItem(
|
||||
uri: '!uri', languageId: '!language', version: 1, text: '!text'));
|
||||
uri: Uri.parse('http://example.org/'),
|
||||
languageId: '!language',
|
||||
version: 1,
|
||||
text: '!text'));
|
||||
final output = json.encode(params);
|
||||
expect(
|
||||
output,
|
||||
equals(
|
||||
'{"languageId":"!language","text":"!text","uri":"!uri","version":1}'));
|
||||
'{"languageId":"!language","text":"!text","uri":"http://example.org/","version":1}'));
|
||||
});
|
||||
|
||||
test('returns correct output for types with lists', () {
|
||||
final location = Location(uri: 'y-uri', range: range);
|
||||
final location =
|
||||
Location(uri: Uri.parse('http://example.org/'), range: range);
|
||||
final codeAction = Diagnostic(
|
||||
range: range,
|
||||
severity: DiagnosticSeverity.Error,
|
||||
|
@ -91,7 +95,7 @@ void main() {
|
|||
"end":{"character":2,"line":2},
|
||||
"start":{"character":1,"line":1}
|
||||
},
|
||||
"uri":"y-uri"
|
||||
"uri":"http://example.org/"
|
||||
},
|
||||
"message":"message"
|
||||
}
|
||||
|
@ -317,7 +321,7 @@ void main() {
|
|||
);
|
||||
expect(reporter.errors, hasLength(greaterThanOrEqualTo(1)));
|
||||
expect(reporter.errors.first,
|
||||
equals('params.textDocument.uri must be of type String'));
|
||||
equals('params.textDocument.uri must be of type Uri'));
|
||||
});
|
||||
|
||||
test(
|
||||
|
@ -407,7 +411,7 @@ void main() {
|
|||
// where the class definition only references a TextDocumentIdentifier.
|
||||
final input = jsonEncode(TextDocumentPositionParams(
|
||||
textDocument: VersionedTextDocumentIdentifier(
|
||||
version: 111, uri: 'file:///foo/bar.dart'),
|
||||
version: 111, uri: Uri.file('/foo/bar.dart')),
|
||||
position: Position(line: 1, character: 1),
|
||||
).toJson());
|
||||
final params = TextDocumentPositionParams.fromJson(
|
||||
|
@ -439,8 +443,8 @@ void main() {
|
|||
|
||||
test('objects with lists can round-trip through to json and back', () {
|
||||
final workspaceFolders = [
|
||||
WorkspaceFolder(uri: '!uri1', name: '!name1'),
|
||||
WorkspaceFolder(uri: '!uri2', name: '!name2'),
|
||||
WorkspaceFolder(uri: Uri.parse('http://example.org/1'), name: '!name1'),
|
||||
WorkspaceFolder(uri: Uri.parse('http://example.org/2'), name: '!name2'),
|
||||
];
|
||||
final obj = InitializeParams(
|
||||
processId: 1,
|
||||
|
@ -486,9 +490,9 @@ void main() {
|
|||
final start = Position(line: 1, character: 1);
|
||||
final end = Position(line: 2, character: 2);
|
||||
final range = Range(start: start, end: end);
|
||||
final obj = WorkspaceEdit(changes: <String, List<TextEdit>>{
|
||||
'fileA': [TextEdit(range: range, newText: 'text A')],
|
||||
'fileB': [TextEdit(range: range, newText: 'text B')]
|
||||
final obj = WorkspaceEdit(changes: <Uri, List<TextEdit>>{
|
||||
Uri.file('/fileA'): [TextEdit(range: range, newText: 'text A')],
|
||||
Uri.file('/fileB'): [TextEdit(range: range, newText: 'text B')]
|
||||
});
|
||||
final json = jsonEncode(obj);
|
||||
final restoredObj =
|
||||
|
|
|
@ -237,6 +237,11 @@ bool _isSpecType(TypeBase type) {
|
|||
(_namespaces.containsKey(type.name)));
|
||||
}
|
||||
|
||||
bool _isUriType(TypeBase type) {
|
||||
type = resolveTypeAlias(type);
|
||||
return type is TypeReference && type.dartType == 'Uri';
|
||||
}
|
||||
|
||||
/// Maps reserved words and identifiers that cause issues in field names.
|
||||
String _makeValidIdentifier(String identifier) {
|
||||
// Some identifiers used in LSP are reserved words in Dart, so map them to
|
||||
|
@ -684,6 +689,17 @@ void _writeFromJsonCode(
|
|||
|
||||
if (_isSimpleType(type)) {
|
||||
buffer.write('$valueCode$cast');
|
||||
} else if (_isUriType(type)) {
|
||||
if (allowsNull) {
|
||||
buffer.write('$valueCode != null ? ');
|
||||
}
|
||||
buffer
|
||||
..write('Uri.parse(')
|
||||
..write(requiresCast ? '$valueCode as String' : valueCode)
|
||||
..write(')');
|
||||
if (allowsNull) {
|
||||
buffer.write(': null');
|
||||
}
|
||||
} else if (_isSpecType(type)) {
|
||||
// Our own types have fromJson() constructors we can call.
|
||||
if (allowsNull) {
|
||||
|
@ -973,6 +989,15 @@ void _writeToJsonCode(IndentableStringBuffer buffer, TypeBase type,
|
|||
buffer.write('$valueCode$nullOp.map((item) => ');
|
||||
_writeToJsonCode(buffer, type.elementType, 'item', '');
|
||||
buffer.write(').toList()');
|
||||
} else if (type is MapType &&
|
||||
(_isUriType(type.indexType) || _isUriType(type.valueType))) {
|
||||
buffer.write('$valueCode$nullOp.map((key, value) => MapEntry(');
|
||||
_writeToJsonCode(buffer, type.indexType, 'key', '');
|
||||
buffer.write(', ');
|
||||
_writeToJsonCode(buffer, type.valueType, 'value', '');
|
||||
buffer.write('))');
|
||||
} else if (_isUriType(type)) {
|
||||
buffer.write('$valueCode$nullOp.toString()');
|
||||
} else {
|
||||
buffer.write(valueCode);
|
||||
}
|
||||
|
@ -1076,17 +1101,22 @@ void _writeTypeCheckCondition(IndentableStringBuffer buffer,
|
|||
|
||||
final operator = negation ? '!' : '';
|
||||
final and = negation ? '||' : '&&';
|
||||
final or = negation ? '&&' : '||';
|
||||
final every = negation ? 'any' : 'every';
|
||||
final equals = negation ? '!=' : '==';
|
||||
final notEqual = negation ? '==' : '!=';
|
||||
final true_ = negation ? 'false' : 'true';
|
||||
|
||||
if (isNullableAnyType(type)) {
|
||||
buffer.write(negation ? 'false' : 'true');
|
||||
buffer.write(true_);
|
||||
} else if (isObjectType(type)) {
|
||||
final notEqual = negation ? '==' : '!=';
|
||||
buffer.write('$valueCode $notEqual null');
|
||||
} else if (_isSimpleType(type)) {
|
||||
buffer.write('$valueCode is$operator $fullDartType');
|
||||
} else if (_isUriType(type)) {
|
||||
buffer.write('($valueCode is$operator String $and '
|
||||
'Uri.tryParse($valueCode) $notEqual null)');
|
||||
} else if (type is LiteralType) {
|
||||
final equals = negation ? '!=' : '==';
|
||||
buffer.write('$valueCode $equals literal');
|
||||
} else if (type is LiteralUnionType) {
|
||||
buffer.write('${operator}literals.contains(value)');
|
||||
|
@ -1132,7 +1162,7 @@ void _writeTypeCheckCondition(IndentableStringBuffer buffer,
|
|||
if (parenForCollection) {
|
||||
buffer.write('(');
|
||||
}
|
||||
var or = negation ? '&&' : '||';
|
||||
|
||||
// To type check a union, we just recursively check against each of its types.
|
||||
for (var i = 0; i < type.types.length; i++) {
|
||||
if (i != 0) {
|
||||
|
|
|
@ -236,15 +236,20 @@ List<LspEntity> getCustomClasses() {
|
|||
),
|
||||
TypeAlias(
|
||||
name: 'DocumentUri',
|
||||
baseType: TypeReference('string'),
|
||||
baseType: TypeReference('Uri'),
|
||||
isRename: false,
|
||||
),
|
||||
TypeAlias(
|
||||
name: 'LSPUri',
|
||||
baseType: TypeReference('Uri'),
|
||||
isRename: false,
|
||||
),
|
||||
|
||||
interface('DartDiagnosticServer', [field('port', type: 'int')]),
|
||||
interface('AnalyzerStatusParams', [field('isAnalyzing', type: 'boolean')]),
|
||||
interface('PublishClosingLabelsParams', [
|
||||
field('uri', type: 'string'),
|
||||
field('labels', type: 'ClosingLabel', array: true)
|
||||
field('uri', type: 'Uri'),
|
||||
field('labels', type: 'ClosingLabel', array: true),
|
||||
]),
|
||||
interface('ClosingLabel',
|
||||
[field('range', type: 'Range'), field('label', type: 'string')]),
|
||||
|
@ -257,16 +262,16 @@ List<LspEntity> getCustomClasses() {
|
|||
field('returnType', type: 'string', canBeUndefined: true),
|
||||
]),
|
||||
interface('PublishOutlineParams',
|
||||
[field('uri', type: 'string'), field('outline', type: 'Outline')]),
|
||||
[field('uri', type: 'Uri'), field('outline', type: 'Outline')]),
|
||||
interface('Outline', [
|
||||
field('element', type: 'Element'),
|
||||
field('range', type: 'Range'),
|
||||
field('codeRange', type: 'Range'),
|
||||
field('children', type: 'Outline', array: true, canBeUndefined: true)
|
||||
field('children', type: 'Outline', array: true, canBeUndefined: true),
|
||||
]),
|
||||
interface('PublishFlutterOutlineParams', [
|
||||
field('uri', type: 'string'),
|
||||
field('outline', type: 'FlutterOutline')
|
||||
field('uri', type: 'Uri'),
|
||||
field('outline', type: 'FlutterOutline'),
|
||||
]),
|
||||
interface('FlutterOutline', [
|
||||
field('kind', type: 'string'),
|
||||
|
@ -279,7 +284,7 @@ List<LspEntity> getCustomClasses() {
|
|||
field('range', type: 'Range'),
|
||||
field('codeRange', type: 'Range'),
|
||||
field('children',
|
||||
type: 'FlutterOutline', array: true, canBeUndefined: true)
|
||||
type: 'FlutterOutline', array: true, canBeUndefined: true),
|
||||
]),
|
||||
interface(
|
||||
'FlutterOutlineAttribute',
|
||||
|
|
|
@ -39,7 +39,9 @@ class LspMetaModelCleaner {
|
|||
.where((type) => _includeTypeInOutput(type.name))
|
||||
.map(_clean)
|
||||
.toList();
|
||||
types = _renameTypes(types).toList();
|
||||
types = _renameTypes(types)
|
||||
.where((type) => _includeTypeInOutput(type.name))
|
||||
.toList();
|
||||
return types;
|
||||
}
|
||||
|
||||
|
@ -293,6 +295,7 @@ class LspMetaModelCleaner {
|
|||
// unions with so many types).
|
||||
'LSPAny',
|
||||
'LSPObject',
|
||||
'LSPUri',
|
||||
// The meta model currently includes an unwanted type named 'T' that we
|
||||
// don't want to create a class for.
|
||||
// TODO(dantup): Remove this once it's gone from the JSON model.
|
||||
|
@ -303,7 +306,7 @@ class LspMetaModelCleaner {
|
|||
// when getting the .dartType for it.
|
||||
'MarkedString'
|
||||
};
|
||||
final shouldIgnore = ignoredTypes.contains(name) ||
|
||||
var shouldIgnore = ignoredTypes.contains(name) ||
|
||||
ignoredPrefixes.any((ignore) => name.startsWith(ignore));
|
||||
return !shouldIgnore;
|
||||
}
|
||||
|
@ -365,7 +368,7 @@ class LspMetaModelCleaner {
|
|||
'TextDocumentFilter2': 'TextDocumentFilterWithScheme',
|
||||
'PrepareRenameResult1': 'PlaceholderAndRange',
|
||||
'Pattern': 'LspPattern',
|
||||
'URI': 'LspUri',
|
||||
'URI': 'LSPUri',
|
||||
};
|
||||
|
||||
for (final type in types) {
|
||||
|
|
Loading…
Reference in a new issue