Skip to content

Commit

Permalink
DAS plugins: Simplify TestPluginManager
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
srawlins authored and Commit Queue committed Nov 13, 2024
1 parent 09261c2 commit fab7e4b
Showing 1 changed file with 4 additions and 46 deletions.
50 changes: 4 additions & 46 deletions pkg/analysis_server/lib/src/utilities/mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import 'dart:async';

import 'package:analysis_server/protocol/protocol.dart';
import 'package:analysis_server/src/channel/channel.dart';
import 'package:analysis_server/src/plugin/notification_manager.dart';
import 'package:analysis_server/src/plugin/plugin_manager.dart';
import 'package:analyzer/dart/analysis/context_root.dart' as analyzer;
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/instrumentation/instrumentation.dart';
import 'package:analyzer_plugin/protocol/protocol.dart' as plugin;
import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
import 'package:analyzer_plugin/src/protocol/protocol_internal.dart' as plugin;
Expand Down Expand Up @@ -161,34 +158,9 @@ class TestPluginManager implements PluginManager {
StreamController<void> pluginsChangedController =
StreamController.broadcast();

@override
String get byteStorePath {
fail('Unexpected invocation of byteStorePath');
}

@override
InstrumentationService get instrumentationService {
fail('Unexpected invocation of instrumentationService');
}

@override
AbstractNotificationManager get notificationManager {
fail('Unexpected invocation of notificationManager');
}

@override
Stream<void> get pluginsChanged => pluginsChangedController.stream;

@override
ResourceProvider get resourceProvider {
fail('Unexpected invocation of resourceProvider');
}

@override
String get sdkPath {
fail('Unexpected invocation of sdkPath');
}

@override
Future<void> addPluginToContextRoot(
analyzer.ContextRoot contextRoot,
Expand All @@ -203,27 +175,19 @@ class TestPluginManager implements PluginManager {
analyzer.ContextRoot? contextRoot,
}) {
broadcastedRequest = params;
return handleRequest?.call(params) ??
broadcastResults ??
<PluginInfo, Future<plugin.Response>>{};
return handleRequest?.call(params) ?? broadcastResults ?? {};
}

@override
Future<List<Future<plugin.Response>>> broadcastWatchEvent(
WatchEvent watchEvent,
) async {
return <Future<plugin.Response>>[];
return [];
}

@override
PluginFiles filesFor(String pluginPath) {
fail('Unexpected invocation of filesFor');
}

@override
List<PluginInfo> pluginsForContextRoot(analyzer.ContextRoot? contextRoot) {
fail('Unexpected invocation of pluginsForContextRoot');
}
dynamic noSuchMethod(Invocation invocation) =>
fail('Unexpected invocation of ${invocation.memberName}');

@override
void removedContextRoot(analyzer.ContextRoot contextRoot) {
Expand All @@ -233,7 +197,6 @@ class TestPluginManager implements PluginManager {
@override
Future<void> restartPlugins() async {
// Nothing to restart.
return;
}

@override
Expand All @@ -256,9 +219,4 @@ class TestPluginManager implements PluginManager {
) {
analysisUpdateContentParams = params;
}

@override
Future<List<void>> stopAll() async {
fail('Unexpected invocation of stopAll');
}
}

0 comments on commit fab7e4b

Please sign in to comment.