Merge pull request #2107 from Philipp-M/fix-group-first-child
Fix bug with first child group anchor (anchor had no effect)
This commit is contained in:
commit
91e4d94016
2 changed files with 27 additions and 1 deletions
|
|
@ -6,7 +6,9 @@
|
|||
// cargo test --target $(rustc -vV | sed -nr 's/^host: //p') -- --test-threads 1
|
||||
// ```
|
||||
|
||||
use super::helpers::query_helpers::assert_query_matches;
|
||||
use crate::tests::helpers::fixtures::get_language;
|
||||
use indoc::indoc;
|
||||
use tree_sitter::Query;
|
||||
|
||||
#[test]
|
||||
|
|
@ -14,3 +16,27 @@ fn issue_2162_out_of_bound() {
|
|||
let language = get_language("java");
|
||||
assert!(Query::new(language, "(package_declaration _ (_) @name _)").is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_2107_first_child_group_anchor_had_no_effect() {
|
||||
let language = get_language("c");
|
||||
let source_code = indoc! {r#"
|
||||
void fun(int a, char b, int c) { };
|
||||
"#};
|
||||
let query = indoc! {r#"
|
||||
(parameter_list
|
||||
.
|
||||
(
|
||||
(parameter_declaration) @constant
|
||||
(#match? @constant "^int")
|
||||
)
|
||||
)
|
||||
"#};
|
||||
let query = Query::new(language, query).unwrap();
|
||||
assert_query_matches(
|
||||
language,
|
||||
&query,
|
||||
source_code,
|
||||
&[(0, vec![("constant", "int a")])],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2260,7 +2260,7 @@ static TSQueryError ts_query__parse_pattern(
|
|||
|
||||
// If this parenthesis is followed by a node, then it represents a grouped sequence.
|
||||
if (stream->next == '(' || stream->next == '"' || stream->next == '[') {
|
||||
bool child_is_immediate = false;
|
||||
bool child_is_immediate = is_immediate;
|
||||
CaptureQuantifiers child_capture_quantifiers = capture_quantifiers_new();
|
||||
for (;;) {
|
||||
if (stream->next == '.') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue