[analysis_server] Remove support for macro virtual files / DartTextDocumentContentProvider

This removes all code related to handling requests for (and sending notifications of modifications of) the virtual files for macros.

Clients would never call this handler unless the analysis server had previously told them about these virtual files with the `dart-macro+file` scheme, which never happens because the implementation was previously removed.

This does not remove the `clientUriConverter` (which as well as handling conversions to/from the macro scheme, also handles conversions between URIs and Paths to support using URIs in the legacy protocol) because I'm not yet certain that is unused.

Change-Id: I148e2383a48b5f6e3a28eff3dd11506fc86353b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461120
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Danny Tuppeny
2025-11-11 11:04:49 -08:00
committed by Commit Queue
parent 3c522839cf
commit 70358239d8
19 changed files with 5 additions and 573 deletions
@@ -1168,218 +1168,6 @@ class DartDiagnosticServer implements ToJsonable {
}
}
class DartTextDocumentContent implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DartTextDocumentContent.canParse,
DartTextDocumentContent.fromJson,
);
final String? content;
DartTextDocumentContent({
this.content,
});
@override
int get hashCode => content.hashCode;
@override
bool operator ==(Object other) {
return other is DartTextDocumentContent &&
other.runtimeType == DartTextDocumentContent &&
content == other.content;
}
@override
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['content'] = content;
return result;
}
@override
String toString() => jsonEncoder.convert(toJson());
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
return _canParseString(obj, reporter, 'content',
allowsUndefined: false, allowsNull: true);
} else {
reporter.reportError('must be of type DartTextDocumentContent');
return false;
}
}
static DartTextDocumentContent fromJson(Map<String, Object?> json) {
final contentJson = json['content'];
final content = contentJson as String?;
return DartTextDocumentContent(
content: content,
);
}
}
class DartTextDocumentContentDidChangeParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DartTextDocumentContentDidChangeParams.canParse,
DartTextDocumentContentDidChangeParams.fromJson,
);
final DocumentUri uri;
DartTextDocumentContentDidChangeParams({
required this.uri,
});
@override
int get hashCode => uri.hashCode;
@override
bool operator ==(Object other) {
return other is DartTextDocumentContentDidChangeParams &&
other.runtimeType == DartTextDocumentContentDidChangeParams &&
uri == other.uri;
}
@override
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['uri'] = uri.toString();
return result;
}
@override
String toString() => jsonEncoder.convert(toJson());
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
return _canParseUri(obj, reporter, 'uri',
allowsUndefined: false, allowsNull: false);
} else {
reporter.reportError(
'must be of type DartTextDocumentContentDidChangeParams');
return false;
}
}
static DartTextDocumentContentDidChangeParams fromJson(
Map<String, Object?> json) {
final uriJson = json['uri'];
final uri = Uri.parse(uriJson as String);
return DartTextDocumentContentDidChangeParams(
uri: uri,
);
}
}
class DartTextDocumentContentParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DartTextDocumentContentParams.canParse,
DartTextDocumentContentParams.fromJson,
);
final DocumentUri uri;
DartTextDocumentContentParams({
required this.uri,
});
@override
int get hashCode => uri.hashCode;
@override
bool operator ==(Object other) {
return other is DartTextDocumentContentParams &&
other.runtimeType == DartTextDocumentContentParams &&
uri == other.uri;
}
@override
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['uri'] = uri.toString();
return result;
}
@override
String toString() => jsonEncoder.convert(toJson());
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
return _canParseUri(obj, reporter, 'uri',
allowsUndefined: false, allowsNull: false);
} else {
reporter.reportError('must be of type DartTextDocumentContentParams');
return false;
}
}
static DartTextDocumentContentParams fromJson(Map<String, Object?> json) {
final uriJson = json['uri'];
final uri = Uri.parse(uriJson as String);
return DartTextDocumentContentParams(
uri: uri,
);
}
}
class DartTextDocumentContentProviderRegistrationOptions implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DartTextDocumentContentProviderRegistrationOptions.canParse,
DartTextDocumentContentProviderRegistrationOptions.fromJson,
);
/// A set of URI schemes the server can provide content for. The server may
/// also return URIs with these schemes in responses to other requests.
final List<String> schemes;
DartTextDocumentContentProviderRegistrationOptions({
required this.schemes,
});
@override
int get hashCode => lspHashCode(schemes);
@override
bool operator ==(Object other) {
return other is DartTextDocumentContentProviderRegistrationOptions &&
other.runtimeType ==
DartTextDocumentContentProviderRegistrationOptions &&
const DeepCollectionEquality().equals(schemes, other.schemes);
}
@override
Map<String, Object?> toJson() {
var result = <String, Object?>{};
result['schemes'] = schemes;
return result;
}
@override
String toString() => jsonEncoder.convert(toJson());
static bool canParse(Object? obj, LspJsonReporter reporter) {
if (obj is Map<String, Object?>) {
return _canParseListString(obj, reporter, 'schemes',
allowsUndefined: false, allowsNull: false);
} else {
reporter.reportError(
'must be of type DartTextDocumentContentProviderRegistrationOptions');
return false;
}
}
static DartTextDocumentContentProviderRegistrationOptions fromJson(
Map<String, Object?> json) {
final schemesJson = json['schemes'];
final schemes =
(schemesJson as List<Object?>).map((item) => item as String).toList();
return DartTextDocumentContentProviderRegistrationOptions(
schemes: schemes,
);
}
}
class DartTextDocumentSummaryParams implements ToJsonable {
static const jsonHandler = LspJsonHandler(
DartTextDocumentSummaryParams.canParse,