SourceEdit.fromJson constructor

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

Implementation

factory SourceEdit.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(jsonPath, "'SourceEdit'", 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);
  }
  String replacement;
  if (json case {'replacement': var encodedReplacement}) {
    replacement = jsonDecoder.decodeString(
      '$jsonPath.replacement',
      encodedReplacement,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'replacement'", json);
  }
  String? id;
  if (json case {'id': var encodedId}) {
    id = jsonDecoder.decodeString('$jsonPath.id', encodedId);
  }
  String? description;
  if (json case {'description': var encodedDescription}) {
    description = jsonDecoder.decodeString(
      '$jsonPath.description',
      encodedDescription,
    );
  }
  return SourceEdit(
    offset,
    length,
    replacement,
    id: id,
    description: description,
  );
}