Skip to content

Commit dd9a061

Browse files
DanTupCommit Queue
authored andcommitted
[analysis_server] Enable "EditArgument" request to work over the legacy protocol
+ move all related tests to a shared mixin so they run for both servers. Change-Id: I853e8f24948c07fdde2a5d6a64ddc65962357b6d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404841 Commit-Queue: Brian Wilkerson <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Phil Quitslund <[email protected]>
1 parent b908274 commit dd9a061

File tree

8 files changed

+767
-724
lines changed

8 files changed

+767
-724
lines changed

pkg/analysis_server/lib/src/analysis_server.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,11 @@ abstract class AnalysisServer {
10331033
/// 'lsp.notification' notification.
10341034
void sendLspNotification(lsp.NotificationMessage notification);
10351035

1036+
/// Sends an LSP request with the given [params] to the client and waits for a
1037+
/// response. Completes with the raw [lsp.ResponseMessage] which could be an
1038+
/// error response.
1039+
Future<lsp.ResponseMessage> sendLspRequest(lsp.Method method, Object params);
1040+
10361041
/// Sends an error notification to the user.
10371042
void sendServerErrorNotification(
10381043
String message,

pkg/analysis_server/lib/src/legacy_analysis_server.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,7 @@ class LegacyAnalysisServer extends AnalysisServer {
719719

720720
/// Sends an LSP request to the server (wrapped in 'lsp.handle') and unwraps
721721
/// the LSP response from the result of the legacy response.
722+
@override
722723
Future<lsp.ResponseMessage> sendLspRequest(
723724
lsp.Method method,
724725
Object params,

pkg/analysis_server/lib/src/lsp/handlers/custom/editable_arguments/handler_edit_argument.dart

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import 'package:analysis_server/src/lsp/constants.dart';
1010
import 'package:analysis_server/src/lsp/error_or.dart';
1111
import 'package:analysis_server/src/lsp/handlers/custom/editable_arguments/editable_arguments_mixin.dart';
1212
import 'package:analysis_server/src/lsp/handlers/handlers.dart';
13-
import 'package:analysis_server/src/lsp/lsp_analysis_server.dart';
1413
import 'package:analysis_server/src/lsp/mapping.dart';
1514
import 'package:analysis_server/src/lsp/source_edits.dart';
1615
import 'package:analyzer/dart/analysis/results.dart';
@@ -286,14 +285,6 @@ class EditArgumentHandler extends SharedMessageHandler<EditArgumentParams, Null>
286285
/// Sends [workspaceEdit] to the client and returns `null` if applied
287286
/// successfully or an error otherwise.
288287
Future<ErrorOr<Null>> _sendEditToClient(WorkspaceEdit workspaceEdit) async {
289-
var server = this.server;
290-
if (server is! LspAnalysisServer) {
291-
return error(
292-
ErrorCodes.RequestFailed,
293-
'Sending edits is currently only supported for clients using LSP directly',
294-
);
295-
}
296-
297288
var editDescription = 'Edit argument';
298289
var editResponse = await server.sendLspRequest(
299290
Method.workspace_applyEdit,

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -861,9 +861,7 @@ class LspAnalysisServer extends AnalysisServer {
861861
channel.sendNotification(notification);
862862
}
863863

864-
/// Sends a request with the given [params] to the client and wait for a
865-
/// response. Completes with the raw [ResponseMessage] which could be an
866-
/// error response.
864+
@override
867865
Future<ResponseMessage> sendLspRequest(Method method, Object params) {
868866
var requestId = nextRequestId++;
869867
var completer = Completer<ResponseMessage>();

0 commit comments

Comments
 (0)