@@ -105,6 +105,19 @@ bool b = false;
105105 expect (assist.change.edits, hasLength (1 ));
106106 }
107107
108+ Future <void > test_handleEditGetAssists_viaSendRequest () async {
109+ writeAnalysisOptionsWithPlugin ();
110+ newFile (filePath, 'bool b = false;' );
111+
112+ await channel
113+ .sendRequest (protocol.AnalysisSetContextRootsParams ([contextRoot]));
114+
115+ var response = await channel.sendRequest (
116+ protocol.EditGetAssistsParams (filePath, 'bool b = ' .length, 1 ));
117+ var result = protocol.EditGetAssistsResult .fromResponse (response);
118+ expect (result.assists, hasLength (1 ));
119+ }
120+
108121 Future <void > test_handleEditGetFixes () async {
109122 writeAnalysisOptionsWithPlugin ();
110123 newFile (filePath, 'bool b = false;' );
@@ -118,6 +131,19 @@ bool b = false;
118131 expect (fixes.fixes, hasLength (4 ));
119132 }
120133
134+ Future <void > test_handleEditGetFixes_viaSendRequest () async {
135+ writeAnalysisOptionsWithPlugin ();
136+ newFile (filePath, 'bool b = false;' );
137+
138+ await channel
139+ .sendRequest (protocol.AnalysisSetContextRootsParams ([contextRoot]));
140+
141+ var response = await channel
142+ .sendRequest (protocol.EditGetFixesParams (filePath, 'bool b = ' .length));
143+ var result = protocol.EditGetFixesResult .fromResponse (response);
144+ expect (result.fixes.first.fixes, hasLength (4 ));
145+ }
146+
121147 Future <void > test_lintDiagnosticsAreDisabledByDefault () async {
122148 writeAnalysisOptionsWithPlugin ();
123149 newFile (filePath, 'double x = 3.14;' );
@@ -258,6 +284,30 @@ plugins:
258284 }
259285}
260286
287+ class _InvertBoolean extends ResolvedCorrectionProducer {
288+ static const _invertBooleanKind =
289+ AssistKind ('dart.fix.invertBooelan' , 50 , 'Invert Boolean value' );
290+
291+ _InvertBoolean ({required super .context});
292+
293+ @override
294+ CorrectionApplicability get applicability =>
295+ CorrectionApplicability .singleLocation;
296+
297+ @override
298+ AssistKind get assistKind => _invertBooleanKind;
299+
300+ @override
301+ Future <void > compute (ChangeBuilder builder) async {
302+ if (node case BooleanLiteral (: var value)) {
303+ await builder.addDartFileEdit (file, (builder) {
304+ var invertedValue = (! value).toString ();
305+ builder.addSimpleReplacement (range.node (node), invertedValue);
306+ });
307+ }
308+ }
309+ }
310+
261311class _NoLiteralsPlugin extends Plugin {
262312 @override
263313 void register (PluginRegistry registry) {
@@ -290,27 +340,3 @@ class _WrapInQuotes extends ResolvedCorrectionProducer {
290340 });
291341 }
292342}
293-
294- class _InvertBoolean extends ResolvedCorrectionProducer {
295- static const _invertBooleanKind =
296- AssistKind ('dart.fix.invertBooelan' , 50 , 'Invert Boolean value' );
297-
298- _InvertBoolean ({required super .context});
299-
300- @override
301- CorrectionApplicability get applicability =>
302- CorrectionApplicability .singleLocation;
303-
304- @override
305- AssistKind get assistKind => _invertBooleanKind;
306-
307- @override
308- Future <void > compute (ChangeBuilder builder) async {
309- if (node case BooleanLiteral (: var value)) {
310- await builder.addDartFileEdit (file, (builder) {
311- var invertedValue = (! value).toString ();
312- builder.addSimpleReplacement (range.node (node), invertedValue);
313- });
314- }
315- }
316- }
0 commit comments