sanex3339 9 سال پیش
والد
کامیت
c6961d6417
2فایلهای تغییر یافته به همراه4 افزوده شده و 12 حذف شده
  1. 1 4
      src/NodeUtils.js
  2. 3 8
      src/NodeUtils.ts

+ 1 - 4
src/NodeUtils.js

@@ -48,10 +48,7 @@ class NodeUtils {
         return node.type === NodeType_1.NodeType.MemberExpression;
     }
     static isNodeHasBlockScope(node) {
-        return (node.type === NodeType_1.NodeType.BlockStatement ||
-            node.type === NodeType_1.NodeType.CatchClause ||
-            node.type === NodeType_1.NodeType.FunctionExpression ||
-            node.type === NodeType_1.NodeType.Program) && node.hasOwnProperty('body');
+        return node.hasOwnProperty('body');
     }
     static isProgramNode(node) {
         return node.type === NodeType_1.NodeType.Program;

+ 3 - 8
src/NodeUtils.ts

@@ -1,4 +1,6 @@
 import { IBlockStatementNode } from "./interfaces/nodes/IBlockStatementNode";
+import { ICatchClauseNode } from "./interfaces/nodes/ICatchClauseNode";
+import { IFunctionNode } from "./interfaces/nodes/IFunctionNode";
 import { IIdentifierNode } from "./interfaces/nodes/IIdentifierNode";
 import { ILiteralNode } from "./interfaces/nodes/ILiteralNode";
 import { IMemberExpressionNode } from "./interfaces/nodes/IMemberExpressionNode";
@@ -10,8 +12,6 @@ import { IVariableDeclaratorNode } from "./interfaces/nodes/IVariableDeclaratorN
 import { NodeType } from "./enums/NodeType";
 
 import { Utils } from "./Utils";
-import {ICatchClauseNode} from "./interfaces/nodes/ICatchClauseNode";
-import {IFunctionNode} from "./interfaces/nodes/IFunctionNode";
 
 export class NodeUtils {
     /**
@@ -129,12 +129,7 @@ export class NodeUtils {
     public static isNodeHasBlockScope (
         node: ITreeNode
     ): node is IBlockStatementNode|ICatchClauseNode|IFunctionNode|IProgramNode {
-        return (
-            node.type === NodeType.BlockStatement ||
-            node.type === NodeType.CatchClause ||
-            node.type === NodeType.FunctionExpression ||
-            node.type === NodeType.Program
-        ) && node.hasOwnProperty('body');
+        return node.hasOwnProperty('body');
     }
 
     /**