File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,19 @@ pub(crate) fn convert_span(span: Span) -> Range<u32> {
4141 span. lo . 0 ..span. hi . 0
4242}
4343
44+ /// The ScopeCollector is responsible for collection function scopes and computing their names.
45+ ///
46+ /// SWCs AST is based around the Visitor pattern. In this case our visitor has some
47+ /// method that act on different function-like AST nodes that we are interested in.
48+ /// From there, the node either has a name itself, or we infer its name from the
49+ /// "path" of parents.
50+ /// As a concrete example:
51+ /// `const name = () => {};`
52+ /// 1. The visitors `visit_arrow_expr` function is invoked for the arrow function
53+ /// on the right hand side. Arrow functions by definition do not have a name.
54+ /// 2. We use the "path" to walk up to the VariableDeclarator.
55+ /// 3. That declarator has a binding pattern on the left hand side, which we use
56+ /// to infer the `name` for the anonymous arrow function expression.
4457struct ScopeCollector {
4558 scopes : Scopes ,
4659}
You can’t perform that action at this time.
0 commit comments