Add '.' as a valid start of a predicate, in addition to '#'
See https://github.com/ubolonton/emacs-tree-sitter/issues/38
This commit is contained in:
parent
82aa1462fd
commit
740d864e67
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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue