Skip to content

Commit 7035823

Browse files
DanTupCommit Queue
authored andcommitted
[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>
1 parent 3c52283 commit 7035823

19 files changed

+5
-573
lines changed

pkg/analysis_server/integration_test/lsp/abstract_lsp_over_legacy.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ abstract class AbstractLspOverLegacyTest
2222
ClientCapabilitiesHelperMixin,
2323
LspRequestHelpersMixin,
2424
LspReverseRequestHelpersMixin,
25-
LspNotificationHelpersMixin,
2625
LspEditHelpersMixin,
2726
LspVerifyEditHelpersMixin {
2827
late final testFile = sourcePath('lib/main.dart');
@@ -37,7 +36,6 @@ abstract class AbstractLspOverLegacyTest
3736
final _overlayContent = <String, String>{};
3837

3938
/// A stream of LSP [NotificationMessage]s from the server.
40-
@override
4139
Stream<NotificationMessage> get notificationsFromServer =>
4240
onLspNotification.map(
4341
(params) => NotificationMessage.fromJson(

pkg/analysis_server/integration_test/lsp_server/integration_tests.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ abstract class AbstractLspAnalysisServerIntegrationTest
2626
ClientCapabilitiesHelperMixin,
2727
LspRequestHelpersMixin,
2828
LspReverseRequestHelpersMixin,
29-
LspNotificationHelpersMixin,
3029
LspEditHelpersMixin,
3130
LspVerifyEditHelpersMixin,
3231
LspAnalysisServerTestMixin {

pkg/analysis_server/lib/src/analysis_server.dart

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,23 +1246,6 @@ abstract class CommonServerContextManagerCallbacks
12461246
var path = result.path;
12471247
filesToFlush.add(path);
12481248

1249-
// If this is a virtual file and the client supports URIs, we need to notify
1250-
// that it's been updated.
1251-
var lspUri = analysisServer.uriConverter.toClientUri(result.path);
1252-
if (!lspUri.isScheme('file')) {
1253-
// TODO(dantup): Should we do any kind of tracking here to avoid sending
1254-
// lots of notifications if there aren't actual changes?
1255-
// TODO(dantup): We may be able to skip sending this if the file is not
1256-
// open (priority) depending on the response to
1257-
// https://github.com/microsoft/vscode/issues/202017
1258-
var message = lsp.NotificationMessage(
1259-
method: lsp.CustomMethods.dartTextDocumentContentDidChange,
1260-
params: lsp.DartTextDocumentContentDidChangeParams(uri: lspUri),
1261-
jsonrpc: lsp.jsonRpcVersion,
1262-
);
1263-
analysisServer.sendLspNotification(message);
1264-
}
1265-
12661249
if (result is AnalysisResultWithDiagnostics) {
12671250
if (analysisServer.isAnalyzed(path)) {
12681251
var serverErrors = server.doAnalysisError_listFromEngine(result);

pkg/analysis_server/lib/src/legacy_analysis_server.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,9 @@ class LegacyAnalysisServer extends AnalysisServer {
482482
set clientCapabilities(ServerSetClientCapabilitiesParams capabilities) {
483483
_clientCapabilities = capabilities;
484484

485+
// TODO(dantup): If we can confirm that IntelliJ did not ship code that
486+
// sets supportsUris=true, then we may be able to entirely remove the
487+
// uriConverter and all the calls through it.
485488
if (capabilities.supportsUris ?? false) {
486489
// URI support implies LSP, as that's the only way to access (and get
487490
// change notifications for) custom-scheme files.

pkg/analysis_server/lib/src/lsp/client_capabilities.dart

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,6 @@
44

55
import 'package:analysis_server/lsp_protocol/protocol.dart';
66

7-
/// The key in the client capabilities experimental object that enables the Dart
8-
/// TextDocumentContentProvider.
9-
///
10-
/// The presence of this key indicates that the client supports our
11-
/// (non-standard) way of using TextDocumentContentProvider. This will need to
12-
/// continue to be supported after switching to standard LSP support for some
13-
/// period to support outdated extensions.
14-
const dartExperimentalTextDocumentContentProviderKey =
15-
'supportsDartTextDocumentContentProvider';
16-
17-
/// The original key used for [dartExperimentalTextDocumentContentProviderKey].
18-
///
19-
/// This is temporarily supported to avoid the macro support vanishing for users
20-
/// for a period if their SDK is updated before Dart-Code passes the standard
21-
/// flag.
22-
///
23-
const dartExperimentalTextDocumentContentProviderLegacyKey =
24-
// TODO(dantup): Remove this after the next beta branch.
25-
'supportsDartTextDocumentContentProviderEXP1';
26-
277
/// A fixed set of ClientCapabilities used for clients that may execute LSP
288
/// requests without performing standard LSP initialization (such as a DTD
299
/// client or LSP-over-Legacy).
@@ -127,11 +107,6 @@ class LspClientCapabilities {
127107
final Set<String> codeActionCommandParameterSupportedKinds;
128108
final bool supportsShowMessageRequest;
129109

130-
/// Whether the client supports the custom Dart TextDocumentContentProvider,
131-
/// meaning it can request file contents from the server for custom URI
132-
/// schemes.
133-
final bool supportsDartExperimentalTextDocumentContentProvider;
134-
135110
/// A set of commands that exist on the client that the server may call.
136111
final Set<String> supportedCommands;
137112

@@ -251,8 +226,6 @@ class LspClientCapabilities {
251226
codeActionCommandParameterSupportedKinds:
252227
experimental.commandParameterKinds,
253228
supportsShowMessageRequest: experimental.showMessageRequest,
254-
supportsDartExperimentalTextDocumentContentProvider:
255-
experimental.dartTextDocumentContentProvider,
256229
supportedCommands: experimental.commands,
257230
experimentalCapabilitiesErrors: experimental.errors,
258231
);
@@ -293,7 +266,6 @@ class LspClientCapabilities {
293266
required this.experimentalSnippetTextEdit,
294267
required this.codeActionCommandParameterSupportedKinds,
295268
required this.supportsShowMessageRequest,
296-
required this.supportsDartExperimentalTextDocumentContentProvider,
297269
required this.supportedCommands,
298270
required this.experimentalCapabilitiesErrors,
299271
});
@@ -319,14 +291,12 @@ class _ExperimentalClientCapabilities {
319291

320292
final bool snippetTextEdit;
321293
final Set<String> commandParameterKinds;
322-
final bool dartTextDocumentContentProvider;
323294
final Set<String> commands;
324295
final bool showMessageRequest;
325296

326297
_ExperimentalClientCapabilities({
327298
required this.snippetTextEdit,
328299
required this.commandParameterKinds,
329-
required this.dartTextDocumentContentProvider,
330300
required this.commands,
331301
required this.showMessageRequest,
332302
required this.errors,
@@ -392,15 +362,6 @@ class _ExperimentalClientCapabilities {
392362
commandParameters['supportedKinds'],
393363
);
394364

395-
// Macro/Augmentation content.
396-
var dartContentValue =
397-
experimental[dartExperimentalTextDocumentContentProviderKey] ??
398-
experimental[dartExperimentalTextDocumentContentProviderLegacyKey];
399-
var dartTextDocumentContentProvider = expectBool(
400-
'.$dartExperimentalTextDocumentContentProviderKey',
401-
dartContentValue,
402-
);
403-
404365
// Executable commands.
405366
var commands = expectNullableStringSet(
406367
'.commands',
@@ -423,7 +384,6 @@ class _ExperimentalClientCapabilities {
423384
return _ExperimentalClientCapabilities(
424385
snippetTextEdit: snippetTextEdit ?? false,
425386
commandParameterKinds: commandParameterKinds ?? {},
426-
dartTextDocumentContentProvider: dartTextDocumentContentProvider ?? false,
427387
commands: commands ?? {},
428388
showMessageRequest: showMessageRequest ?? false,
429389
errors: errors,

pkg/analysis_server/lib/src/lsp/constants.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@ abstract final class CustomMethods {
152152
static const summary = Method('dart/textDocument/summary');
153153
static const super_ = Method('dart/textDocument/super');
154154
static const imports = Method('dart/textDocument/imports');
155-
static const dartTextDocumentContent = Method('dart/textDocumentContent');
156-
static const dartTextDocumentContentDidChange = Method(
157-
'dart/textDocumentContentDidChange',
158-
);
159155

160156
/// Method for requesting the set of editable arguments at a location in a
161157
/// document.

pkg/analysis_server/lib/src/lsp/handlers/custom/handler_dart_text_document_content_provider.dart

Lines changed: 0 additions & 82 deletions
This file was deleted.

pkg/analysis_server/lib/src/lsp/handlers/handler_states.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import 'package:analysis_server/src/lsp/handlers/custom/editable_arguments/handl
1313
import 'package:analysis_server/src/lsp/handlers/custom/handler_augmentation.dart';
1414
import 'package:analysis_server/src/lsp/handlers/custom/handler_augmented.dart';
1515
import 'package:analysis_server/src/lsp/handlers/custom/handler_connect_to_dtd.dart';
16-
import 'package:analysis_server/src/lsp/handlers/custom/handler_dart_text_document_content_provider.dart';
1716
import 'package:analysis_server/src/lsp/handlers/custom/handler_diagnostic_server.dart';
1817
import 'package:analysis_server/src/lsp/handlers/custom/handler_experimental_echo.dart';
1918
import 'package:analysis_server/src/lsp/handlers/custom/handler_imports.dart';
@@ -126,7 +125,6 @@ class InitializedStateMessageHandler extends ServerStateMessageHandler {
126125
CodeActionHandler.new,
127126
CodeLensHandler.new,
128127
ConnectToDtdHandler.new,
129-
DartTextDocumentContentProviderHandler.new,
130128
DocumentColorHandler.new,
131129
DocumentColorPresentationHandler.new,
132130
DocumentHighlightsHandler.new,

pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import 'package:analyzer/src/utilities/extensions/flutter.dart';
4747
import 'package:analyzer_plugin/protocol/protocol_common.dart' as plugin;
4848
import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
4949
import 'package:analyzer_plugin/src/protocol/protocol_internal.dart' as plugin;
50-
import 'package:analyzer_plugin/src/utilities/client_uri_converter.dart';
5150
import 'package:http/http.dart' as http;
5251
import 'package:meta/meta.dart';
5352

@@ -398,15 +397,6 @@ class LspAnalysisServer extends AnalysisServer {
398397
var initializationOptions = _initializationOptions =
399398
LspInitializationOptions(rawInitializationOptions);
400399

401-
/// Enable virtual file support.
402-
var supportsVirtualFiles =
403-
_clientCapabilities
404-
?.supportsDartExperimentalTextDocumentContentProvider ??
405-
false;
406-
if (supportsVirtualFiles) {
407-
uriConverter = ClientUriConverter.withVirtualFileSupport(pathContext);
408-
}
409-
410400
// Set whether to allow interleaved requests.
411401
if (initializationOptions.allowOverlappingHandlers
412402
case var allowOverlappingHandlers?) {

pkg/analysis_server/lib/src/lsp/registration/feature_registration.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import 'package:analysis_server/lsp_protocol/protocol.dart';
66
import 'package:analysis_server/src/lsp/client_capabilities.dart';
77
import 'package:analysis_server/src/lsp/client_configuration.dart';
8-
import 'package:analysis_server/src/lsp/handlers/custom/handler_dart_text_document_content_provider.dart';
98
import 'package:analysis_server/src/lsp/handlers/handler_call_hierarchy.dart';
109
import 'package:analysis_server/src/lsp/handlers/handler_change_workspace_folders.dart';
1110
import 'package:analysis_server/src/lsp/handlers/handler_code_actions.dart';
@@ -114,8 +113,6 @@ class LspFeatures {
114113
final WorkspaceDidChangeConfigurationRegistrations
115114
workspaceDidChangeConfiguration;
116115
final WorkspaceSymbolRegistrations workspaceSymbol;
117-
final DartTextDocumentContentProviderRegistrations
118-
dartTextDocumentContentProvider;
119116

120117
LspFeatures(RegistrationContext context)
121118
: callHierarchy = CallHierarchyRegistrations(context),
@@ -148,9 +145,7 @@ class LspFeatures {
148145
willRename = WillRenameFilesRegistrations(context),
149146
workspaceDidChangeConfiguration =
150147
WorkspaceDidChangeConfigurationRegistrations(context),
151-
workspaceSymbol = WorkspaceSymbolRegistrations(context),
152-
dartTextDocumentContentProvider =
153-
DartTextDocumentContentProviderRegistrations(context);
148+
workspaceSymbol = WorkspaceSymbolRegistrations(context);
154149

155150
List<FeatureRegistration> get allFeatures => [
156151
callHierarchy,

0 commit comments

Comments
 (0)