Skip to content

Commit fab7e4b

Browse files
srawlinsCommit Queue
authored andcommitted
DAS plugins: Simplify TestPluginManager
Using `noSuchMethod` is an idiomatic way to "implement" unimplemented members. Change-Id: Ifec025fc41bd9965f7461330b27990621a3ad7d4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395043 Auto-Submit: Samuel Rawlins <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]>
1 parent 09261c2 commit fab7e4b

File tree

1 file changed

+4
-46
lines changed

1 file changed

+4
-46
lines changed

pkg/analysis_server/lib/src/utilities/mocks.dart

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ import 'dart:async';
66

77
import 'package:analysis_server/protocol/protocol.dart';
88
import 'package:analysis_server/src/channel/channel.dart';
9-
import 'package:analysis_server/src/plugin/notification_manager.dart';
109
import 'package:analysis_server/src/plugin/plugin_manager.dart';
1110
import 'package:analyzer/dart/analysis/context_root.dart' as analyzer;
12-
import 'package:analyzer/file_system/file_system.dart';
13-
import 'package:analyzer/instrumentation/instrumentation.dart';
1411
import 'package:analyzer_plugin/protocol/protocol.dart' as plugin;
1512
import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
1613
import 'package:analyzer_plugin/src/protocol/protocol_internal.dart' as plugin;
@@ -161,34 +158,9 @@ class TestPluginManager implements PluginManager {
161158
StreamController<void> pluginsChangedController =
162159
StreamController.broadcast();
163160

164-
@override
165-
String get byteStorePath {
166-
fail('Unexpected invocation of byteStorePath');
167-
}
168-
169-
@override
170-
InstrumentationService get instrumentationService {
171-
fail('Unexpected invocation of instrumentationService');
172-
}
173-
174-
@override
175-
AbstractNotificationManager get notificationManager {
176-
fail('Unexpected invocation of notificationManager');
177-
}
178-
179161
@override
180162
Stream<void> get pluginsChanged => pluginsChangedController.stream;
181163

182-
@override
183-
ResourceProvider get resourceProvider {
184-
fail('Unexpected invocation of resourceProvider');
185-
}
186-
187-
@override
188-
String get sdkPath {
189-
fail('Unexpected invocation of sdkPath');
190-
}
191-
192164
@override
193165
Future<void> addPluginToContextRoot(
194166
analyzer.ContextRoot contextRoot,
@@ -203,27 +175,19 @@ class TestPluginManager implements PluginManager {
203175
analyzer.ContextRoot? contextRoot,
204176
}) {
205177
broadcastedRequest = params;
206-
return handleRequest?.call(params) ??
207-
broadcastResults ??
208-
<PluginInfo, Future<plugin.Response>>{};
178+
return handleRequest?.call(params) ?? broadcastResults ?? {};
209179
}
210180

211181
@override
212182
Future<List<Future<plugin.Response>>> broadcastWatchEvent(
213183
WatchEvent watchEvent,
214184
) async {
215-
return <Future<plugin.Response>>[];
185+
return [];
216186
}
217187

218188
@override
219-
PluginFiles filesFor(String pluginPath) {
220-
fail('Unexpected invocation of filesFor');
221-
}
222-
223-
@override
224-
List<PluginInfo> pluginsForContextRoot(analyzer.ContextRoot? contextRoot) {
225-
fail('Unexpected invocation of pluginsForContextRoot');
226-
}
189+
dynamic noSuchMethod(Invocation invocation) =>
190+
fail('Unexpected invocation of ${invocation.memberName}');
227191

228192
@override
229193
void removedContextRoot(analyzer.ContextRoot contextRoot) {
@@ -233,7 +197,6 @@ class TestPluginManager implements PluginManager {
233197
@override
234198
Future<void> restartPlugins() async {
235199
// Nothing to restart.
236-
return;
237200
}
238201

239202
@override
@@ -256,9 +219,4 @@ class TestPluginManager implements PluginManager {
256219
) {
257220
analysisUpdateContentParams = params;
258221
}
259-
260-
@override
261-
Future<List<void>> stopAll() async {
262-
fail('Unexpected invocation of stopAll');
263-
}
264222
}

0 commit comments

Comments
 (0)