fromAst static method

VariableDeclarationList? fromAst(
  1. Map? ast
)

Implementation

static VariableDeclarationList? fromAst(Map? ast) {
  if (ast != null &&
      ast['type'] == astNodeNameValue(AstNodeName.VariableDeclarationList)) {
    var astDeclarations = ast['declarations'] as List;
    var declarations = <VariableDeclarator?>[];
    for (var arg in astDeclarations) {
      declarations.add(VariableDeclarator.fromAst(arg));
    }
    var astAnnotations = ast['annotations'] as List;
    var annotations = <Annotation?>[];
    for (var annotation in astAnnotations) {
      annotations.add(Annotation.fromAst(annotation));
    }

    return VariableDeclarationList(
        Identifier.fromAst(ast['typeAnnotation'])?.name,
        declarations,
        annotations,
        ast['source'],
        ast: ast);
  }
  return null;
}