UNPKG

1.59 kBJavaScriptView Raw
1function AstNodeTypes() {
2
3}
4
5AstNodeTypes.LogicalExpression = "LogicalExpression";
6AstNodeTypes.BlockStatement = "BlockStatement";
7AstNodeTypes.SwitchStatement = "SwitchStatement";
8AstNodeTypes.IfStatement = "IfStatement";
9AstNodeTypes.ConditionalExpression = "ConditionalExpression";
10AstNodeTypes.StringLiteral = "StringLiteral";
11AstNodeTypes.Identifier = "Identifier";
12AstNodeTypes.AssignmentPattern = "AssignmentPattern";
13AstNodeTypes.DefaultArgument = "DefaultArgument";
14AstNodeTypes.FunctionExpression = "FunctionExpression";
15AstNodeTypes.FunctionDeclaration = "FunctionDeclaration";
16
17AstNodeTypes.isMethodNode = function (node) {
18 if (!node && !node.type)
19 return false;
20
21 return methodNodeTypes[node.type];
22}
23
24AstNodeTypes.isBranchNode = function (node) {
25 if (!node && !node.type)
26 return false;
27
28 return branchNodeTypes[node.type];
29}
30
31var branchNodeTypes = {
32 "IfStatement": true,
33 "SwitchStatement": true,
34 "ConditionalExpression": true,
35 "LogicalExpression": true
36};
37
38//TODO: Can we use 'CallExpression' in order to understend which functions are being called? (Nadav)
39//TODO: Do we need to handle: (Nadav)
40// * "MemberExpression"?
41// * "ClassPrivateMethod"
42// * "ClassProperty"
43// * "ClassPrivateProperty"
44
45// ObjectMethod is property function like "get", "set", "init". that uses in babylon. (in espirma its called Property).
46var methodNodeTypes = {
47 "FunctionDeclaration": true,
48 "FunctionExpression": true,
49 "ArrowFunctionExpression": true,
50 "ObjectMethod": true,
51 "ClassMethod": true
52}
53
54module.exports = AstNodeTypes;
\No newline at end of file