fromAst static method
Implementation
static MethodDeclaration? fromAst(Map? ast) {
if (ast != null &&
ast['type'] == astNodeNameValue(AstNodeName.MethodDeclaration)) {
var parameters = <SimpleFormalParameter?>[];
if (ast['parameters'] != null &&
ast['parameters']['parameterList'] != null) {
var astParameters = ast['parameters']['parameterList'] as List;
for (var arg in astParameters) {
parameters.add(SimpleFormalParameter.fromAst(arg));
}
}
var astAnnotations = ast['annotations'] as List;
var annotations = <Annotation?>[];
for (var ann in astAnnotations) {
annotations.add(Annotation.fromAst(ann));
}
var name = Identifier.fromAst(ast['id'])?.name;
FairLogicUnit().addFunction(name);
return MethodDeclaration(
name,
parameters,
BlockStatement.fromAst(ast['body']),
annotations,
TypeName.fromAst(ast['returnType']),
ast['source'],
isAsync: ast['isAsync'] as bool,
ast: ast);
}
return null;
}