549a78500a
This is refactor extracted from an upcoming change (to make property editor tests run against both servers) to make that change smaller and easier to review. There are some existing shared tests that run for both LSP and Legacy servers, but they currently do not touch much server API (one is for DTD and one tests reverse-requests). Migrating other tests (such as EditableArguments) requires some additional API be the same between the different test/server base classes. This change adds an `abstract interface class SharedTestInterface` to serve as a common interface for methods that shared tests need to use that have different implementations between LSP and Legacy. For example, updating the overlays in an LSP-over-Legacy test needs to use the Legacy APIs for updating the overlay and not the LSP ones (so we can't just use the LSP methods like we would for calling something like getHover for LSP-over-Legacy). It also: - adds some new futures to the LSP test base to match the behaviour of the legacy one (wait for in-progress analysis) - replaces the shared mixins with real base classes that implement the shared interface (for ex. `abstract class SharedLspOverLegacyTest extends LspOverLegacyTest implements SharedTestInterface`) to make it easier to create shared tests - renames `sendLspRequest` to `sendLspRequestToClient` to make it clearer what direction this method is for Change-Id: I070c2c005b11b9afd8a87aa22b04972a9dde2320 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404680 Reviewed-by: Phil Quitslund <pquitslund@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Phil Quitslund <pquitslund@google.com>
53 lines
2.3 KiB
Dart
53 lines
2.3 KiB
Dart
// Copyright (c) 2025, 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.
|
|
|
|
/// A common interface that can be implemented by a set of base classes to
|
|
/// allow tests to be written to run in different configurations
|
|
/// (LSP and LSP-over-Legacy, and in-process and out-of-process).
|
|
///
|
|
/// Implementations should use the appropriate APIs for the given server, for
|
|
/// example a test running against LSP will send a `textDocument/didOpen`
|
|
/// notification from [openFile] whereas when using the legacy server (even for
|
|
/// LSP-over-Legacy tests) will send an `analysis.updateContent` request.
|
|
abstract interface class SharedTestInterface {
|
|
/// A future that completes when the current analysis completes.
|
|
///
|
|
/// If there is no analysis in progress, completes immediately.
|
|
Future<void> get currentAnalysis;
|
|
|
|
/// Sets whether the test should fail if error diagnostics are generated.
|
|
///
|
|
/// This is used to avoid accidentally including invalid code in tests but can
|
|
/// be overridden for tests that are deliberately testing invalid code.
|
|
set failTestOnErrorDiagnostic(bool value);
|
|
|
|
/// Gets the full normalized file path of a file named "test.dart" in the test
|
|
/// project.
|
|
String get testFilePath;
|
|
|
|
/// Gets a file:/// URI for [testFilePath];
|
|
Uri get testFileUri => Uri.file(testFilePath);
|
|
|
|
/// Tells the server that file with [uri] has been closed and any overlay
|
|
/// should be removed.
|
|
Future<void> closeFile(Uri uri);
|
|
|
|
/// Creates a file at [filePath] with the given [content].
|
|
void createFile(String filePath, String content);
|
|
|
|
/// Performs standard initialization of the server, including starting
|
|
/// the server (an external process for integration tests) and sending any
|
|
/// initialization/analysis roots, and waiting for initial analysis to
|
|
/// complete.
|
|
Future<void> initializeServer();
|
|
|
|
/// Tells the server that the file with [uri] has been opened and has the
|
|
/// given [content].
|
|
Future<void> openFile(Uri uri, String content, {int version = 1});
|
|
|
|
/// Tells the server that the file with [uri] has had it's content replaced
|
|
/// with [content].
|
|
Future<void> replaceFile(int newVersion, Uri uri, String content);
|
|
}
|