CompletionGetSuggestionsParams.fromJson constructor

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

Implementation

factory CompletionGetSuggestionsParams.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(
      jsonPath,
      "'completion.getSuggestions params'",
      json,
    );
  }
  String file;
  if (json case {'file': var encodedFile}) {
    file =
        clientUriConverter?.fromClientFilePath(
          jsonDecoder.decodeString('$jsonPath.file', encodedFile),
        ) ??
        jsonDecoder.decodeString('$jsonPath.file', encodedFile);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'file'", json);
  }
  int offset;
  if (json case {'offset': var encodedOffset}) {
    offset = jsonDecoder.decodeInt('$jsonPath.offset', encodedOffset);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'offset'", json);
  }
  return CompletionGetSuggestionsParams(file, offset);
}