types: add more tests for optional paranthesis

This commit is contained in:
Sebastian McKenzie 2014-10-31 21:22:03 +11:00
parent 5c5348537d
commit 622bb2e962

View File

@ -13,7 +13,6 @@ exports.aliases = {
FunctionExpression: ["Function"]
};
exports.isUnaryLike = function (node) {
return _.contains(exports.UNARY_TYPES, node.type);
};
@ -166,17 +165,23 @@ exports.needsParans = function (node, parent) {
}
}
if (node.type === "FunctionExpression" && parent.type === "CallExpression" && parent.callee === node) {
if (node.type === "FunctionExpression") {
if (parent.type === "MemberExpression" && parent.object === node) {
return true;
}
if (parent.type === "CallExpression" && parent.callee === node) {
return true;
}
}
if (node.type === "ObjectPattern" && parent.type === "AssignmentExpression") {
return true;
}
return false;
};
exports.canBeFirstInStatement = function (node) {
return node.type !== "FunctionExpression" && node.type !== "ObjectExpression";
};
var PRECEDENCE = {};
_.each([