AnalysisNavigationParams.fromJson constructor

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

Implementation

factory AnalysisNavigationParams.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json,
    {ClientUriConverter? clientUriConverter}) {
  json ??= {};
  if (json is Map) {
    String file;
    if (json.containsKey('file')) {
      file = clientUriConverter?.fromClientFilePath(
              jsonDecoder.decodeString('$jsonPath.file', json['file'])) ??
          jsonDecoder.decodeString('$jsonPath.file', json['file']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'file');
    }
    List<NavigationRegion> regions;
    if (json.containsKey('regions')) {
      regions = jsonDecoder.decodeList(
          '$jsonPath.regions',
          json['regions'],
          (String jsonPath, Object? json) => NavigationRegion.fromJson(
              jsonDecoder, jsonPath, json,
              clientUriConverter: clientUriConverter));
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'regions');
    }
    List<NavigationTarget> targets;
    if (json.containsKey('targets')) {
      targets = jsonDecoder.decodeList(
          '$jsonPath.targets',
          json['targets'],
          (String jsonPath, Object? json) => NavigationTarget.fromJson(
              jsonDecoder, jsonPath, json,
              clientUriConverter: clientUriConverter));
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'targets');
    }
    List<String> files;
    if (json.containsKey('files')) {
      files = jsonDecoder.decodeList(
          '$jsonPath.files',
          json['files'],
          (String jsonPath, Object? json) =>
              clientUriConverter?.fromClientFilePath(
                  jsonDecoder.decodeString(jsonPath, json)) ??
              jsonDecoder.decodeString(jsonPath, json));
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'files');
    }
    return AnalysisNavigationParams(file, regions, targets, files);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'analysis.navigation params', json);
  }
}