UNPKG

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