FoldingRegion.fromJson constructor

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

Implementation

factory FoldingRegion.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(jsonPath, "'FoldingRegion'", json);
  }
  FoldingKind kind;
  if (json case {'kind': var encodedKind}) {
    kind = FoldingKind.fromJson(
      jsonDecoder,
      '$jsonPath.kind',
      encodedKind,
      clientUriConverter: clientUriConverter,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'kind'", 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);
  }
  return FoldingRegion(kind, offset, length);
}