query: Fix handling of alternations under field names (#661)
This commit is contained in:
parent
bfeec63d60
commit
deeeb67a3b
2 changed files with 56 additions and 6 deletions
|
|
@ -1008,6 +1008,41 @@ fn test_query_matches_with_alternatives_at_root() {
|
|||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_query_matches_with_alternatives_under_fields() {
|
||||
allocations::record(|| {
|
||||
let language = get_language("javascript");
|
||||
let query = Query::new(
|
||||
language,
|
||||
r#"
|
||||
(assignment_expression
|
||||
left: [
|
||||
(identifier) @variable
|
||||
(member_expression property: (property_identifier) @variable)
|
||||
])
|
||||
"#,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_query_matches(
|
||||
language,
|
||||
&query,
|
||||
"
|
||||
a = b;
|
||||
b = c.d;
|
||||
e.f = g;
|
||||
h.i = j.k;
|
||||
",
|
||||
&[
|
||||
(0, vec![("variable", "a")]),
|
||||
(0, vec![("variable", "b")]),
|
||||
(0, vec![("variable", "f")]),
|
||||
(0, vec![("variable", "i")]),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_query_matches_in_language_with_simple_aliases() {
|
||||
allocations::record(|| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue