SearchGetElementDeclarationsResult.fromJson constructor

SearchGetElementDeclarationsResult.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json
)

Implementation

factory SearchGetElementDeclarationsResult.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    List<ElementDeclaration> declarations;
    if (json.containsKey('declarations')) {
      declarations = jsonDecoder.decodeList(
          '$jsonPath.declarations',
          json['declarations'],
          (String jsonPath, Object? json) =>
              ElementDeclaration.fromJson(jsonDecoder, jsonPath, json));
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'declarations');
    }
    List<String> files;
    if (json.containsKey('files')) {
      files = jsonDecoder.decodeList(
          '$jsonPath.files', json['files'], jsonDecoder.decodeString);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'files');
    }
    return SearchGetElementDeclarationsResult(declarations, files);
  } else {
    throw jsonDecoder.mismatch(
        jsonPath, 'search.getElementDeclarations result', json);
  }
}