SourceFileEdit.fromJson constructor

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

Implementation

factory SourceFileEdit.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(jsonPath, "'SourceFileEdit'", 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 fileStamp;
  if (json case {'fileStamp': var encodedFileStamp}) {
    fileStamp = jsonDecoder.decodeInt(
      '$jsonPath.fileStamp',
      encodedFileStamp,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'fileStamp'", json);
  }
  List<SourceEdit> edits;
  if (json case {'edits': var encodedEdits}) {
    edits = jsonDecoder.decodeList(
      '$jsonPath.edits',
      encodedEdits,
      (String jsonPath, Object? json) => SourceEdit.fromJson(
        jsonDecoder,
        jsonPath,
        json,
        clientUriConverter: clientUriConverter,
      ),
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'edits'", json);
  }
  return SourceFileEdit(file, fileStamp, edits: edits);
}