EditGetRefactoringResult.fromJson constructor

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

Implementation

factory EditGetRefactoringResult.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is Map) {
    List<RefactoringProblem> initialProblems;
    if (json.containsKey('initialProblems')) {
      initialProblems = jsonDecoder.decodeList(
        '$jsonPath.initialProblems',
        json['initialProblems'],
        (String jsonPath, Object? json) => RefactoringProblem.fromJson(
          jsonDecoder,
          jsonPath,
          json,
          clientUriConverter: clientUriConverter,
        ),
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'initialProblems');
    }
    List<RefactoringProblem> optionsProblems;
    if (json.containsKey('optionsProblems')) {
      optionsProblems = jsonDecoder.decodeList(
        '$jsonPath.optionsProblems',
        json['optionsProblems'],
        (String jsonPath, Object? json) => RefactoringProblem.fromJson(
          jsonDecoder,
          jsonPath,
          json,
          clientUriConverter: clientUriConverter,
        ),
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'optionsProblems');
    }
    List<RefactoringProblem> finalProblems;
    if (json.containsKey('finalProblems')) {
      finalProblems = jsonDecoder.decodeList(
        '$jsonPath.finalProblems',
        json['finalProblems'],
        (String jsonPath, Object? json) => RefactoringProblem.fromJson(
          jsonDecoder,
          jsonPath,
          json,
          clientUriConverter: clientUriConverter,
        ),
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'finalProblems');
    }
    RefactoringFeedback? feedback;
    if (json.containsKey('feedback')) {
      feedback = RefactoringFeedback.fromJson(
        jsonDecoder,
        '$jsonPath.feedback',
        json['feedback'],
        json,
        clientUriConverter: clientUriConverter,
      );
    }
    SourceChange? change;
    if (json.containsKey('change')) {
      change = SourceChange.fromJson(
        jsonDecoder,
        '$jsonPath.change',
        json['change'],
        clientUriConverter: clientUriConverter,
      );
    }
    List<String>? potentialEdits;
    if (json.containsKey('potentialEdits')) {
      potentialEdits = jsonDecoder.decodeList(
        '$jsonPath.potentialEdits',
        json['potentialEdits'],
        jsonDecoder.decodeString,
      );
    }
    return EditGetRefactoringResult(
      initialProblems,
      optionsProblems,
      finalProblems,
      feedback: feedback,
      change: change,
      potentialEdits: potentialEdits,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'edit.getRefactoring result', json);
  }
}