File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
main/java/io/github/treesitter/jtreesitter
test/java/io/github/treesitter/jtreesitter Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -77,9 +77,9 @@ boolean test(QueryMatch match) {
7777
7878 private boolean testCapture (QueryMatch match ) {
7979 var findNodes1 = match .findNodes (capture ).stream ();
80- var findNodes2 = match .findNodes (value ). stream () ;
80+ var findNodes2 = match .findNodes (value );
8181 Predicate <Node > predicate =
82- n1 -> findNodes2 .anyMatch (n2 -> Objects .equals (n1 .getText (), n2 .getText ()) == isPositive );
82+ n1 -> findNodes2 .stream (). anyMatch (n2 -> Objects .equals (n1 .getText (), n2 .getText ()) == isPositive );
8383 return isAny ? findNodes1 .anyMatch (predicate ) : findNodes1 .allMatch (predicate );
8484 }
8585
Original file line number Diff line number Diff line change @@ -175,5 +175,21 @@ void findMatches() {
175175 assertEquals (Short .MAX_VALUE + 1 , matches .getFirst ().captures ().size ());
176176 });
177177 }
178+
179+ // Verify that `eq?` predicate works with quantified captures
180+ try (var tree = parser .parse ("/* 1 */ /* 1 */ /* 1 */" ).orElseThrow ()) {
181+ var source = """
182+ (program
183+ . (block_comment) @b (block_comment)+ @a
184+ (#eq? @a @b)
185+ )
186+ """ ;
187+ assertCursor (source , cursor -> {
188+ var matches = cursor .findMatches (tree .getRootNode ()).toList ();
189+ assertEquals (1 , matches .size ());
190+ assertEquals (
191+ "/* 1 */" , matches .getFirst ().captures ().getFirst ().node ().getText ());
192+ });
193+ }
178194 }
179195}
You can’t perform that action at this time.
0 commit comments