SearchGetElementDeclarationsParams.fromJson constructor

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

Implementation

factory SearchGetElementDeclarationsParams.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    String? file;
    if (json.containsKey('file')) {
      file = jsonDecoder.decodeString('$jsonPath.file', json['file']);
    }
    String? pattern;
    if (json.containsKey('pattern')) {
      pattern =
          jsonDecoder.decodeString('$jsonPath.pattern', json['pattern']);
    }
    int? maxResults;
    if (json.containsKey('maxResults')) {
      maxResults =
          jsonDecoder.decodeInt('$jsonPath.maxResults', json['maxResults']);
    }
    return SearchGetElementDeclarationsParams(
        file: file, pattern: pattern, maxResults: maxResults);
  } else {
    throw jsonDecoder.mismatch(
        jsonPath, 'search.getElementDeclarations params', json);
  }
}