startSidecarPlugin function

Future<void> startSidecarPlugin(
  1. SendPort sendPort,
  2. List<String> args
)

Run Sidecar via analyzer_plugin package.

This function is called from tools/analyzer_plugin/bin/plugin.dart

Implementation

Future<void> startSidecarPlugin(
  SendPort sendPort,
  List<String> args,
) async {
  final channel = PluginIsolateChannel(sendPort);

  final LogDelegateBase delegate = PluginChannelDelegate(channel);
  runZonedGuarded(
    () {
      final container = ProviderContainer(
        overrides: [
          analyzerPluginChannelProvider.overrideWithValue(channel),
        ],
      );
      // logger.info('sidecar - plugin initialization....');
      final analyzerPlugin = container.read(analyzerPluginProvider);
      analyzerPlugin.start(channel);
    },
    delegate.sidecarError,
    zoneSpecification: ZoneSpecification(
      print: (self, parent, zone, line) {
        delegate.sidecarLog(line);
      },
    ),
  );
}