RefactoringProblem.fromJson constructor

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

Implementation

factory RefactoringProblem.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    RefactoringProblemSeverity severity;
    if (json.containsKey('severity')) {
      severity = RefactoringProblemSeverity.fromJson(
          jsonDecoder, '$jsonPath.severity', json['severity']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'severity');
    }
    String message;
    if (json.containsKey('message')) {
      message =
          jsonDecoder.decodeString('$jsonPath.message', json['message']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'message');
    }
    Location? location;
    if (json.containsKey('location')) {
      location = Location.fromJson(
          jsonDecoder, '$jsonPath.location', json['location']);
    }
    return RefactoringProblem(severity, message, location: location);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'RefactoringProblem', json);
  }
}