buildNode method
Implementation
ASTNode buildNode(var node) {
String type = (node is Map) ? node['type'] : node.toString();
if (type == 'ExpressionStatement') {
return ExpressionStatement.fromJson(node, this);
} else if (type == 'AssignmentExpression') {
return AssignmentExpression.fromJson(node, this);
} else if (type == 'MemberExpression') {
return MemberExpr.fromJson(node, this);
} else if (type == 'IfStatement') {
return IfStatement.fromJson(node, this);
} else if (type == 'ConditionalExpression') {
return ConditionalExpression.fromJson(node, this);
} else if (type == 'Literal') {
return Literal.fromJson(node, this);
} else if (type == 'Identifier') {
return Identifier.fromJson(node, this);
} else if (type == 'BlockStatement') {
return BlockStatement.fromJson(node, this);
} else if (type == 'BinaryExpression') {
return BinaryExpression.fromJson(node, this);
} else if (type == 'LogicalExpression') {
return LogicalExpression.fromJson(node, this);
} else if (type == 'CallExpression') {
return CallExpression.fromJson(node, this);
} else if (type == 'UnaryExpression') {
return UnaryExpression.fromJson(node, this);
} else if (type == 'ThisExpression') {
return ThisExpr.fromJson(node, this);
} else if (type == 'ArrayExpression') {
return ArrayExpression.fromJson(node, this);
} else if (type == 'ArrowFunctionExpression') {
return ArrowFunctionExpression.fromJson(node, this);
} else if (type == 'VariableDeclaration') {
return VariableDeclaration.fromJson(node, this);
} else if (type == 'VariableDeclarator') {
return VariableDeclarator.fromJson(node, this);
} else if (type == 'ObjectExpression') {
return ObjectExpr.fromJson(node, this);
} else if (type == 'Property') {
return Property.fromJson(node, this);
} else if (type == 'ReturnStatement') {
return ReturnStatement.fromJson(node, this);
}
throw Exception(
type + " is not yet supported. Full expression is=" + node.toString());
}