How to use the visit function from recast
Find comprehensive JavaScript recast.visit code examples handpicked from public code repositorys.
106 107 108 109 110 111 112 113 114
definition = resolveDefinition(definitions[0]); return false; }; recast.visit(ast, { visitExportDeclaration: exportDeclaration, visitExportNamedDeclaration: exportDeclaration, visitExportDefaultDeclaration: exportDeclaration,
2
11
0
+ 3 other calls in file
168 169 170 171 172 173 174 175 176
visitProjectTrees: function(trees, options) { // console.log('options: ',options) return trees.map(function(tree) { var hasSourceRef = false; recast.visit(tree, { /* visitNode: function(path) { var node = path.node;
1
7
1
+ 29 other calls in file
19 20 21 22 23 24 25 26 27 28
parser: require("recast/parsers/babylon") }); const b = recast.types.builders; recast.visit(ast.program.body, { visitExportNamedDeclaration(path) { const node = path.node if (node.exportKind !== 'value') {
0
2
0
31 32 33 34 35 36 37 38 39 40 41 42
return nodePath.traverse(); } } function transform(ast) { var visitedAst = recast.visit(ast, visitors); return visitedAst; } module.exports = {
0
2
0
+ 3 other calls in file
57 58 59 60 61 62 63 64 65 66
} else { body = b.blockStatement([body, toInsert]); loop.body = body; } recast.visit(body, { visitContinueStatement: function(path) { var cst = path.node; assert.equal(
0
1
0
44 45 46 47 48 49 50 51 52 53 54
var getComponentAstData = function getComponentAstData(component, properties) { var source = component.prototype.constructor.toString(); var data = {}; var lastProperty; recast.visit(recast.parse(source), { visitAssignmentExpression: function visitAssignmentExpression(_ref) { var value = _ref.value; var left = value.left, right = value.right;
0
0
2
+ 33 other calls in file
GitHub: saagaar/uptrendly
729 730 731 732 733 734 735 736 737 738
var catchScope = bodyPath.scope; var catchParamName = handler.param.name; n.CatchClause.assert(catchScope.node); assert.strictEqual(catchScope.lookup(catchParamName), catchScope); types.visit(bodyPath, { visitIdentifier: function(path) { if (util.isReference(path, catchParamName) && path.scope.lookup(catchParamName) === catchScope) { return safeParam;
0
0
1
+ 4 other calls in file
GitHub: saagaar/uptrendly
336 337 338 339 340 341 342 343 344 345 346
function renameArguments(funcPath, argsId) { assert.ok(funcPath instanceof types.NodePath); var func = funcPath.value; var didRenameArguments = false; recast.visit(funcPath, { visitFunction: function(path) { if (path.value === func) { this.traverse(path); } else {
0
0
0
+ 3 other calls in file
8 9 10 11 12 13 14 15 16 17 18
// TNT判断ast的数据类型 const TNT = recast.types.namedTypes recast.run(function(ast,printSource){ //printSource(ast) recast.visit(ast,{ /** * @visiFunctionDelaration 遍历函数声明 * @visitExpressionStatement 遍历赋值表达式 * */
0
0
0
recast.parse is the most popular function in recast (1784 examples)