Fix parsing of queries that start with repetitions followed by alternatives
This commit is contained in:
parent
6526efc5f5
commit
40f7b2ec97
2 changed files with 79 additions and 7 deletions
|
|
@ -1826,6 +1826,53 @@ fn test_query_matches_with_alternatives_and_too_many_permutations_to_track() {
|
|||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_repetitions_before_with_alternatives() {
|
||||
allocations::record(|| {
|
||||
let language = get_language("rust");
|
||||
let query = Query::new(
|
||||
language,
|
||||
r#"
|
||||
(
|
||||
(line_comment)* @comment
|
||||
.
|
||||
[
|
||||
(struct_item name: (_) @name)
|
||||
(function_item name: (_) @name)
|
||||
(enum_item name: (_) @name)
|
||||
(impl_item type: (_) @name)
|
||||
]
|
||||
)
|
||||
"#,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_query_matches(
|
||||
language,
|
||||
&query,
|
||||
r#"
|
||||
// a
|
||||
// b
|
||||
fn c() {}
|
||||
|
||||
// d
|
||||
// e
|
||||
impl F {}
|
||||
"#,
|
||||
&[
|
||||
(
|
||||
0,
|
||||
vec![("comment", "// a"), ("comment", "// b"), ("name", "c")],
|
||||
),
|
||||
(
|
||||
0,
|
||||
vec![("comment", "// d"), ("comment", "// e"), ("name", "F")],
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_query_matches_with_anonymous_tokens() {
|
||||
allocations::record(|| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue