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) {
    List<int>? coveringExpressionOffsets;
    if (json.containsKey('coveringExpressionOffsets')) {
      coveringExpressionOffsets = jsonDecoder.decodeList(
        '$jsonPath.coveringExpressionOffsets',
        json['coveringExpressionOffsets'],
        jsonDecoder.decodeInt,
      );
    }
    List<int>? coveringExpressionLengths;
    if (json.containsKey('coveringExpressionLengths')) {
      coveringExpressionLengths = jsonDecoder.decodeList(
        '$jsonPath.coveringExpressionLengths',
        json['coveringExpressionLengths'],
        jsonDecoder.decodeInt,
      );
    }
    List<String> names;
    if (json.containsKey('names')) {
      names = jsonDecoder.decodeList(
        '$jsonPath.names',
        json['names'],
        jsonDecoder.decodeString,
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'names');
    }
    List<int> offsets;
    if (json.containsKey('offsets')) {
      offsets = jsonDecoder.decodeList(
        '$jsonPath.offsets',
        json['offsets'],
        jsonDecoder.decodeInt,
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'offsets');
    }
    List<int> lengths;
    if (json.containsKey('lengths')) {
      lengths = jsonDecoder.decodeList(
        '$jsonPath.lengths',
        json['lengths'],
        jsonDecoder.decodeInt,
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'lengths');
    }
    return ExtractLocalVariableFeedback(
      names,
      offsets,
      lengths,
      coveringExpressionOffsets: coveringExpressionOffsets,
      coveringExpressionLengths: coveringExpressionLengths,
    );
  } else {
    throw jsonDecoder.mismatch(
      jsonPath,
      'extractLocalVariable feedback',
      json,
    );
  }
}