ExtractMethodOptions.fromJson constructor
ExtractMethodOptions.fromJson(})
Implementation
factory ExtractMethodOptions.fromJson(
JsonDecoder jsonDecoder,
String jsonPath,
Object? json, {
ClientUriConverter? clientUriConverter,
}) {
json ??= {};
if (json is! Map) {
throw jsonDecoder.mismatch(jsonPath, "'extractMethod options'", json);
}
String returnType;
if (json case {'returnType': var encodedReturnType}) {
returnType = jsonDecoder.decodeString(
'$jsonPath.returnType',
encodedReturnType,
);
} else {
throw jsonDecoder.mismatch(jsonPath, "'returnType'", json);
}
bool createGetter;
if (json case {'createGetter': var encodedCreateGetter}) {
createGetter = jsonDecoder.decodeBool(
'$jsonPath.createGetter',
encodedCreateGetter,
);
} else {
throw jsonDecoder.mismatch(jsonPath, "'createGetter'", json);
}
String name;
if (json case {'name': var encodedName}) {
name = jsonDecoder.decodeString('$jsonPath.name', encodedName);
} else {
throw jsonDecoder.mismatch(jsonPath, "'name'", json);
}
List<RefactoringMethodParameter> parameters;
if (json case {'parameters': var encodedParameters}) {
parameters = jsonDecoder.decodeList(
'$jsonPath.parameters',
encodedParameters,
(String jsonPath, Object? json) => RefactoringMethodParameter.fromJson(
jsonDecoder,
jsonPath,
json,
clientUriConverter: clientUriConverter,
),
);
} else {
throw jsonDecoder.mismatch(jsonPath, "'parameters'", json);
}
bool extractAll;
if (json case {'extractAll': var encodedExtractAll}) {
extractAll = jsonDecoder.decodeBool(
'$jsonPath.extractAll',
encodedExtractAll,
);
} else {
throw jsonDecoder.mismatch(jsonPath, "'extractAll'", json);
}
return ExtractMethodOptions(
returnType,
createGetter,
name,
parameters,
extractAll,
);
}