CompletionSuggestion.fromJson constructor

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

Implementation

factory CompletionSuggestion.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(jsonPath, "'CompletionSuggestion'", json);
  }
  CompletionSuggestionKind kind;
  if (json case {'kind': var encodedKind}) {
    kind = CompletionSuggestionKind.fromJson(
      jsonDecoder,
      '$jsonPath.kind',
      encodedKind,
      clientUriConverter: clientUriConverter,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'kind'", json);
  }
  int relevance;
  if (json case {'relevance': var encodedRelevance}) {
    relevance = jsonDecoder.decodeInt(
      '$jsonPath.relevance',
      encodedRelevance,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'relevance'", json);
  }
  String completion;
  if (json case {'completion': var encodedCompletion}) {
    completion = jsonDecoder.decodeString(
      '$jsonPath.completion',
      encodedCompletion,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'completion'", json);
  }
  String? displayText;
  if (json case {'displayText': var encodedDisplayText}) {
    displayText = jsonDecoder.decodeString(
      '$jsonPath.displayText',
      encodedDisplayText,
    );
  }
  int? replacementOffset;
  if (json case {'replacementOffset': var encodedReplacementOffset}) {
    replacementOffset = jsonDecoder.decodeInt(
      '$jsonPath.replacementOffset',
      encodedReplacementOffset,
    );
  }
  int? replacementLength;
  if (json case {'replacementLength': var encodedReplacementLength}) {
    replacementLength = jsonDecoder.decodeInt(
      '$jsonPath.replacementLength',
      encodedReplacementLength,
    );
  }
  int selectionOffset;
  if (json case {'selectionOffset': var encodedSelectionOffset}) {
    selectionOffset = jsonDecoder.decodeInt(
      '$jsonPath.selectionOffset',
      encodedSelectionOffset,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'selectionOffset'", json);
  }
  int selectionLength;
  if (json case {'selectionLength': var encodedSelectionLength}) {
    selectionLength = jsonDecoder.decodeInt(
      '$jsonPath.selectionLength',
      encodedSelectionLength,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'selectionLength'", json);
  }
  bool isDeprecated;
  if (json case {'isDeprecated': var encodedIsDeprecated}) {
    isDeprecated = jsonDecoder.decodeBool(
      '$jsonPath.isDeprecated',
      encodedIsDeprecated,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'isDeprecated'", json);
  }
  bool isPotential;
  if (json case {'isPotential': var encodedIsPotential}) {
    isPotential = jsonDecoder.decodeBool(
      '$jsonPath.isPotential',
      encodedIsPotential,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'isPotential'", json);
  }
  String? docSummary;
  if (json case {'docSummary': var encodedDocSummary}) {
    docSummary = jsonDecoder.decodeString(
      '$jsonPath.docSummary',
      encodedDocSummary,
    );
  }
  String? docComplete;
  if (json case {'docComplete': var encodedDocComplete}) {
    docComplete = jsonDecoder.decodeString(
      '$jsonPath.docComplete',
      encodedDocComplete,
    );
  }
  String? declaringType;
  if (json case {'declaringType': var encodedDeclaringType}) {
    declaringType = jsonDecoder.decodeString(
      '$jsonPath.declaringType',
      encodedDeclaringType,
    );
  }
  String? defaultArgumentListString;
  if (json case {
    'defaultArgumentListString': var encodedDefaultArgumentListString,
  }) {
    defaultArgumentListString = jsonDecoder.decodeString(
      '$jsonPath.defaultArgumentListString',
      encodedDefaultArgumentListString,
    );
  }
  List<int>? defaultArgumentListTextRanges;
  if (json case {
    'defaultArgumentListTextRanges': var encodedDefaultArgumentListTextRanges,
  }) {
    defaultArgumentListTextRanges = jsonDecoder.decodeList(
      '$jsonPath.defaultArgumentListTextRanges',
      encodedDefaultArgumentListTextRanges,
      jsonDecoder.decodeInt,
    );
  }
  Element? element;
  if (json case {'element': var encodedElement}) {
    element = Element.fromJson(
      jsonDecoder,
      '$jsonPath.element',
      encodedElement,
      clientUriConverter: clientUriConverter,
    );
  }
  String? returnType;
  if (json case {'returnType': var encodedReturnType}) {
    returnType = jsonDecoder.decodeString(
      '$jsonPath.returnType',
      encodedReturnType,
    );
  }
  List<String>? parameterNames;
  if (json case {'parameterNames': var encodedParameterNames}) {
    parameterNames = jsonDecoder.decodeList(
      '$jsonPath.parameterNames',
      encodedParameterNames,
      jsonDecoder.decodeString,
    );
  }
  List<String>? parameterTypes;
  if (json case {'parameterTypes': var encodedParameterTypes}) {
    parameterTypes = jsonDecoder.decodeList(
      '$jsonPath.parameterTypes',
      encodedParameterTypes,
      jsonDecoder.decodeString,
    );
  }
  int? requiredParameterCount;
  if (json case {
    'requiredParameterCount': var encodedRequiredParameterCount,
  }) {
    requiredParameterCount = jsonDecoder.decodeInt(
      '$jsonPath.requiredParameterCount',
      encodedRequiredParameterCount,
    );
  }
  bool? hasNamedParameters;
  if (json case {'hasNamedParameters': var encodedHasNamedParameters}) {
    hasNamedParameters = jsonDecoder.decodeBool(
      '$jsonPath.hasNamedParameters',
      encodedHasNamedParameters,
    );
  }
  String? parameterName;
  if (json case {'parameterName': var encodedParameterName}) {
    parameterName = jsonDecoder.decodeString(
      '$jsonPath.parameterName',
      encodedParameterName,
    );
  }
  String? parameterType;
  if (json case {'parameterType': var encodedParameterType}) {
    parameterType = jsonDecoder.decodeString(
      '$jsonPath.parameterType',
      encodedParameterType,
    );
  }
  String? libraryUri;
  if (json case {'libraryUri': var encodedLibraryUri}) {
    libraryUri = jsonDecoder.decodeString(
      '$jsonPath.libraryUri',
      encodedLibraryUri,
    );
  }
  bool? isNotImported;
  if (json case {'isNotImported': var encodedIsNotImported}) {
    isNotImported = jsonDecoder.decodeBool(
      '$jsonPath.isNotImported',
      encodedIsNotImported,
    );
  }
  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,
  );
}