Skip to content

Commit 85837e9

Browse files
yancyaclaude
andcommitted
fix: Remove duplicate method definitions in QueryCursor to eliminate warnings
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3c3ef84 commit 85837e9

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

ext/tree_sitter/query_cursor.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,21 +204,16 @@ void init_query_cursor(void) {
204204

205205
rb_define_alloc_func(cQueryCursor, query_cursor_allocate);
206206

207-
/* Module methods */
208-
rb_define_module_function(cQueryCursor, "exec", query_cursor_exec_static, 2);
209-
210207
/* Class methods */
208+
rb_define_singleton_method(cQueryCursor, "exec", query_cursor_exec_static, 2);
209+
211210
// Accessors
212211
DECLARE_ACCESSOR(cQueryCursor, query_cursor, match_limit)
213212

214213
// Other
215214
rb_define_method(cQueryCursor, "exec", query_cursor_exec, 2);
216215
rb_define_method(cQueryCursor, "exceed_match_limit?",
217216
query_cursor_did_exceed_match_limit, 0);
218-
rb_define_method(cQueryCursor, "match_limit", query_cursor_get_match_limit,
219-
0);
220-
rb_define_method(cQueryCursor, "match_limit=", query_cursor_set_match_limit,
221-
1);
222217
rb_define_method(cQueryCursor,
223218
"max_start_depth=", query_cursor_set_max_start_depth, 1);
224219
rb_define_method(cQueryCursor, "next_capture", query_cursor_next_capture, 0);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../test_helper'
4+
5+
describe 'QueryCursor' do
6+
it 'must not emit redefined warnings when loading the extension' do
7+
lib_path = File.expand_path('../../lib', __dir__)
8+
output = IO.popen(
9+
[RbConfig.ruby, '-W', '-I', lib_path, '-e', "require 'tree_sitter'"],
10+
err: %i[child out],
11+
&:read
12+
)
13+
refute_match(/redefined/, output,
14+
"Loading tree_sitter should not produce 'redefined' warnings:\n#{output}")
15+
end
16+
end

0 commit comments

Comments
 (0)