generateOccurrencesNotification method

GeneratorResult<ResponseResult?> generateOccurrencesNotification(
  1. OccurrencesRequest request
)

Create an 'analysis.occurrences' notification. If any of the contributors throws an exception, also create a non-fatal 'plugin.error' notification.

Implementation

GeneratorResult generateOccurrencesNotification(OccurrencesRequest request) {
  var notifications = <Notification>[];
  var collector = OccurrencesCollectorImpl();
  for (var contributor in contributors) {
    try {
      contributor.computeOccurrences(request, collector);
    } catch (exception, stackTrace) {
      notifications.add(
        PluginErrorParams(
          false,
          exception.toString(),
          stackTrace.toString(),
        ).toNotification(),
      );
    }
  }
  notifications.add(
    AnalysisOccurrencesParams(
      request.path,
      collector.occurrences,
    ).toNotification(),
  );
  return GeneratorResult(null, notifications);
}