CompletionGetSuggestions2Params.fromJson constructor

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

Implementation

factory CompletionGetSuggestions2Params.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']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'file');
    }
    int offset;
    if (json.containsKey('offset')) {
      offset = jsonDecoder.decodeInt('$jsonPath.offset', json['offset']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'offset');
    }
    int maxResults;
    if (json.containsKey('maxResults')) {
      maxResults =
          jsonDecoder.decodeInt('$jsonPath.maxResults', json['maxResults']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'maxResults');
    }
    CompletionCaseMatchingMode? completionCaseMatchingMode;
    if (json.containsKey('completionCaseMatchingMode')) {
      completionCaseMatchingMode = CompletionCaseMatchingMode.fromJson(
          jsonDecoder,
          '$jsonPath.completionCaseMatchingMode',
          json['completionCaseMatchingMode']);
    }
    CompletionMode? completionMode;
    if (json.containsKey('completionMode')) {
      completionMode = CompletionMode.fromJson(
          jsonDecoder, '$jsonPath.completionMode', json['completionMode']);
    }
    int? invocationCount;
    if (json.containsKey('invocationCount')) {
      invocationCount = jsonDecoder.decodeInt(
          '$jsonPath.invocationCount', json['invocationCount']);
    }
    int? timeout;
    if (json.containsKey('timeout')) {
      timeout = jsonDecoder.decodeInt('$jsonPath.timeout', json['timeout']);
    }
    return CompletionGetSuggestions2Params(file, offset, maxResults,
        completionCaseMatchingMode: completionCaseMatchingMode,
        completionMode: completionMode,
        invocationCount: invocationCount,
        timeout: timeout);
  } else {
    throw jsonDecoder.mismatch(
        jsonPath, 'completion.getSuggestions2 params', json);
  }
}