EditGetRefactoringParams.fromJson constructor

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

Implementation

factory EditGetRefactoringParams.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(
      jsonPath,
      "'edit.getRefactoring params'",
      json,
    );
  }
  RefactoringKind kind;
  if (json case {'kind': var encodedKind}) {
    kind = RefactoringKind.fromJson(
      jsonDecoder,
      '$jsonPath.kind',
      encodedKind,
      clientUriConverter: clientUriConverter,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'kind'", 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);
  }
  int length;
  if (json case {'length': var encodedLength}) {
    length = jsonDecoder.decodeInt('$jsonPath.length', encodedLength);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'length'", json);
  }
  bool validateOnly;
  if (json case {'validateOnly': var encodedValidateOnly}) {
    validateOnly = jsonDecoder.decodeBool(
      '$jsonPath.validateOnly',
      encodedValidateOnly,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'validateOnly'", json);
  }
  RefactoringOptions? options;
  if (json case {'options': var encodedOptions}) {
    options = RefactoringOptions.fromJson(
      jsonDecoder,
      '$jsonPath.options',
      encodedOptions,
      kind,
      clientUriConverter: clientUriConverter,
    );
  }
  return EditGetRefactoringParams(
    kind,
    file,
    offset,
    length,
    validateOnly,
    options: options,
  );
}