fix es6 visitor keys

This commit is contained in:
Sebastian McKenzie
2014-10-09 18:56:24 +11:00
parent 03a84a7de1
commit e7ef64a5ad
6 changed files with 126 additions and 72 deletions

View File

@@ -92,12 +92,14 @@ var buildNode = function (node) {
nodes.push(b.variableDeclaration("var", declars));
return node.declarations.map(function (declar) {
return _.compact(node.declarations.map(function (declar) {
if (!declar.init) return;
return util.template("assign", {
VALUE: declar.init,
KEY: declar.id
}, true);
});
}));
} else if (node.type === "ForInStatement" && node.left.type === "VariableDeclaration" && !node.left._ignoreBlockBindingHoist) {
var id = node.left.declarations[0].id;
node.left = id;

View File

@@ -22,7 +22,7 @@ var getMemberExpressionObject = function (node) {
var buildClass = function (node) {
var superName = node.superClass;
var className = node.id;
var className = node.id || b.identifier("Anonymous");
var superClassReference = node.superClass;

View File

@@ -1,46 +1,75 @@
{
"AssignmentExpression": ["left", "right"],
"ArrayExpression": ["elements"],
"ArrayPattern": ["elements"],
"ArrowFunctionExpression": ["params", "defaults", "rest", "body"],
"BlockStatement": ["body"],
"BinaryExpression": ["left", "right"],
"BreakStatement": ["label"],
"CallExpression": ["callee", "arguments"],
"CatchClause": ["param", "body"],
"ClassBody": ["body"],
"ClassDeclaration": ["id", "body", "superClass"],
"ClassExpression": ["id", "body", "superClass"],
"ConditionalExpression": ["test", "consequent", "alternate"],
"ContinueStatement": ["label"],
"DoWhileStatement": ["body", "test"],
"ExpressionStatement": ["expression"],
"ForStatement": ["init", "test", "update", "body"],
"ForInStatement": ["left", "right", "body"],
"ForOfStatement": ["left", "right", "body"],
"FunctionDeclaration": ["id", "params", "defaults", "rest", "body"],
"FunctionExpression": ["id", "params", "defaults", "rest", "body"],
"IfStatement": ["test", "consequent", "alternate"],
"LabeledStatement": ["label", "body"],
"LogicalExpression": ["left", "right"],
"MemberExpression": ["object", "property"],
"MethodDefinition": ["key", "value"],
"NewExpression": ["callee", "arguments"],
"ObjectExpression": ["properties"],
"ObjectPattern": ["properties"],
"Program": ["body"],
"Property": ["key", "value"],
"ReturnStatement": ["argument"],
"SequenceExpression": ["expressions"],
"SwitchStatement": ["discriminant", "cases"],
"SwitchCase": ["test", "consequent"],
"ThrowStatement": ["argument"],
"TryStatement": ["block", "handlers", "handler", "guardedHandlers", "finalizer"],
"UnaryExpression": ["argument"],
"UpdateExpression": ["argument"],
"VariableDeclaration": ["declarations"],
"VariableDeclarator": ["id", "init"],
"WhileStatement": ["test", "body"],
"WithStatement": ["object", "body"],
"YieldExpression": ["argument"]
"ArrayExpression": ["elements"],
"ArrayPattern": ["elements"],
"ArrowFunctionExpression": ["params", "defaults", "rest", "body"],
"AssignmentExpression": ["left", "right"],
"BinaryExpression": ["left", "right"],
"BlockStatement": ["body"],
"BreakStatement": ["label"],
"CallExpression": ["callee", "arguments"],
"CatchClause": ["param", "body"],
"ClassBody": ["body"],
"ClassDeclaration": ["id", "body", "superClass"],
"ClassExpression": ["id", "body", "superClass"],
"ClassProperty": ["key", "value"],
"ComprehensionBlock": ["left", "right", "body"],
"ComprehensionExpression": ["filter", "blocks", "body"],
"ConditionalExpression": ["test", "consequent", "alternate"],
"ContinueStatement": ["label"],
"DebuggerStatement": [],
"DoWhileStatement": ["body", "test"],
"EmptyStatement": [],
"ExportDeclaration": ["declaration", "specifiers", "source"],
"ExportBatchSpecifier": [],
"ExportSpecifier": ["id", "name"],
"ExpressionStatement": ["expression"],
"ForInStatement": ["left", "right", "body"],
"ForOfStatement": ["left", "right", "body"],
"ForStatement": ["init", "test", "update", "body"],
"FunctionDeclaration": ["id", "params", "defaults", "rest", "body"],
"FunctionExpression": ["id", "params", "defaults", "rest", "body"],
"Identifier": [],
"IfStatement": ["test", "consequent", "alternate"],
"ImportDeclaration": ["specifiers", "source"],
"ImportDefaultSpecifier": ["id"],
"ImportNamespaceSpecifier": ["id"],
"ImportSpecifier": ["id", "name"],
"LabeledStatement": ["label", "body"],
"Literal": [],
"LogicalExpression": ["left", "right"],
"MemberExpression": ["object", "property"],
"MethodDefinition": ["key", "value"],
"ModuleSpecifier": [],
"NewExpression": ["callee", "arguments"],
"ObjectExpression": ["properties"],
"ObjectPattern": ["properties"],
"ObjectTypeAnnotation": ["properties"],
"OptionalParameter": ["id"],
"ParametricTypeAnnotation": ["params"],
"ParametricallyTypedIdentifier": [],
"Program": ["body"],
"Property": ["key", "value"],
"ReturnStatement": ["argument"],
"SequenceExpression": ["expressions"],
"SpreadElement": ["argument"],
"SpreadProperty": ["argument"],
"SwitchCase": ["test", "consequent"],
"SwitchStatement": ["discriminant", "cases"],
"TaggedTemplateExpression": ["tag", "quasi"],
"TemplateElement": [],
"TemplateLiteral": ["quasis", "expressions"],
"ThisExpression": [],
"ThrowStatement": ["argument"],
"TryStatement": ["block", "handlers", "handler", "guardedHandlers", "finalizer"],
"TypeAnnotatedIdentifier": ["id", "annotation"],
"TypeAnnotation": ["id", "params", "returnType", "parametricType"],
"UnaryExpression": ["argument"],
"UpdateExpression": ["argument"],
"VariableDeclaration": ["declarations"],
"VariableDeclarator": ["id", "init"],
"VoidTypeAnnotation": [],
"WhileStatement": ["test", "body"],
"WithStatement": ["object", "body"],
"YieldExpression": ["argument"],
"AwaitExpression": ["argument"]
}