ElementDeclaration.fromJson constructor
ElementDeclaration.fromJson(
- JsonDecoder jsonDecoder,
- String jsonPath,
- Object? json
)
Implementation
factory ElementDeclaration.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
json ??= {};
if (json is Map) {
String name;
if (json.containsKey('name')) {
name = jsonDecoder.decodeString('$jsonPath.name', json['name']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'name');
}
ElementKind kind;
if (json.containsKey('kind')) {
kind =
ElementKind.fromJson(jsonDecoder, '$jsonPath.kind', json['kind']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'kind');
}
int fileIndex;
if (json.containsKey('fileIndex')) {
fileIndex =
jsonDecoder.decodeInt('$jsonPath.fileIndex', json['fileIndex']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'fileIndex');
}
int offset;
if (json.containsKey('offset')) {
offset = jsonDecoder.decodeInt('$jsonPath.offset', json['offset']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'offset');
}
int line;
if (json.containsKey('line')) {
line = jsonDecoder.decodeInt('$jsonPath.line', json['line']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'line');
}
int column;
if (json.containsKey('column')) {
column = jsonDecoder.decodeInt('$jsonPath.column', json['column']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'column');
}
int codeOffset;
if (json.containsKey('codeOffset')) {
codeOffset =
jsonDecoder.decodeInt('$jsonPath.codeOffset', json['codeOffset']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'codeOffset');
}
int codeLength;
if (json.containsKey('codeLength')) {
codeLength =
jsonDecoder.decodeInt('$jsonPath.codeLength', json['codeLength']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'codeLength');
}
String? className;
if (json.containsKey('className')) {
className =
jsonDecoder.decodeString('$jsonPath.className', json['className']);
}
String? mixinName;
if (json.containsKey('mixinName')) {
mixinName =
jsonDecoder.decodeString('$jsonPath.mixinName', json['mixinName']);
}
String? parameters;
if (json.containsKey('parameters')) {
parameters = jsonDecoder.decodeString(
'$jsonPath.parameters', json['parameters']);
}
return ElementDeclaration(
name, kind, fileIndex, offset, line, column, codeOffset, codeLength,
className: className, mixinName: mixinName, parameters: parameters);
} else {
throw jsonDecoder.mismatch(jsonPath, 'ElementDeclaration', json);
}
}