Merge branch 'master' into tags
This commit is contained in:
commit
05c1d44e80
2 changed files with 31 additions and 1 deletions
|
|
@ -434,6 +434,36 @@ fn test_query_matches_with_named_wildcard() {
|
|||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_query_matches_with_wildcard_at_the_root() {
|
||||
allocations::record(|| {
|
||||
let language = get_language("javascript");
|
||||
let query = Query::new(
|
||||
language,
|
||||
"
|
||||
(*
|
||||
(comment) @doc
|
||||
.
|
||||
(function_declaration
|
||||
name: (identifier) @name))
|
||||
",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let source = "/* one */ var x; /* two */ function y() {} /* three */ class Z {}";
|
||||
|
||||
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![("doc", "/* two */"), ("name", "y")]),]
|
||||
);
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn test_query_with_immediate_siblings() {
|
||||
allocations::record(|| {
|
||||
|
|
|
|||
|
|
@ -698,7 +698,7 @@ static TSQueryError ts_query__parse_pattern(
|
|||
|
||||
// Parse the wildcard symbol
|
||||
if (stream->next == '*') {
|
||||
symbol = NAMED_WILDCARD_SYMBOL;
|
||||
symbol = depth > 0 ? NAMED_WILDCARD_SYMBOL : WILDCARD_SYMBOL;
|
||||
stream_advance(stream);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue