[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:
committed by
Commit Queue
parent
3c522839cf
commit
70358239d8
@@ -22,7 +22,6 @@ abstract class AbstractLspOverLegacyTest
|
||||
ClientCapabilitiesHelperMixin,
|
||||
LspRequestHelpersMixin,
|
||||
LspReverseRequestHelpersMixin,
|
||||
LspNotificationHelpersMixin,
|
||||
LspEditHelpersMixin,
|
||||
LspVerifyEditHelpersMixin {
|
||||
late final testFile = sourcePath('lib/main.dart');
|
||||
@@ -37,7 +36,6 @@ abstract class AbstractLspOverLegacyTest
|
||||
final _overlayContent = <String, String>{};
|
||||
|
||||
/// A stream of LSP [NotificationMessage]s from the server.
|
||||
@override
|
||||
Stream<NotificationMessage> get notificationsFromServer =>
|
||||
onLspNotification.map(
|
||||
(params) => NotificationMessage.fromJson(
|
||||
|
||||
@@ -26,7 +26,6 @@ abstract class AbstractLspAnalysisServerIntegrationTest
|
||||
ClientCapabilitiesHelperMixin,
|
||||
LspRequestHelpersMixin,
|
||||
LspReverseRequestHelpersMixin,
|
||||
LspNotificationHelpersMixin,
|
||||
LspEditHelpersMixin,
|
||||
LspVerifyEditHelpersMixin,
|
||||
LspAnalysisServerTestMixin {
|
||||
|
||||
@@ -1246,23 +1246,6 @@ abstract class CommonServerContextManagerCallbacks
|
||||
var path = result.path;
|
||||
filesToFlush.add(path);
|
||||
|
||||
// If this is a virtual file and the client supports URIs, we need to notify
|
||||
// that it's been updated.
|
||||
var lspUri = analysisServer.uriConverter.toClientUri(result.path);
|
||||
if (!lspUri.isScheme('file')) {
|
||||
// TODO(dantup): Should we do any kind of tracking here to avoid sending
|
||||
// lots of notifications if there aren't actual changes?
|
||||
// TODO(dantup): We may be able to skip sending this if the file is not
|
||||
// open (priority) depending on the response to
|
||||
// https://github.com/microsoft/vscode/issues/202017
|
||||
var message = lsp.NotificationMessage(
|
||||
method: lsp.CustomMethods.dartTextDocumentContentDidChange,
|
||||
params: lsp.DartTextDocumentContentDidChangeParams(uri: lspUri),
|
||||
jsonrpc: lsp.jsonRpcVersion,
|
||||
);
|
||||
analysisServer.sendLspNotification(message);
|
||||
}
|
||||
|
||||
if (result is AnalysisResultWithDiagnostics) {
|
||||
if (analysisServer.isAnalyzed(path)) {
|
||||
var serverErrors = server.doAnalysisError_listFromEngine(result);
|
||||
|
||||
@@ -482,6 +482,9 @@ class LegacyAnalysisServer extends AnalysisServer {
|
||||
set clientCapabilities(ServerSetClientCapabilitiesParams capabilities) {
|
||||
_clientCapabilities = capabilities;
|
||||
|
||||
// TODO(dantup): If we can confirm that IntelliJ did not ship code that
|
||||
// sets supportsUris=true, then we may be able to entirely remove the
|
||||
// uriConverter and all the calls through it.
|
||||
if (capabilities.supportsUris ?? false) {
|
||||
// URI support implies LSP, as that's the only way to access (and get
|
||||
// change notifications for) custom-scheme files.
|
||||
|
||||
@@ -4,26 +4,6 @@
|
||||
|
||||
import 'package:analysis_server/lsp_protocol/protocol.dart';
|
||||
|
||||
/// The key in the client capabilities experimental object that enables the Dart
|
||||
/// TextDocumentContentProvider.
|
||||
///
|
||||
/// The presence of this key indicates that the client supports our
|
||||
/// (non-standard) way of using TextDocumentContentProvider. This will need to
|
||||
/// continue to be supported after switching to standard LSP support for some
|
||||
/// period to support outdated extensions.
|
||||
const dartExperimentalTextDocumentContentProviderKey =
|
||||
'supportsDartTextDocumentContentProvider';
|
||||
|
||||
/// The original key used for [dartExperimentalTextDocumentContentProviderKey].
|
||||
///
|
||||
/// This is temporarily supported to avoid the macro support vanishing for users
|
||||
/// for a period if their SDK is updated before Dart-Code passes the standard
|
||||
/// flag.
|
||||
///
|
||||
const dartExperimentalTextDocumentContentProviderLegacyKey =
|
||||
// TODO(dantup): Remove this after the next beta branch.
|
||||
'supportsDartTextDocumentContentProviderEXP1';
|
||||
|
||||
/// A fixed set of ClientCapabilities used for clients that may execute LSP
|
||||
/// requests without performing standard LSP initialization (such as a DTD
|
||||
/// client or LSP-over-Legacy).
|
||||
@@ -127,11 +107,6 @@ class LspClientCapabilities {
|
||||
final Set<String> codeActionCommandParameterSupportedKinds;
|
||||
final bool supportsShowMessageRequest;
|
||||
|
||||
/// Whether the client supports the custom Dart TextDocumentContentProvider,
|
||||
/// meaning it can request file contents from the server for custom URI
|
||||
/// schemes.
|
||||
final bool supportsDartExperimentalTextDocumentContentProvider;
|
||||
|
||||
/// A set of commands that exist on the client that the server may call.
|
||||
final Set<String> supportedCommands;
|
||||
|
||||
@@ -251,8 +226,6 @@ class LspClientCapabilities {
|
||||
codeActionCommandParameterSupportedKinds:
|
||||
experimental.commandParameterKinds,
|
||||
supportsShowMessageRequest: experimental.showMessageRequest,
|
||||
supportsDartExperimentalTextDocumentContentProvider:
|
||||
experimental.dartTextDocumentContentProvider,
|
||||
supportedCommands: experimental.commands,
|
||||
experimentalCapabilitiesErrors: experimental.errors,
|
||||
);
|
||||
@@ -293,7 +266,6 @@ class LspClientCapabilities {
|
||||
required this.experimentalSnippetTextEdit,
|
||||
required this.codeActionCommandParameterSupportedKinds,
|
||||
required this.supportsShowMessageRequest,
|
||||
required this.supportsDartExperimentalTextDocumentContentProvider,
|
||||
required this.supportedCommands,
|
||||
required this.experimentalCapabilitiesErrors,
|
||||
});
|
||||
@@ -319,14 +291,12 @@ class _ExperimentalClientCapabilities {
|
||||
|
||||
final bool snippetTextEdit;
|
||||
final Set<String> commandParameterKinds;
|
||||
final bool dartTextDocumentContentProvider;
|
||||
final Set<String> commands;
|
||||
final bool showMessageRequest;
|
||||
|
||||
_ExperimentalClientCapabilities({
|
||||
required this.snippetTextEdit,
|
||||
required this.commandParameterKinds,
|
||||
required this.dartTextDocumentContentProvider,
|
||||
required this.commands,
|
||||
required this.showMessageRequest,
|
||||
required this.errors,
|
||||
@@ -392,15 +362,6 @@ class _ExperimentalClientCapabilities {
|
||||
commandParameters['supportedKinds'],
|
||||
);
|
||||
|
||||
// Macro/Augmentation content.
|
||||
var dartContentValue =
|
||||
experimental[dartExperimentalTextDocumentContentProviderKey] ??
|
||||
experimental[dartExperimentalTextDocumentContentProviderLegacyKey];
|
||||
var dartTextDocumentContentProvider = expectBool(
|
||||
'.$dartExperimentalTextDocumentContentProviderKey',
|
||||
dartContentValue,
|
||||
);
|
||||
|
||||
// Executable commands.
|
||||
var commands = expectNullableStringSet(
|
||||
'.commands',
|
||||
@@ -423,7 +384,6 @@ class _ExperimentalClientCapabilities {
|
||||
return _ExperimentalClientCapabilities(
|
||||
snippetTextEdit: snippetTextEdit ?? false,
|
||||
commandParameterKinds: commandParameterKinds ?? {},
|
||||
dartTextDocumentContentProvider: dartTextDocumentContentProvider ?? false,
|
||||
commands: commands ?? {},
|
||||
showMessageRequest: showMessageRequest ?? false,
|
||||
errors: errors,
|
||||
|
||||
@@ -152,10 +152,6 @@ abstract final class CustomMethods {
|
||||
static const summary = Method('dart/textDocument/summary');
|
||||
static const super_ = Method('dart/textDocument/super');
|
||||
static const imports = Method('dart/textDocument/imports');
|
||||
static const dartTextDocumentContent = Method('dart/textDocumentContent');
|
||||
static const dartTextDocumentContentDidChange = Method(
|
||||
'dart/textDocumentContentDidChange',
|
||||
);
|
||||
|
||||
/// Method for requesting the set of editable arguments at a location in a
|
||||
/// document.
|
||||
|
||||
-82
@@ -1,82 +0,0 @@
|
||||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analysis_server/lsp_protocol/protocol.dart';
|
||||
import 'package:analysis_server/src/lsp/constants.dart';
|
||||
import 'package:analysis_server/src/lsp/error_or.dart';
|
||||
import 'package:analysis_server/src/lsp/handlers/handlers.dart';
|
||||
import 'package:analysis_server/src/lsp/registration/feature_registration.dart';
|
||||
import 'package:analyzer/dart/analysis/results.dart';
|
||||
|
||||
typedef StaticOptions = DartTextDocumentContentProviderRegistrationOptions?;
|
||||
|
||||
class DartTextDocumentContentProviderHandler
|
||||
extends
|
||||
SharedMessageHandler<
|
||||
DartTextDocumentContentParams,
|
||||
DartTextDocumentContent
|
||||
> {
|
||||
DartTextDocumentContentProviderHandler(super.server);
|
||||
|
||||
@override
|
||||
Method get handlesMessage => CustomMethods.dartTextDocumentContent;
|
||||
|
||||
@override
|
||||
LspJsonHandler<DartTextDocumentContentParams> get jsonHandler =>
|
||||
DartTextDocumentContentParams.jsonHandler;
|
||||
|
||||
@override
|
||||
bool get requiresTrustedCaller => false;
|
||||
|
||||
@override
|
||||
Future<ErrorOr<DartTextDocumentContent>> handle(
|
||||
DartTextDocumentContentParams params,
|
||||
MessageInfo message,
|
||||
CancellationToken token,
|
||||
) async {
|
||||
var allowedSchemes = server.uriConverter.supportedNonFileSchemes;
|
||||
var uri = params.uri;
|
||||
|
||||
if (!allowedSchemes.contains(uri.scheme)) {
|
||||
var supportedSchemesString = allowedSchemes.isEmpty
|
||||
? '(none)'
|
||||
: allowedSchemes.map((scheme) => "'$scheme'").join(', ');
|
||||
return error(
|
||||
ErrorCodes.InvalidParams,
|
||||
"Fetching content for scheme '${uri.scheme}' is not supported. "
|
||||
'Supported schemes are $supportedSchemesString.',
|
||||
);
|
||||
}
|
||||
|
||||
return pathOfUri(uri).mapResult((filePath) async {
|
||||
var file = server.getAnalysisDriver(filePath)?.getFileSync(filePath);
|
||||
var content = file is FileResult ? file.content : null;
|
||||
|
||||
return success(DartTextDocumentContent(content: content));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class DartTextDocumentContentProviderRegistrations extends FeatureRegistration
|
||||
with SingleDynamicRegistration, StaticRegistration<StaticOptions> {
|
||||
@override
|
||||
final DartTextDocumentContentProviderRegistrationOptions options;
|
||||
|
||||
DartTextDocumentContentProviderRegistrations(super.info)
|
||||
: options = DartTextDocumentContentProviderRegistrationOptions(
|
||||
schemes: info.customDartSchemes.toList(),
|
||||
);
|
||||
|
||||
@override
|
||||
Method get registrationMethod => CustomMethods.dartTextDocumentContent;
|
||||
|
||||
@override
|
||||
StaticOptions get staticOptions => options;
|
||||
|
||||
@override
|
||||
bool get supportsDynamic => false;
|
||||
|
||||
@override
|
||||
bool get supportsStatic => true;
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import 'package:analysis_server/src/lsp/handlers/custom/editable_arguments/handl
|
||||
import 'package:analysis_server/src/lsp/handlers/custom/handler_augmentation.dart';
|
||||
import 'package:analysis_server/src/lsp/handlers/custom/handler_augmented.dart';
|
||||
import 'package:analysis_server/src/lsp/handlers/custom/handler_connect_to_dtd.dart';
|
||||
import 'package:analysis_server/src/lsp/handlers/custom/handler_dart_text_document_content_provider.dart';
|
||||
import 'package:analysis_server/src/lsp/handlers/custom/handler_diagnostic_server.dart';
|
||||
import 'package:analysis_server/src/lsp/handlers/custom/handler_experimental_echo.dart';
|
||||
import 'package:analysis_server/src/lsp/handlers/custom/handler_imports.dart';
|
||||
@@ -126,7 +125,6 @@ class InitializedStateMessageHandler extends ServerStateMessageHandler {
|
||||
CodeActionHandler.new,
|
||||
CodeLensHandler.new,
|
||||
ConnectToDtdHandler.new,
|
||||
DartTextDocumentContentProviderHandler.new,
|
||||
DocumentColorHandler.new,
|
||||
DocumentColorPresentationHandler.new,
|
||||
DocumentHighlightsHandler.new,
|
||||
|
||||
@@ -47,7 +47,6 @@ import 'package:analyzer/src/utilities/extensions/flutter.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart' as plugin;
|
||||
import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
|
||||
import 'package:analyzer_plugin/src/protocol/protocol_internal.dart' as plugin;
|
||||
import 'package:analyzer_plugin/src/utilities/client_uri_converter.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
@@ -398,15 +397,6 @@ class LspAnalysisServer extends AnalysisServer {
|
||||
var initializationOptions = _initializationOptions =
|
||||
LspInitializationOptions(rawInitializationOptions);
|
||||
|
||||
/// Enable virtual file support.
|
||||
var supportsVirtualFiles =
|
||||
_clientCapabilities
|
||||
?.supportsDartExperimentalTextDocumentContentProvider ??
|
||||
false;
|
||||
if (supportsVirtualFiles) {
|
||||
uriConverter = ClientUriConverter.withVirtualFileSupport(pathContext);
|
||||
}
|
||||
|
||||
// Set whether to allow interleaved requests.
|
||||
if (initializationOptions.allowOverlappingHandlers
|
||||
case var allowOverlappingHandlers?) {
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
import 'package:analysis_server/lsp_protocol/protocol.dart';
|
||||
import 'package:analysis_server/src/lsp/client_capabilities.dart';
|
||||
import 'package:analysis_server/src/lsp/client_configuration.dart';
|
||||
import 'package:analysis_server/src/lsp/handlers/custom/handler_dart_text_document_content_provider.dart';
|
||||
import 'package:analysis_server/src/lsp/handlers/handler_call_hierarchy.dart';
|
||||
import 'package:analysis_server/src/lsp/handlers/handler_change_workspace_folders.dart';
|
||||
import 'package:analysis_server/src/lsp/handlers/handler_code_actions.dart';
|
||||
@@ -114,8 +113,6 @@ class LspFeatures {
|
||||
final WorkspaceDidChangeConfigurationRegistrations
|
||||
workspaceDidChangeConfiguration;
|
||||
final WorkspaceSymbolRegistrations workspaceSymbol;
|
||||
final DartTextDocumentContentProviderRegistrations
|
||||
dartTextDocumentContentProvider;
|
||||
|
||||
LspFeatures(RegistrationContext context)
|
||||
: callHierarchy = CallHierarchyRegistrations(context),
|
||||
@@ -148,9 +145,7 @@ class LspFeatures {
|
||||
willRename = WillRenameFilesRegistrations(context),
|
||||
workspaceDidChangeConfiguration =
|
||||
WorkspaceDidChangeConfigurationRegistrations(context),
|
||||
workspaceSymbol = WorkspaceSymbolRegistrations(context),
|
||||
dartTextDocumentContentProvider =
|
||||
DartTextDocumentContentProviderRegistrations(context);
|
||||
workspaceSymbol = WorkspaceSymbolRegistrations(context);
|
||||
|
||||
List<FeatureRegistration> get allFeatures => [
|
||||
callHierarchy,
|
||||
|
||||
@@ -219,10 +219,7 @@ class ServerCapabilitiesComputer {
|
||||
// Some of these fields are objects where bools could be sufficient to
|
||||
// allow for future expansion without potentially breaking clients by
|
||||
// changing the data type.
|
||||
if (clientCapabilities
|
||||
.supportsDartExperimentalTextDocumentContentProvider)
|
||||
'dartTextDocumentContentProvider':
|
||||
features.dartTextDocumentContentProvider.staticRegistration,
|
||||
|
||||
// Indicate that we support the 'updateDiagnosticInformation'
|
||||
// custom request.
|
||||
'updateDiagnosticInformation': {},
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analysis_server/src/legacy_analysis_server.dart';
|
||||
import 'package:analyzer_plugin/src/utilities/client_uri_converter.dart';
|
||||
import 'package:analyzer_testing/experiments/experiments.dart';
|
||||
import 'package:language_server_protocol/protocol_generated.dart';
|
||||
import 'package:test/expect.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../tool/lsp_spec/matchers.dart';
|
||||
import 'server_abstract.dart';
|
||||
|
||||
void main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(DartTextDocumentContentProviderTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class DartTextDocumentContentProviderTest
|
||||
extends AbstractLspAnalysisServerTest {
|
||||
@override
|
||||
AnalysisServerOptions get serverOptions => AnalysisServerOptions()
|
||||
..enabledExperiments = [
|
||||
...super.serverOptions.enabledExperiments,
|
||||
...experimentsForTests,
|
||||
];
|
||||
|
||||
@override
|
||||
void setUp() {
|
||||
super.setUp();
|
||||
setDartTextDocumentContentProviderSupport();
|
||||
}
|
||||
|
||||
Future<void> test_invalid_badScheme() async {
|
||||
await initialize();
|
||||
|
||||
await expectLater(
|
||||
getDartTextDocumentContent(Uri.parse('abcde:foo/bar.dart')),
|
||||
throwsA(
|
||||
isResponseError(
|
||||
ErrorCodes.InvalidParams,
|
||||
message:
|
||||
"Fetching content for scheme 'abcde' is not supported. "
|
||||
"Supported schemes are '$macroClientUriScheme'.",
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> test_invalid_fileScheme() async {
|
||||
await initialize();
|
||||
|
||||
await expectLater(
|
||||
getDartTextDocumentContent(mainFileUri),
|
||||
throwsA(
|
||||
isResponseError(
|
||||
ErrorCodes.InvalidParams,
|
||||
message:
|
||||
"Fetching content for scheme 'file' is not supported. "
|
||||
"Supported schemes are '$macroClientUriScheme'.",
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> test_support_notSupported() async {
|
||||
setDartTextDocumentContentProviderSupport(false);
|
||||
await initialize();
|
||||
expect(
|
||||
experimentalServerCapabilities['dartTextDocumentContentProvider'],
|
||||
isNull,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> test_supported_static() async {
|
||||
await initialize();
|
||||
expect(experimentalServerCapabilities['dartTextDocumentContentProvider'], {
|
||||
'schemes': [macroClientUriScheme],
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1147,14 +1147,6 @@ class InitializationTest extends AbstractLspAnalysisServerTest {
|
||||
}, 'ClientCapabilities.experimental.snippetTextEdit must be a bool?');
|
||||
}
|
||||
|
||||
Future<void>
|
||||
test_invalidExperimental_supportsDartTextDocumentContentProvider() async {
|
||||
await expectInvalidExperimentalParams(
|
||||
{'supportsDartTextDocumentContentProvider': 1},
|
||||
'ClientCapabilities.experimental.supportsDartTextDocumentContentProvider must be a bool?',
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> test_nonFileScheme_rootUri() async {
|
||||
// We expect an error notification about the invalid file we try to open.
|
||||
failTestOnAnyErrorNotification = false;
|
||||
|
||||
@@ -91,26 +91,6 @@ mixin LspEditHelpersMixin {
|
||||
}
|
||||
}
|
||||
|
||||
/// Helpers to simplify handling LSP notifications.
|
||||
mixin LspNotificationHelpersMixin {
|
||||
/// A stream of [DartTextDocumentContentDidChangeParams] for any
|
||||
/// `dart/textDocumentContentDidChange` notifications.
|
||||
Stream<DartTextDocumentContentDidChangeParams>
|
||||
get dartTextDocumentContentDidChangeNotifications => notificationsFromServer
|
||||
.where(
|
||||
(notification) =>
|
||||
notification.method ==
|
||||
CustomMethods.dartTextDocumentContentDidChange,
|
||||
)
|
||||
.map(
|
||||
(message) => DartTextDocumentContentDidChangeParams.fromJson(
|
||||
message.params as Map<String, Object?>,
|
||||
),
|
||||
);
|
||||
|
||||
Stream<NotificationMessage> get notificationsFromServer;
|
||||
}
|
||||
|
||||
mixin LspProgressNotificationsMixin {
|
||||
Stream<NotificationMessage> get notificationsFromServer;
|
||||
|
||||
@@ -460,17 +440,6 @@ mixin LspRequestHelpersMixin {
|
||||
return completions;
|
||||
}
|
||||
|
||||
Future<DartTextDocumentContent?> getDartTextDocumentContent(Uri uri) {
|
||||
var request = makeRequest(
|
||||
CustomMethods.dartTextDocumentContent,
|
||||
DartTextDocumentContentParams(uri: uri),
|
||||
);
|
||||
return expectSuccessfulResponseTo(
|
||||
request,
|
||||
DartTextDocumentContent.fromJson,
|
||||
);
|
||||
}
|
||||
|
||||
Future<Either2<List<Location>, List<LocationLink>>> getDefinition(
|
||||
Uri uri,
|
||||
Position pos,
|
||||
|
||||
@@ -53,7 +53,6 @@ abstract class AbstractLspAnalysisServerTest
|
||||
ClientCapabilitiesHelperMixin,
|
||||
LspRequestHelpersMixin,
|
||||
LspReverseRequestHelpersMixin,
|
||||
LspNotificationHelpersMixin,
|
||||
LspEditHelpersMixin,
|
||||
LspVerifyEditHelpersMixin,
|
||||
LspAnalysisServerTestMixin,
|
||||
@@ -573,18 +572,6 @@ mixin ClientCapabilitiesHelperMixin {
|
||||
});
|
||||
}
|
||||
|
||||
void setDartTextDocumentContentProviderSupport([bool supported = true]) {
|
||||
// These are temporarily versioned with a suffix during dev so if we ship
|
||||
// as an experiment (not LSP standard) without the suffix it will only be
|
||||
// active for matching server/clients.
|
||||
const key = dartExperimentalTextDocumentContentProviderKey;
|
||||
if (supported) {
|
||||
experimentalCapabilities[key] = true;
|
||||
} else {
|
||||
experimentalCapabilities.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
void setDiagnosticCodeDescriptionSupport() {
|
||||
textDocumentCapabilities = extendTextDocumentCapabilities(
|
||||
textDocumentCapabilities,
|
||||
@@ -801,7 +788,6 @@ mixin LspAnalysisServerTestMixin
|
||||
on
|
||||
LspRequestHelpersMixin,
|
||||
LspReverseRequestHelpersMixin,
|
||||
LspNotificationHelpersMixin,
|
||||
LspEditHelpersMixin
|
||||
implements ClientCapabilitiesHelperMixin {
|
||||
late String projectFolderPath,
|
||||
@@ -891,7 +877,6 @@ mixin LspAnalysisServerTestMixin
|
||||
Uri get nonExistentFileUri => pathContext.toUri(nonExistentFilePath);
|
||||
|
||||
/// A stream of [NotificationMessage]s from the server.
|
||||
@override
|
||||
Stream<NotificationMessage> get notificationsFromServer {
|
||||
return serverToClient
|
||||
.where((m) => m is NotificationMessage)
|
||||
|
||||
@@ -22,8 +22,6 @@ import 'commands/test_all.dart' as commands;
|
||||
import 'completion_dart_test.dart' as completion_dart;
|
||||
import 'completion_yaml_test.dart' as completion_yaml;
|
||||
import 'configuration_test.dart' as configuration;
|
||||
import 'dart_text_document_content_provider_test.dart'
|
||||
as dart_text_document_content_provider;
|
||||
import 'definition_test.dart' as definition;
|
||||
import 'diagnostic_test.dart' as diagnostic;
|
||||
import 'document_changes_test.dart' as document_changes;
|
||||
@@ -88,7 +86,6 @@ void main() {
|
||||
completion_dart.main();
|
||||
completion_yaml.main();
|
||||
configuration.main();
|
||||
dart_text_document_content_provider.main();
|
||||
definition.main();
|
||||
diagnostic.main();
|
||||
document_changes.main();
|
||||
|
||||
@@ -9,7 +9,6 @@ import 'package:analysis_server/lsp_protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_constants.dart';
|
||||
import 'package:analysis_server/src/analytics/analytics_manager.dart';
|
||||
import 'package:analysis_server/src/lsp/client_capabilities.dart';
|
||||
import 'package:analysis_server/src/lsp/constants.dart';
|
||||
import 'package:analysis_server/src/protocol/protocol_internal.dart';
|
||||
import 'package:analysis_server/src/protocol_server.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
@@ -97,18 +96,6 @@ class EventsPrinter {
|
||||
event.files.sorted(),
|
||||
_writelnFile,
|
||||
);
|
||||
case NotificationMessage():
|
||||
switch (event.method) {
|
||||
case CustomMethods.dartTextDocumentContentDidChange:
|
||||
sink.writelnWithIndent(event.method);
|
||||
var params =
|
||||
event.params as DartTextDocumentContentDidChangeParams;
|
||||
sink.withIndent(() {
|
||||
_writelnUri(params.uri, name: 'uri');
|
||||
});
|
||||
default:
|
||||
throw UnimplementedError('${event.method}');
|
||||
}
|
||||
default:
|
||||
throw UnimplementedError('${event.runtimeType}');
|
||||
}
|
||||
@@ -124,23 +111,6 @@ class EventsPrinter {
|
||||
sink.write(file.posixPath);
|
||||
});
|
||||
}
|
||||
|
||||
void _writelnUri(Uri uri, {String? name}) {
|
||||
sink.writeIndentedLine(() {
|
||||
if (name != null) {
|
||||
sink.write('$name: ');
|
||||
}
|
||||
|
||||
if (uri.isScheme('file') || uri.isScheme('dart-macro+file')) {
|
||||
var fileUri = uri.replace(scheme: 'file');
|
||||
var path = resourceProvider.pathContext.fromUri(fileUri);
|
||||
var file = resourceProvider.getFile(path);
|
||||
uri = uri.replace(path: file.posixPath);
|
||||
}
|
||||
|
||||
sink.write(uri);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class EventsPrinterConfiguration {}
|
||||
@@ -149,7 +119,6 @@ abstract class LspOverLegacyTest extends PubPackageAnalysisServerTest
|
||||
with
|
||||
LspRequestHelpersMixin,
|
||||
LspReverseRequestHelpersMixin,
|
||||
LspNotificationHelpersMixin,
|
||||
LspEditHelpersMixin,
|
||||
ClientCapabilitiesHelperMixin,
|
||||
LspVerifyEditHelpersMixin,
|
||||
@@ -191,7 +160,6 @@ abstract class LspOverLegacyTest extends PubPackageAnalysisServerTest
|
||||
server.editorClientCapabilities;
|
||||
|
||||
/// A stream of [NotificationMessage]s from the server.
|
||||
@override
|
||||
Stream<NotificationMessage> get notificationsFromServer =>
|
||||
_notificationsFromServer.stream;
|
||||
|
||||
|
||||
@@ -603,26 +603,6 @@ List<LspEntity> getCustomClasses() {
|
||||
baseType: 'CommandParameter',
|
||||
comment: 'Information about a Save URI argument needed by the command.',
|
||||
),
|
||||
interface('DartTextDocumentContentProviderRegistrationOptions', [
|
||||
field(
|
||||
'schemes',
|
||||
type: 'string',
|
||||
array: true,
|
||||
comment:
|
||||
'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.',
|
||||
),
|
||||
]),
|
||||
interface('DartTextDocumentContentParams', [
|
||||
field('uri', type: 'DocumentUri'),
|
||||
]),
|
||||
interface('DartTextDocumentContent', [
|
||||
field('content', type: 'String', canBeNull: true),
|
||||
]),
|
||||
interface('DartTextDocumentContentDidChangeParams', [
|
||||
field('uri', type: 'DocumentUri'),
|
||||
]),
|
||||
|
||||
// Types for `dart/textDocument/summary`.
|
||||
interface('DartTextDocumentSummaryParams', [
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user