Skip to content

Commit

Permalink
Merge branch 'main' into test-visit
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing authored Jul 19, 2024
2 parents 062e3b3 + 6ffce86 commit 8a2971b
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 25 deletions.
11 changes: 8 additions & 3 deletions crates/oxc_semantic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1671,6 +1671,10 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.enter_node(kind);
self.enter_scope(ScopeFlags::Function | ScopeFlags::Arrow, &expr.scope_id);

if let Some(parameters) = &expr.type_parameters {
self.visit_ts_type_parameter_declaration(parameters);
}

self.visit_formal_parameters(&expr.params);

/* cfg */
Expand All @@ -1681,6 +1685,10 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
));
/* cfg */

if let Some(return_type) = &expr.return_type {
self.visit_ts_type_annotation(return_type);
}

self.visit_function_body(&expr.body);

/* cfg */
Expand All @@ -1692,9 +1700,6 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
});
/* cfg */

if let Some(parameters) = &expr.type_parameters {
self.visit_ts_type_parameter_declaration(parameters);
}
self.leave_node(kind);
self.leave_scope();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/functions/arrow
"id": 1,
"node": "ArrowFunctionExpression",
"symbols": [
{
"flag": "SymbolFlags(BlockScopedVariable)",
"id": 1,
"name": "x",
"node": "VariableDeclarator",
"references": []
},
{
"flag": "SymbolFlags(TypeParameter)",
"id": 2,
"id": 1,
"name": "T",
"node": "TSTypeParameter",
"references": [
{
"flag": "ReferenceFlag(Type)",
"id": 0,
"name": "T",
"node_id": 13
"node_id": 16
}
]
},
{
"flag": "SymbolFlags(BlockScopedVariable)",
"id": 2,
"name": "x",
"node": "VariableDeclarator",
"references": []
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,24 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/functions/arrow
"node": "ArrowFunctionExpression",
"symbols": [
{
"flag": "SymbolFlags(FunctionScopedVariable)",
"flag": "SymbolFlags(TypeParameter)",
"id": 1,
"name": "a",
"node": "FormalParameter",
"references": []
"name": "T",
"node": "TSTypeParameter",
"references": [
{
"flag": "ReferenceFlag(Type)",
"id": 0,
"name": "T",
"node_id": 14
}
]
},
{
"flag": "SymbolFlags(TypeParameter)",
"flag": "SymbolFlags(FunctionScopedVariable)",
"id": 2,
"name": "T",
"node": "TSTypeParameter",
"name": "a",
"node": "FormalParameter",
"references": []
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/functions/arrow
"id": 1,
"name": "T",
"node": "TSTypeParameter",
"references": []
"references": [
{
"flag": "ReferenceFlag(Type)",
"id": 0,
"name": "T",
"node_id": 12
}
]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/functions/arrow
"flag": "ReferenceFlag(Type)",
"id": 0,
"name": "T",
"node_id": 14
"node_id": 12
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/functions/arrow
"id": 0,
"name": "T",
"node": "TSTypeAliasDeclaration",
"references": []
"references": [
{
"flag": "ReferenceFlag(Type)",
"id": 0,
"name": "T",
"node_id": 18
}
]
},
{
"flag": "SymbolFlags(BlockScopedVariable | ConstVariable)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/functions/arrow
"flag": "ReferenceFlag(Read)",
"id": 0,
"name": "arg",
"node_id": 14
"node_id": 18
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/functions/arrow
"flag": "ReferenceFlag(Read)",
"id": 0,
"name": "arg",
"node_id": 17
"node_id": 23
}
]
}
Expand All @@ -44,7 +44,14 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/functions/arrow
"id": 0,
"name": "T",
"node": "TSTypeAliasDeclaration",
"references": []
"references": [
{
"flag": "ReferenceFlag(Type)",
"id": 0,
"name": "T",
"node_id": 18
}
]
},
{
"flag": "SymbolFlags(BlockScopedVariable | ConstVariable)",
Expand Down

0 comments on commit 8a2971b

Please sign in to comment.