Skip to content

Commit 736637b

Browse files
Yutian Songfacebook-github-bot
Yutian Song
authored andcommitted
starlark find call by name support dot expression
Summary: We find the case when the target rule name with dot, the find call by name will not work this is because the the dotted name rule is wrapped with Dot expression not Identifier: ``` utils.func.infra_elaborated_model( name = "run_fb_inf_ccp_ss_dv_ax45mp_stub_vcs", top = "ccp_ax45mp_stub", ) ``` => ``` Dot( Spanned { node: Dot( Spanned { node: Identifier(Spanned { node: IdentP { ident: "utils", payload: () }, span: Span { begin: Pos(464), end: Pos(469) } }), span: Span { begin: Pos(464), end: Pos(469) } }, Spanned { node: "func", span: Span { begin: Pos(470), end: Pos(474) } }), span: Span { begin: Pos(464), end: Pos(474) } }, Spanned { node: "infra_elaborated_model", span: Span { begin: Pos(475), end: Pos(497) } } ) ``` Reviewed By: JakobDegen Differential Revision: D72725012 fbshipit-source-id: 9dfafc98edfa45214279cfdc370aeec57ba4cd56
1 parent feeeed7 commit 736637b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

starlark/src/analysis/find_call_name.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl AstModuleFindCallName for AstModule {
5151
node: Expr::Call(identifier, arguments),
5252
..
5353
} => {
54-
if let Expr::Identifier(_) = &identifier.node {
54+
if matches!(&identifier.node, Expr::Identifier(_) | Expr::Dot(_, _)) {
5555
let found =
5656
arguments
5757
.args
@@ -100,6 +100,8 @@ foo(name = "foo_name")
100100
bar("bar_name")
101101
baz(name = "baz_name")
102102
103+
utils.foo(name = "dot_name")
104+
103105
def x(name = "foo_name"):
104106
pass
105107
"#;
@@ -121,6 +123,15 @@ def x(name = "foo_name"):
121123
.map(|span| module.codemap().resolve_span(span))
122124
);
123125
assert_eq!(None, module.find_function_call_with_name("bar_name"));
126+
assert_eq!(
127+
Some(ResolvedSpan {
128+
begin: ResolvedPos { line: 5, column: 0 },
129+
end: ResolvedPos { line: 5, column: 9 }
130+
}),
131+
module
132+
.find_function_call_with_name("dot_name")
133+
.map(|span| module.codemap().resolve_span(span))
134+
);
124135
Ok(())
125136
}
126137
}

0 commit comments

Comments
 (0)