[analysis_server] Change flag for enabling LSP virtual document support

This accepts the flag without a suffix because I'm fairly confident we can ship this support without breaking changes to the API.

For a short period, the old flag is still supported so that Dart-Code + SDK don't need to be updated at the same time to avoid the support disappearing. I will remove the old flag in a few weeks (after a beta SDK branch and a stable Dart-Code release).

Change-Id: I246a33f37a5d5fc5c05c15daab7d87d4cc4fd9e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359064
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Danny Tuppeny 2024-03-22 17:01:40 +00:00 committed by Commit Queue
parent f1a064cd8a
commit 683917ddd7

View file

@ -11,13 +11,17 @@ import 'package:analysis_server/lsp_protocol/protocol.dart';
/// (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.
///
/// This is current EXPERIMENTAL and has a suffix that will allow opting-in for
/// dev/testing only if the Dart-Code and server versions match. This number
/// will be increased if breaking changes to the API are made. The suffix should
/// be removed here (and in Dart-Code) when work is complete and support is
/// enabled by default in Dart-Code.
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';
/// Wraps the client (editor) capabilities to improve performance.
@ -182,7 +186,10 @@ class LspClientCapabilities {
_listToSet(commandParameterSupport['supportedKinds'] as List?)
.cast<String>();
final supportsDartExperimentalTextDocumentContentProvider =
experimental[dartExperimentalTextDocumentContentProviderKey] != null;
(experimental[dartExperimentalTextDocumentContentProviderKey] ??
experimental[
dartExperimentalTextDocumentContentProviderLegacyKey]) !=
null;
/// At the time of writing (2023-02-01) there is no official capability for
/// supporting 'showMessageRequest' because LSP assumed all clients