rubydex 0.1.0.beta7-x86_64-linux → 0.1.0.beta9-x86_64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/rubydex/declaration.c +42 -0
- data/ext/rubydex/declaration.h +1 -0
- data/ext/rubydex/graph.c +2 -27
- data/ext/rubydex/utils.c +24 -0
- data/ext/rubydex/utils.h +6 -0
- data/lib/rubydex/3.2/rubydex.so +0 -0
- data/lib/rubydex/3.3/rubydex.so +0 -0
- data/lib/rubydex/3.4/rubydex.so +0 -0
- data/lib/rubydex/4.0/rubydex.so +0 -0
- data/lib/rubydex/librubydex_sys.so +0 -0
- data/lib/rubydex/version.rb +1 -1
- data/rbi/rubydex.rbi +227 -196
- data/rust/Cargo.toml +5 -0
- data/rust/rubydex/src/indexing/local_graph.rs +35 -0
- data/rust/rubydex/src/indexing/rbs_indexer.rs +240 -19
- data/rust/rubydex/src/indexing/ruby_indexer.rs +510 -124
- data/rust/rubydex/src/indexing.rs +6 -1
- data/rust/rubydex/src/job_queue.rs +23 -4
- data/rust/rubydex/src/model/declaration.rs +6 -1
- data/rust/rubydex/src/model/definitions.rs +83 -45
- data/rust/rubydex/src/model/graph.rs +146 -20
- data/rust/rubydex/src/query.rs +7 -5
- data/rust/rubydex/src/resolution.rs +681 -69
- data/rust/rubydex/src/test_utils/graph_test.rs +80 -1
- data/rust/rubydex/src/test_utils/local_graph_test.rs +156 -1
- data/rust/rubydex-mcp/src/server.rs +675 -74
- data/rust/rubydex-mcp/src/tools.rs +9 -1
- data/rust/rubydex-mcp/tests/mcp.rs +7 -4
- data/rust/rubydex-sys/src/declaration_api.rs +49 -7
- data/rust/rubydex-sys/src/graph_api.rs +3 -3
- data/rust/rubydex-sys/src/reference_api.rs +22 -18
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: edf2302fdc66d1c0e0560a3f59af9fb2acae9269b3db80dea4a70a70b7b6e0b4
|
|
4
|
+
data.tar.gz: 541747276861c81cb5d4339a9961a8d1b6ab1f58dc6f85f9f1ef0fb00b429449
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aa0cad72232ba1e55b22aac62c28cd294f06cff2a51ed6583ba8f25974f957adbfd20929266cd112d08b00aa637270d53527584d93fb785fb3be90733c5c62c4
|
|
7
|
+
data.tar.gz: 5521008248d353fc0779882e914d4b50fe882dcc614731298e99ecaff0b88a48aff3e3e0a19e6c7dc661cfac30cbf78e512bd34c3879de713b9cad67bd1305b5
|
data/ext/rubydex/declaration.c
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#include "definition.h"
|
|
3
3
|
#include "graph.h"
|
|
4
4
|
#include "handle.h"
|
|
5
|
+
#include "reference.h"
|
|
5
6
|
#include "rustbindings.h"
|
|
6
7
|
#include "utils.h"
|
|
7
8
|
|
|
@@ -10,6 +11,7 @@ VALUE cNamespace;
|
|
|
10
11
|
VALUE cClass;
|
|
11
12
|
VALUE cModule;
|
|
12
13
|
VALUE cSingletonClass;
|
|
14
|
+
VALUE cTodo;
|
|
13
15
|
VALUE cConstant;
|
|
14
16
|
VALUE cConstantAlias;
|
|
15
17
|
VALUE cMethod;
|
|
@@ -26,6 +28,8 @@ VALUE rdxi_declaration_class_for_kind(CDeclarationKind kind) {
|
|
|
26
28
|
return cModule;
|
|
27
29
|
case CDeclarationKind_SingletonClass:
|
|
28
30
|
return cSingletonClass;
|
|
31
|
+
case CDeclarationKind_Todo:
|
|
32
|
+
return cTodo;
|
|
29
33
|
case CDeclarationKind_Constant:
|
|
30
34
|
return cConstant;
|
|
31
35
|
case CDeclarationKind_ConstantAlias:
|
|
@@ -291,12 +295,49 @@ static VALUE rdxr_declaration_descendants(VALUE self) {
|
|
|
291
295
|
return self;
|
|
292
296
|
}
|
|
293
297
|
|
|
298
|
+
// Size function for the Declaration#references enumerator
|
|
299
|
+
static VALUE declaration_references_size(VALUE self, VALUE _args, VALUE _eobj) {
|
|
300
|
+
HandleData *data;
|
|
301
|
+
TypedData_Get_Struct(self, HandleData, &handle_type, data);
|
|
302
|
+
|
|
303
|
+
void *graph;
|
|
304
|
+
TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
|
|
305
|
+
|
|
306
|
+
struct ReferencesIter *iter = rdx_declaration_references_iter_new(graph, data->id);
|
|
307
|
+
size_t len = rdx_references_iter_len(iter);
|
|
308
|
+
rdx_references_iter_free(iter);
|
|
309
|
+
|
|
310
|
+
return SIZET2NUM(len);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Returns an enumerator for all references to this declaration
|
|
314
|
+
//
|
|
315
|
+
// Declaration#references: () -> Enumerator[Reference]
|
|
316
|
+
static VALUE rdxr_declaration_references(VALUE self) {
|
|
317
|
+
if (!rb_block_given_p()) {
|
|
318
|
+
return rb_enumeratorize_with_size(self, rb_str_new2("references"), 0, NULL, declaration_references_size);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
HandleData *data;
|
|
322
|
+
TypedData_Get_Struct(self, HandleData, &handle_type, data);
|
|
323
|
+
|
|
324
|
+
void *graph;
|
|
325
|
+
TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
|
|
326
|
+
|
|
327
|
+
void *iter = rdx_declaration_references_iter_new(graph, data->id);
|
|
328
|
+
VALUE args = rb_ary_new_from_args(2, data->graph_obj, ULL2NUM((uintptr_t)iter));
|
|
329
|
+
rb_ensure(rdxi_references_yield, args, rdxi_references_ensure, args);
|
|
330
|
+
|
|
331
|
+
return self;
|
|
332
|
+
}
|
|
333
|
+
|
|
294
334
|
void rdxi_initialize_declaration(VALUE mRubydex) {
|
|
295
335
|
cDeclaration = rb_define_class_under(mRubydex, "Declaration", rb_cObject);
|
|
296
336
|
cNamespace = rb_define_class_under(mRubydex, "Namespace", cDeclaration);
|
|
297
337
|
cClass = rb_define_class_under(mRubydex, "Class", cNamespace);
|
|
298
338
|
cModule = rb_define_class_under(mRubydex, "Module", cNamespace);
|
|
299
339
|
cSingletonClass = rb_define_class_under(mRubydex, "SingletonClass", cNamespace);
|
|
340
|
+
cTodo = rb_define_class_under(mRubydex, "Todo", cNamespace);
|
|
300
341
|
cConstant = rb_define_class_under(mRubydex, "Constant", cDeclaration);
|
|
301
342
|
cConstantAlias = rb_define_class_under(mRubydex, "ConstantAlias", cDeclaration);
|
|
302
343
|
cMethod = rb_define_class_under(mRubydex, "Method", cDeclaration);
|
|
@@ -309,6 +350,7 @@ void rdxi_initialize_declaration(VALUE mRubydex) {
|
|
|
309
350
|
rb_define_method(cDeclaration, "name", rdxr_declaration_name, 0);
|
|
310
351
|
rb_define_method(cDeclaration, "unqualified_name", rdxr_declaration_unqualified_name, 0);
|
|
311
352
|
rb_define_method(cDeclaration, "definitions", rdxr_declaration_definitions, 0);
|
|
353
|
+
rb_define_method(cDeclaration, "references", rdxr_declaration_references, 0);
|
|
312
354
|
rb_define_method(cDeclaration, "owner", rdxr_declaration_owner, 0);
|
|
313
355
|
|
|
314
356
|
// Namespace only methods
|
data/ext/rubydex/declaration.h
CHANGED
data/ext/rubydex/graph.c
CHANGED
|
@@ -228,31 +228,6 @@ static VALUE rdxr_graph_aref(VALUE self, VALUE key) {
|
|
|
228
228
|
return rb_class_new_instance(2, argv, decl_class);
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
// Body function for rb_ensure for the reference enumerators
|
|
232
|
-
static VALUE graph_references_yield(VALUE args) {
|
|
233
|
-
VALUE self = rb_ary_entry(args, 0);
|
|
234
|
-
void *iter = (void *)(uintptr_t)NUM2ULL(rb_ary_entry(args, 1));
|
|
235
|
-
|
|
236
|
-
uint64_t id = 0;
|
|
237
|
-
ReferenceKind kind;
|
|
238
|
-
while (rdx_references_iter_next(iter, &id, &kind)) {
|
|
239
|
-
VALUE ref_class = rdxi_reference_class_for_kind(kind);
|
|
240
|
-
VALUE argv[] = {self, ULL2NUM(id)};
|
|
241
|
-
VALUE obj = rb_class_new_instance(2, argv, ref_class);
|
|
242
|
-
rb_yield(obj);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return Qnil;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// Ensure function for rb_ensure for the reference enumerators to always free the iterator
|
|
249
|
-
static VALUE graph_references_ensure(VALUE args) {
|
|
250
|
-
void *iter = (void *)(uintptr_t)NUM2ULL(rb_ary_entry(args, 1));
|
|
251
|
-
rdx_references_iter_free(iter);
|
|
252
|
-
|
|
253
|
-
return Qnil;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
231
|
// Size function for the constant_references enumerator
|
|
257
232
|
static VALUE graph_constant_references_size(VALUE self, VALUE _args, VALUE _eobj) {
|
|
258
233
|
void *graph;
|
|
@@ -278,7 +253,7 @@ static VALUE rdxr_graph_constant_references(VALUE self) {
|
|
|
278
253
|
|
|
279
254
|
void *iter = rdx_graph_constant_references_iter_new(graph);
|
|
280
255
|
VALUE args = rb_ary_new_from_args(2, self, ULL2NUM((uintptr_t)iter));
|
|
281
|
-
rb_ensure(
|
|
256
|
+
rb_ensure(rdxi_references_yield, args, rdxi_references_ensure, args);
|
|
282
257
|
|
|
283
258
|
return self;
|
|
284
259
|
}
|
|
@@ -308,7 +283,7 @@ static VALUE rdxr_graph_method_references(VALUE self) {
|
|
|
308
283
|
|
|
309
284
|
void *iter = rdx_graph_method_references_iter_new(graph);
|
|
310
285
|
VALUE args = rb_ary_new_from_args(2, self, ULL2NUM((uintptr_t)iter));
|
|
311
|
-
rb_ensure(
|
|
286
|
+
rb_ensure(rdxi_references_yield, args, rdxi_references_ensure, args);
|
|
312
287
|
|
|
313
288
|
return self;
|
|
314
289
|
}
|
data/ext/rubydex/utils.c
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#include "utils.h"
|
|
2
2
|
#include "declaration.h"
|
|
3
|
+
#include "reference.h"
|
|
3
4
|
#include "rustbindings.h"
|
|
4
5
|
|
|
5
6
|
// Convert a Ruby array of strings into a double char pointer so that we can pass that to Rust.
|
|
@@ -50,3 +51,26 @@ VALUE rdxi_declarations_ensure(VALUE args) {
|
|
|
50
51
|
rdx_graph_declarations_iter_free(iter);
|
|
51
52
|
return Qnil;
|
|
52
53
|
}
|
|
54
|
+
|
|
55
|
+
// Yield body for iterating over references
|
|
56
|
+
VALUE rdxi_references_yield(VALUE args) {
|
|
57
|
+
VALUE graph_obj = rb_ary_entry(args, 0);
|
|
58
|
+
void *iter = (void *)(uintptr_t)NUM2ULL(rb_ary_entry(args, 1));
|
|
59
|
+
|
|
60
|
+
CReference cref;
|
|
61
|
+
while (rdx_references_iter_next(iter, &cref)) {
|
|
62
|
+
VALUE ref_class = rdxi_reference_class_for_kind(cref.kind);
|
|
63
|
+
VALUE argv[] = {graph_obj, ULL2NUM(cref.id)};
|
|
64
|
+
VALUE obj = rb_class_new_instance(2, argv, ref_class);
|
|
65
|
+
rb_yield(obj);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return Qnil;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Ensure function for iterating over references to always free the iterator
|
|
72
|
+
VALUE rdxi_references_ensure(VALUE args) {
|
|
73
|
+
void *iter = (void *)(uintptr_t)NUM2ULL(rb_ary_entry(args, 1));
|
|
74
|
+
rdx_references_iter_free(iter);
|
|
75
|
+
return Qnil;
|
|
76
|
+
}
|
data/ext/rubydex/utils.h
CHANGED
|
@@ -16,4 +16,10 @@ VALUE rdxi_declarations_yield(VALUE args);
|
|
|
16
16
|
// Ensure function for iterating over declarations to always free the iterator
|
|
17
17
|
VALUE rdxi_declarations_ensure(VALUE args);
|
|
18
18
|
|
|
19
|
+
// Yield body for iterating over references
|
|
20
|
+
VALUE rdxi_references_yield(VALUE args);
|
|
21
|
+
|
|
22
|
+
// Ensure function for iterating over references to always free the iterator
|
|
23
|
+
VALUE rdxi_references_ensure(VALUE args);
|
|
24
|
+
|
|
19
25
|
#endif // RUBYDEX_UTILS_H
|
data/lib/rubydex/3.2/rubydex.so
CHANGED
|
Binary file
|
data/lib/rubydex/3.3/rubydex.so
CHANGED
|
Binary file
|
data/lib/rubydex/3.4/rubydex.so
CHANGED
|
Binary file
|
data/lib/rubydex/4.0/rubydex.so
CHANGED
|
Binary file
|
|
Binary file
|
data/lib/rubydex/version.rb
CHANGED