AnalysisFoldingParams.fromJson constructor

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

Implementation

factory AnalysisFoldingParams.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(jsonPath, "'analysis.folding 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<FoldingRegion> regions;
  if (json case {'regions': var encodedRegions}) {
    regions = jsonDecoder.decodeList(
      '$jsonPath.regions',
      encodedRegions,
      (String jsonPath, Object? json) => FoldingRegion.fromJson(
        jsonDecoder,
        jsonPath,
        json,
        clientUriConverter: clientUriConverter,
      ),
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'regions'", json);
  }
  return AnalysisFoldingParams(file, regions);
}