Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// catch block to the fall-through location.
self.jump(after);
}
self.updateContextPrevLoc(self.mark(catchLoc));
var bodyPath = path.get("handler", "body");
var safeParam = self.makeTempVar();
self.clearPendingException(tryEntry.firstLoc, safeParam);
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;
}
this.traverse(path);
},
visitFunction: function(path) {
if (path.scope.declares(catchParamName)) {
// Don't descend into nested scopes that shadow the catch
// parameter with their own declarations. This isn't
// logically necessary because of the path.scope.lookup we
// do in visitIdentifier, but it saves time.
return false;
// catch block to the fall-through location.
self.jump(after);
}
self.updateContextPrevLoc(self.mark(catchLoc));
var bodyPath = path.get("handler", "body");
var safeParam = self.makeTempVar();
self.clearPendingException(tryEntry.firstLoc, safeParam);
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;
}
this.traverse(path);
},
visitFunction: function(path) {
if (path.scope.declares(catchParamName)) {
// Don't descend into nested scopes that shadow the catch
// parameter with their own declarations. This isn't
// logically necessary because of the path.scope.lookup we
// do in visitIdentifier, but it saves time.
return false;
));
} else if (includeIdentifiers) {
exprs.push(dec.id);
}
});
if (exprs.length === 0)
return null;
if (exprs.length === 1)
return exprs[0];
return b.sequenceExpression(exprs);
}
types.visit(funPath.get("body"), {
visitVariableDeclaration: function(path) {
var expr = varDeclToExpr(path.value, false);
if (expr === null) {
path.replace();
} else {
// We don't need to traverse this expression any further because
// there can't be any new declarations inside an expression.
return b.expressionStatement(expr);
}
// Since the original node has been either removed or replaced,
// avoid traversing it any further.
return false;
},
visitForStatement: function(path) {
const findModuleFromImport = (path: any) => {
const name = path.node.source && path.node.source.value;
if (name) {
const version = getVersionFromComments(path.node.trailingComments);
if (removeVersionComments) {
removeCommentFromPath(path);
}
dependencies[name] = version;
}
};
types.visit(ast, {
visitImportDeclaration(path) {
findModuleFromImport(path);
this.traverse(path);
},
visitExportNamedDeclaration(path) {
findModuleFromImport(path);
this.traverse(path);
},
visitExportAllDeclaration(path) {
findModuleFromImport(path);
this.traverse(path);
},
visitCallExpression(path) {
const findModuleFromImport = (path: *) => {
const name = path.node.source && path.node.source.value;
if (name) {
const version = getVersionFromComments(path.node.trailingComments);
if (removeVersionComments) {
removeCommentFromPath(path);
}
dependencies[name] = version;
}
};
types.visit(ast, {
visitImportDeclaration(path) {
findModuleFromImport(path);
this.traverse(path);
},
visitExportNamedDeclaration(path) {
findModuleFromImport(path);
this.traverse(path);
},
visitExportAllDeclaration(path) {
findModuleFromImport(path);
this.traverse(path);
},
visitCallExpression(path) {