How to use the isTryStatement function from babel-types
Find comprehensive JavaScript babel-types.isTryStatement code examples handpicked from public code repositorys.
292 293 294 295 296 297 298 299 300 301
所以,我们的过滤条件是这样的: ```js // 1、如果有try catch包裹了,则不需要 2、防止loops 3、需要try catch的只能是语句,像() => 0这种的body,是不需要的 if (blockStatement.body && types.isTryStatement(blockStatement.body[0]) || !types.isBlockStatement(blockStatement) && !types.isExpressionStatement(blockStatement)) { return; } ```
6
14
2
+ 23 other calls in file
55 56 57 58 59 60 61 62 63 64
for (let i = 0; i < block.length; ++i) { if ( isTimePoint(block[i]) || (t.isIfStatement(block[i]) && block[i].name == 'emptyContinuation') || t.isDoWhileStatement(block[i]) || t.isTryStatement(block[i]) || t.isWhileStatement(block[i]) || t.isForStatement(block[i]) ) { splitPoints.push(i);
2
5
3
+ 7 other calls in file
GitHub: mrcoles/parcel
38 39 40 41 42 43 44 45 46
args.length === 1 && types.isStringLiteral(args[0]) && !hasBinding(ancestors, 'require'); if (isRequire) { let optional = ancestors.some(a => types.isTryStatement(a)) || undefined; addDependency(asset, args[0], {optional}); return; }
0
2
2
19 20 21 22 23 24 25 26 27 28
FunctionDeclaration(nodePath){ let {node}=nodePath; let {id} = node;//Person 标识符 let blockStatement = node.body; //如果此函数的第一个语句已经一个try语句了,就不要再处理了否则 会死循环 if(blockStatement.body && types.isTryStatement(blockStatement.body[0])){ return ; } //把一个JS字符串转成AST语法树节点 CallExpression let catchStatement = template.statement('console.log(error)')();
0
0
0
21 22 23 24 25 26 27 28 29 30
FunctionDeclaration(nodePath) { let { node } = nodePath; let { id } = node; let blockStatement = node.body; // 如果次函数的对个语句已经是一个try语句了,就不要再处理了,否则会死循环 if (blockStatement.body && types.isTryStatement(blockStatement.body[0])) { return; } // 把一个JS字符串转成一个AST节点
0
0
0
GitHub: free-dev-gf/fe_build
44 45 46 47 48 49 50 51 52 53
// 1、如果有try catch包裹了,则不需要 2、防止circle loops // 3、需要try catch的只能是语句,像() => 0这种的body,是不需要的 // 4、如果函数内容小于等于‘LIMIT_LINE’行不try catch,当然这个函数可以暴露出来给用户设置 if ( (blockStatement.body && types.isTryStatement(blockStatement.body[0])) || (!types.isBlockStatement(blockStatement) && !types.isExpressionStatement(blockStatement)) || (blockStatement.body && blockStatement.body.length <= LIMIT_LINE) ) {
0
0
0
babel-types.identifier is the most popular function in babel-types (4076 examples)