ExtractMethodFeedback.fromJson constructor

ExtractMethodFeedback.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json
)

Implementation

factory ExtractMethodFeedback.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    int offset;
    if (json.containsKey('offset')) {
      offset = jsonDecoder.decodeInt('$jsonPath.offset', json['offset']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'offset');
    }
    int length;
    if (json.containsKey('length')) {
      length = jsonDecoder.decodeInt('$jsonPath.length', json['length']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'length');
    }
    String returnType;
    if (json.containsKey('returnType')) {
      returnType = jsonDecoder.decodeString(
          '$jsonPath.returnType', json['returnType']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'returnType');
    }
    List<String> names;
    if (json.containsKey('names')) {
      names = jsonDecoder.decodeList(
          '$jsonPath.names', json['names'], jsonDecoder.decodeString);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'names');
    }
    bool canCreateGetter;
    if (json.containsKey('canCreateGetter')) {
      canCreateGetter = jsonDecoder.decodeBool(
          '$jsonPath.canCreateGetter', json['canCreateGetter']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'canCreateGetter');
    }
    List<RefactoringMethodParameter> parameters;
    if (json.containsKey('parameters')) {
      parameters = jsonDecoder.decodeList(
          '$jsonPath.parameters',
          json['parameters'],
          (String jsonPath, Object? json) =>
              RefactoringMethodParameter.fromJson(
                  jsonDecoder, jsonPath, json));
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'parameters');
    }
    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 ExtractMethodFeedback(offset, length, returnType, names,
        canCreateGetter, parameters, offsets, lengths);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'extractMethod feedback', json);
  }
}