Location.fromJson constructor
Location.fromJson(})
Implementation
factory Location.fromJson(
JsonDecoder jsonDecoder,
String jsonPath,
Object? json, {
ClientUriConverter? clientUriConverter,
}) {
json ??= {};
if (json is! Map) {
throw jsonDecoder.mismatch(jsonPath, "'Location'", json);
}
String file;
if (json case {'file': var encodedFile}) {
file =
clientUriConverter?.fromClientFilePath(
jsonDecoder.decodeString('$jsonPath.file', encodedFile),
) ??
jsonDecoder.decodeString('$jsonPath.file', encodedFile);
} else {
throw jsonDecoder.mismatch(jsonPath, "'file'", json);
}
int offset;
if (json case {'offset': var encodedOffset}) {
offset = jsonDecoder.decodeInt('$jsonPath.offset', encodedOffset);
} else {
throw jsonDecoder.mismatch(jsonPath, "'offset'", json);
}
int length;
if (json case {'length': var encodedLength}) {
length = jsonDecoder.decodeInt('$jsonPath.length', encodedLength);
} else {
throw jsonDecoder.mismatch(jsonPath, "'length'", json);
}
int startLine;
if (json case {'startLine': var encodedStartLine}) {
startLine = jsonDecoder.decodeInt(
'$jsonPath.startLine',
encodedStartLine,
);
} else {
throw jsonDecoder.mismatch(jsonPath, "'startLine'", json);
}
int startColumn;
if (json case {'startColumn': var encodedStartColumn}) {
startColumn = jsonDecoder.decodeInt(
'$jsonPath.startColumn',
encodedStartColumn,
);
} else {
throw jsonDecoder.mismatch(jsonPath, "'startColumn'", json);
}
int? endLine;
if (json case {'endLine': var encodedEndLine}) {
endLine = jsonDecoder.decodeInt('$jsonPath.endLine', encodedEndLine);
}
int? endColumn;
if (json case {'endColumn': var encodedEndColumn}) {
endColumn = jsonDecoder.decodeInt(
'$jsonPath.endColumn',
encodedEndColumn,
);
}
return Location(
file,
offset,
length,
startLine,
startColumn,
endLine: endLine,
endColumn: endColumn,
);
}