Merge pull request #692 from ubolonton/query-dot-predicate
Add '.' as a valid start of a query predicate, in addition to '#'
This commit is contained in:
commit
1b8426bb65
2 changed files with 31 additions and 2 deletions
|
|
@ -2087,6 +2087,35 @@ fn test_query_disable_pattern() {
|
|||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_query_alternative_predicate_prefix() {
|
||||
allocations::record(|| {
|
||||
let language = get_language("c");
|
||||
let query = Query::new(language, r#"
|
||||
((call_expression
|
||||
function: (identifier) @keyword
|
||||
arguments: (argument_list
|
||||
(string_literal) @function))
|
||||
(.eq? @keyword "DEFUN"))
|
||||
"#).unwrap();
|
||||
let source = r#"
|
||||
DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0,
|
||||
doc: /* Return the argument unchanged. */
|
||||
attributes: const)
|
||||
(Lisp_Object arg)
|
||||
{
|
||||
return arg;
|
||||
}
|
||||
"#;
|
||||
assert_query_matches(
|
||||
language,
|
||||
&query,
|
||||
source,
|
||||
&[(0, vec![("keyword", "DEFUN"), ("function", "\"identity\"")])],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
fn assert_query_matches(
|
||||
language: Language,
|
||||
query: &Query,
|
||||
|
|
|
|||
|
|
@ -805,8 +805,8 @@ static TSQueryError ts_query__parse_pattern(
|
|||
}
|
||||
}
|
||||
|
||||
// A pound character indicates the start of a predicate.
|
||||
else if (stream->next == '#') {
|
||||
// A dot/pound character indicates the start of a predicate.
|
||||
else if (stream->next == '.' || stream->next == '#') {
|
||||
stream_advance(stream);
|
||||
return ts_query__parse_predicate(self, stream);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue