query: Differentiate between wildcard '*' and named wildcard '(*)'
This commit is contained in:
parent
1d6ea51b63
commit
950a89a525
2 changed files with 36 additions and 2 deletions
|
|
@ -402,6 +402,38 @@ fn test_query_matches_capturing_error_nodes() {
|
|||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_query_matches_with_named_wildcard() {
|
||||
allocations::record(|| {
|
||||
let language = get_language("javascript");
|
||||
let query = Query::new(
|
||||
language,
|
||||
"
|
||||
(return_statement (*) @the-return-value)
|
||||
(binary_expression operator: * @the-operator)
|
||||
",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let source = "return a + b - c;";
|
||||
|
||||
let mut parser = Parser::new();
|
||||
parser.set_language(language).unwrap();
|
||||
let tree = parser.parse(source, None).unwrap();
|
||||
let mut cursor = QueryCursor::new();
|
||||
let matches = cursor.matches(&query, tree.root_node(), to_callback(source));
|
||||
|
||||
assert_eq!(
|
||||
collect_matches(matches, &query, source),
|
||||
&[
|
||||
(0, vec![("the-return-value", "a + b - c")]),
|
||||
(1, vec![("the-operator", "+")]),
|
||||
(1, vec![("the-operator", "-")]),
|
||||
]
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_query_matches_in_language_with_simple_aliases() {
|
||||
allocations::record(|| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue