CompletionSuggestion.fromJson constructor

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

Implementation

factory CompletionSuggestion.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    CompletionSuggestionKind kind;
    if (json.containsKey('kind')) {
      kind = CompletionSuggestionKind.fromJson(
          jsonDecoder, '$jsonPath.kind', json['kind']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'kind');
    }
    int relevance;
    if (json.containsKey('relevance')) {
      relevance =
          jsonDecoder.decodeInt('$jsonPath.relevance', json['relevance']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'relevance');
    }
    String completion;
    if (json.containsKey('completion')) {
      completion = jsonDecoder.decodeString(
          '$jsonPath.completion', json['completion']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'completion');
    }
    String? displayText;
    if (json.containsKey('displayText')) {
      displayText = jsonDecoder.decodeString(
          '$jsonPath.displayText', json['displayText']);
    }
    int? replacementOffset;
    if (json.containsKey('replacementOffset')) {
      replacementOffset = jsonDecoder.decodeInt(
          '$jsonPath.replacementOffset', json['replacementOffset']);
    }
    int? replacementLength;
    if (json.containsKey('replacementLength')) {
      replacementLength = jsonDecoder.decodeInt(
          '$jsonPath.replacementLength', json['replacementLength']);
    }
    int selectionOffset;
    if (json.containsKey('selectionOffset')) {
      selectionOffset = jsonDecoder.decodeInt(
          '$jsonPath.selectionOffset', json['selectionOffset']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'selectionOffset');
    }
    int selectionLength;
    if (json.containsKey('selectionLength')) {
      selectionLength = jsonDecoder.decodeInt(
          '$jsonPath.selectionLength', json['selectionLength']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'selectionLength');
    }
    bool isDeprecated;
    if (json.containsKey('isDeprecated')) {
      isDeprecated = jsonDecoder.decodeBool(
          '$jsonPath.isDeprecated', json['isDeprecated']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'isDeprecated');
    }
    bool isPotential;
    if (json.containsKey('isPotential')) {
      isPotential = jsonDecoder.decodeBool(
          '$jsonPath.isPotential', json['isPotential']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'isPotential');
    }
    String? docSummary;
    if (json.containsKey('docSummary')) {
      docSummary = jsonDecoder.decodeString(
          '$jsonPath.docSummary', json['docSummary']);
    }
    String? docComplete;
    if (json.containsKey('docComplete')) {
      docComplete = jsonDecoder.decodeString(
          '$jsonPath.docComplete', json['docComplete']);
    }
    String? declaringType;
    if (json.containsKey('declaringType')) {
      declaringType = jsonDecoder.decodeString(
          '$jsonPath.declaringType', json['declaringType']);
    }
    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);
    }
    Element? element;
    if (json.containsKey('element')) {
      element =
          Element.fromJson(jsonDecoder, '$jsonPath.element', json['element']);
    }
    String? returnType;
    if (json.containsKey('returnType')) {
      returnType = jsonDecoder.decodeString(
          '$jsonPath.returnType', json['returnType']);
    }
    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);
    }
    int? requiredParameterCount;
    if (json.containsKey('requiredParameterCount')) {
      requiredParameterCount = jsonDecoder.decodeInt(
          '$jsonPath.requiredParameterCount', json['requiredParameterCount']);
    }
    bool? hasNamedParameters;
    if (json.containsKey('hasNamedParameters')) {
      hasNamedParameters = jsonDecoder.decodeBool(
          '$jsonPath.hasNamedParameters', json['hasNamedParameters']);
    }
    String? parameterName;
    if (json.containsKey('parameterName')) {
      parameterName = jsonDecoder.decodeString(
          '$jsonPath.parameterName', json['parameterName']);
    }
    String? parameterType;
    if (json.containsKey('parameterType')) {
      parameterType = jsonDecoder.decodeString(
          '$jsonPath.parameterType', json['parameterType']);
    }
    String? libraryUri;
    if (json.containsKey('libraryUri')) {
      libraryUri = jsonDecoder.decodeString(
          '$jsonPath.libraryUri', json['libraryUri']);
    }
    bool? isNotImported;
    if (json.containsKey('isNotImported')) {
      isNotImported = jsonDecoder.decodeBool(
          '$jsonPath.isNotImported', json['isNotImported']);
    }
    return CompletionSuggestion(kind, relevance, completion, selectionOffset,
        selectionLength, isDeprecated, isPotential,
        displayText: displayText,
        replacementOffset: replacementOffset,
        replacementLength: replacementLength,
        docSummary: docSummary,
        docComplete: docComplete,
        declaringType: declaringType,
        defaultArgumentListString: defaultArgumentListString,
        defaultArgumentListTextRanges: defaultArgumentListTextRanges,
        element: element,
        returnType: returnType,
        parameterNames: parameterNames,
        parameterTypes: parameterTypes,
        requiredParameterCount: requiredParameterCount,
        hasNamedParameters: hasNamedParameters,
        parameterName: parameterName,
        parameterType: parameterType,
        libraryUri: libraryUri,
        isNotImported: isNotImported);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'CompletionSuggestion', json);
  }
}