AnalysisError.fromJson constructor
AnalysisError.fromJson(})
Implementation
factory AnalysisError.fromJson(
JsonDecoder jsonDecoder,
String jsonPath,
Object? json, {
ClientUriConverter? clientUriConverter,
}) {
json ??= {};
if (json is! Map) {
throw jsonDecoder.mismatch(jsonPath, "'AnalysisError'", json);
}
AnalysisErrorSeverity severity;
if (json case {'severity': var encodedSeverity}) {
severity = AnalysisErrorSeverity.fromJson(
jsonDecoder,
'$jsonPath.severity',
encodedSeverity,
clientUriConverter: clientUriConverter,
);
} else {
throw jsonDecoder.mismatch(jsonPath, "'severity'", json);
}
AnalysisErrorType type;
if (json case {'type': var encodedType}) {
type = AnalysisErrorType.fromJson(
jsonDecoder,
'$jsonPath.type',
encodedType,
clientUriConverter: clientUriConverter,
);
} else {
throw jsonDecoder.mismatch(jsonPath, "'type'", json);
}
Location location;
if (json case {'location': var encodedLocation}) {
location = Location.fromJson(
jsonDecoder,
'$jsonPath.location',
encodedLocation,
clientUriConverter: clientUriConverter,
);
} else {
throw jsonDecoder.mismatch(jsonPath, "'location'", json);
}
String message;
if (json case {'message': var encodedMessage}) {
message = jsonDecoder.decodeString('$jsonPath.message', encodedMessage);
} else {
throw jsonDecoder.mismatch(jsonPath, "'message'", json);
}
String? correction;
if (json case {'correction': var encodedCorrection}) {
correction = jsonDecoder.decodeString(
'$jsonPath.correction',
encodedCorrection,
);
}
String code;
if (json case {'code': var encodedCode}) {
code = jsonDecoder.decodeString('$jsonPath.code', encodedCode);
} else {
throw jsonDecoder.mismatch(jsonPath, "'code'", json);
}
String? url;
if (json case {'url': var encodedUrl}) {
url = jsonDecoder.decodeString('$jsonPath.url', encodedUrl);
}
List<DiagnosticMessage>? contextMessages;
if (json case {'contextMessages': var encodedContextMessages}) {
contextMessages = jsonDecoder.decodeList(
'$jsonPath.contextMessages',
encodedContextMessages,
(String jsonPath, Object? json) => DiagnosticMessage.fromJson(
jsonDecoder,
jsonPath,
json,
clientUriConverter: clientUriConverter,
),
);
}
bool? hasFix;
if (json case {'hasFix': var encodedHasFix}) {
hasFix = jsonDecoder.decodeBool('$jsonPath.hasFix', encodedHasFix);
}
return AnalysisError(
severity,
type,
location,
message,
code,
correction: correction,
url: url,
contextMessages: contextMessages,
hasFix: hasFix,
);
}