fromAst static method
Implementation
static Expression? fromAst(Map? ast) {
if (ast == null) return null;
var astType = ast['type'];
if (astType == astNodeNameValue(AstNodeName.Program)) {
return Expression(Program.fromAst(ast), isProgram: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.ExpressionStatement)) {
return Expression(Expression.fromAst(ast['expression']),
isExpressionStatement: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.Identifier)) {
return Expression(Identifier.fromAst(ast), isIdentifier: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.PrefixedIdentifier)) {
return Expression(PrefixedIdentifier.fromAst(ast),
isPrefixedIdentifier: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.StringLiteral)) {
return Expression(StringLiteral.fromAst(ast),
isStringLiteral: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.NumericLiteral)) {
return Expression(NumericLiteral.fromAst(ast),
isNumericLiteral: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.BooleanLiteral)) {
return Expression(BooleanLiteral.fromAst(ast),
isBooleanLiteral: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.ListLiteral)) {
return Expression(ListLiteral.fromAst(ast),
isListLiteral: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.SetOrMapLiteral)) {
return Expression(MapLiteral.fromAst(ast), isMapLiteral: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.MethodInvocation)) {
return Expression(MethodInvocation.fromAst(ast),
isMethodInvocation: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.MemberExpression)) {
return Expression(MemberExpression.fromAst(ast),
isMemberExpression: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.NamedExpression)) {
return Expression(NamedExpression.fromAst(ast),
isNamedExpression: true, ast: ast);
} else if (astType ==
astNodeNameValue(AstNodeName.VariableDeclarationList)) {
return Expression(VariableDeclarationList.fromAst(ast),
isVariableDeclarationList: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.BinaryExpression)) {
return Expression(BinaryExpression.fromAst(ast),
isBinaryExpression: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.AssignmentExpression)) {
return Expression(AssignmentExpression.fromAst(ast),
isAssignmentExpression: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.PropertyAccess)) {
return Expression(PropertyAccess.fromAst(ast),
isPropertyAccess: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.ClassDeclaration)) {
return Expression(ClassDeclaration.fromAst(ast),
isClassDeclaration: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.MethodDeclaration)) {
return Expression(MethodDeclaration.fromAst(ast),
isMethodDeclaration: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.ReturnStatement)) {
return Expression(ReturnStatement.fromAst(ast),
isReturnStatement: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.FieldDeclaration)) {
return Expression(FieldDeclaration.fromAst(ast),
isFieldDeclaration: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.FunctionExpression)) {
return Expression(FunctionExpression.fromAst(ast),
isFunctionExpression: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.BlockStatement)) {
return Expression(BlockStatement.fromAst(ast),
isBlockStatement: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.FunctionDeclaration)) {
return Expression(FunctionDeclaration.fromAst(ast),
isFunctionDeclaration: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.AwaitExpression)) {
return Expression(AwaitExpression.fromAst(ast),
isAwaitExpression: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.PrefixExpression)) {
return Expression(PrefixExpression.fromAst(ast),
isPrefixExpression: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.IfStatement)) {
return Expression(IfStatement.fromAst(ast),
isIfStatement: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.ForStatement)) {
return Expression(ForStatement.fromAst(ast),
isForStatement: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.SwitchStatement)) {
return Expression(SwitchStatement.fromAst(ast),
isSwitchStatement: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.IndexExpression)) {
return Expression(IndexExpression.fromAst(ast),
isIndexExpression: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.StringInterpolation)) {
return Expression(StringInterpolation.fromAst(ast),
isStringInterpolation: true, ast: ast);
} else if (astType ==
astNodeNameValue(AstNodeName.InterpolationExpression)) {
return Expression(InterpolationExpression.fromAst(ast),
isInterpolationExpression: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.VariableExpression)) {
return Expression(VariableExpression.fromAst(ast), isVariableExpression: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.TypeName)) {
return Expression(TypeName.fromAst(ast), isTypeName: true, ast: ast);
}
return null;
}