AnalysisOccurrencesParams.fromJson constructor

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

Implementation

factory AnalysisOccurrencesParams.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(
      jsonPath,
      "'analysis.occurrences params'",
      json,
    );
  }
  String file;
  if (json case {'file': var encodedFile}) {
    file =
        clientUriConverter?.fromClientFilePath(
          jsonDecoder.decodeString('$jsonPath.file', encodedFile),
        ) ??
        jsonDecoder.decodeString('$jsonPath.file', encodedFile);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'file'", json);
  }
  List<Occurrences> occurrences;
  if (json case {'occurrences': var encodedOccurrences}) {
    occurrences = jsonDecoder.decodeList(
      '$jsonPath.occurrences',
      encodedOccurrences,
      (String jsonPath, Object? json) => Occurrences.fromJson(
        jsonDecoder,
        jsonPath,
        json,
        clientUriConverter: clientUriConverter,
      ),
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'occurrences'", json);
  }
  return AnalysisOccurrencesParams(file, occurrences);
}