AvailableSuggestion.fromJson constructor

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

Implementation

factory AvailableSuggestion.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    String label;
    if (json.containsKey('label')) {
      label = jsonDecoder.decodeString('$jsonPath.label', json['label']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'label');
    }
    String declaringLibraryUri;
    if (json.containsKey('declaringLibraryUri')) {
      declaringLibraryUri = jsonDecoder.decodeString(
          '$jsonPath.declaringLibraryUri', json['declaringLibraryUri']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'declaringLibraryUri');
    }
    Element element;
    if (json.containsKey('element')) {
      element =
          Element.fromJson(jsonDecoder, '$jsonPath.element', json['element']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'element');
    }
    String? defaultArgumentListString;
    if (json.containsKey('defaultArgumentListString')) {
      defaultArgumentListString = jsonDecoder.decodeString(
          '$jsonPath.defaultArgumentListString',
          json['defaultArgumentListString']);
    }
    List<int>? defaultArgumentListTextRanges;
    if (json.containsKey('defaultArgumentListTextRanges')) {
      defaultArgumentListTextRanges = jsonDecoder.decodeList(
          '$jsonPath.defaultArgumentListTextRanges',
          json['defaultArgumentListTextRanges'],
          jsonDecoder.decodeInt);
    }
    List<String>? parameterNames;
    if (json.containsKey('parameterNames')) {
      parameterNames = jsonDecoder.decodeList('$jsonPath.parameterNames',
          json['parameterNames'], jsonDecoder.decodeString);
    }
    List<String>? parameterTypes;
    if (json.containsKey('parameterTypes')) {
      parameterTypes = jsonDecoder.decodeList('$jsonPath.parameterTypes',
          json['parameterTypes'], jsonDecoder.decodeString);
    }
    List<String>? relevanceTags;
    if (json.containsKey('relevanceTags')) {
      relevanceTags = jsonDecoder.decodeList('$jsonPath.relevanceTags',
          json['relevanceTags'], jsonDecoder.decodeString);
    }
    int? requiredParameterCount;
    if (json.containsKey('requiredParameterCount')) {
      requiredParameterCount = jsonDecoder.decodeInt(
          '$jsonPath.requiredParameterCount', json['requiredParameterCount']);
    }
    return AvailableSuggestion(label, declaringLibraryUri, element,
        defaultArgumentListString: defaultArgumentListString,
        defaultArgumentListTextRanges: defaultArgumentListTextRanges,
        parameterNames: parameterNames,
        parameterTypes: parameterTypes,
        relevanceTags: relevanceTags,
        requiredParameterCount: requiredParameterCount);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'AvailableSuggestion', json);
  }
}