AnalysisErrorFixes.fromJson constructor

AnalysisErrorFixes.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json, {
  4. ClientUriConverter? clientUriConverter,
})

Implementation

factory AnalysisErrorFixes.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(jsonPath, "'AnalysisErrorFixes'", json);
  }
  AnalysisError error;
  if (json case {'error': var encodedError}) {
    error = AnalysisError.fromJson(
      jsonDecoder,
      '$jsonPath.error',
      encodedError,
      clientUriConverter: clientUriConverter,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'error'", json);
  }
  List<PrioritizedSourceChange> fixes;
  if (json case {'fixes': var encodedFixes}) {
    fixes = jsonDecoder.decodeList(
      '$jsonPath.fixes',
      encodedFixes,
      (String jsonPath, Object? json) => PrioritizedSourceChange.fromJson(
        jsonDecoder,
        jsonPath,
        json,
        clientUriConverter: clientUriConverter,
      ),
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'fixes'", json);
  }
  return AnalysisErrorFixes(error, fixes: fixes);
}