ExtractLocalVariableFeedback.fromJson constructor

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

Implementation

factory ExtractLocalVariableFeedback.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(
      jsonPath,
      "'extractLocalVariable feedback'",
      json,
    );
  }
  List<int>? coveringExpressionOffsets;
  if (json case {
    'coveringExpressionOffsets': var encodedCoveringExpressionOffsets,
  }) {
    coveringExpressionOffsets = jsonDecoder.decodeList(
      '$jsonPath.coveringExpressionOffsets',
      encodedCoveringExpressionOffsets,
      jsonDecoder.decodeInt,
    );
  }
  List<int>? coveringExpressionLengths;
  if (json case {
    'coveringExpressionLengths': var encodedCoveringExpressionLengths,
  }) {
    coveringExpressionLengths = jsonDecoder.decodeList(
      '$jsonPath.coveringExpressionLengths',
      encodedCoveringExpressionLengths,
      jsonDecoder.decodeInt,
    );
  }
  List<String> names;
  if (json case {'names': var encodedNames}) {
    names = jsonDecoder.decodeList(
      '$jsonPath.names',
      encodedNames,
      jsonDecoder.decodeString,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'names'", json);
  }
  List<int> offsets;
  if (json case {'offsets': var encodedOffsets}) {
    offsets = jsonDecoder.decodeList(
      '$jsonPath.offsets',
      encodedOffsets,
      jsonDecoder.decodeInt,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'offsets'", json);
  }
  List<int> lengths;
  if (json case {'lengths': var encodedLengths}) {
    lengths = jsonDecoder.decodeList(
      '$jsonPath.lengths',
      encodedLengths,
      jsonDecoder.decodeInt,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'lengths'", json);
  }
  return ExtractLocalVariableFeedback(
    names,
    offsets,
    lengths,
    coveringExpressionOffsets: coveringExpressionOffsets,
    coveringExpressionLengths: coveringExpressionLengths,
  );
}