rubydex 0.1.0.beta11 → 0.1.0.beta13
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/LICENSE.txt +23 -23
- data/README.md +125 -125
- data/THIRD_PARTY_LICENSES.html +2018 -945
- data/exe/rdx +47 -47
- data/ext/rubydex/declaration.c +453 -388
- data/ext/rubydex/declaration.h +23 -23
- data/ext/rubydex/definition.c +284 -197
- data/ext/rubydex/definition.h +28 -28
- data/ext/rubydex/diagnostic.c +6 -6
- data/ext/rubydex/diagnostic.h +11 -11
- data/ext/rubydex/document.c +97 -98
- data/ext/rubydex/document.h +10 -10
- data/ext/rubydex/extconf.rb +146 -127
- data/ext/rubydex/graph.c +701 -512
- data/ext/rubydex/graph.h +10 -10
- data/ext/rubydex/handle.h +44 -44
- data/ext/rubydex/location.c +22 -22
- data/ext/rubydex/location.h +15 -15
- data/ext/rubydex/reference.c +123 -104
- data/ext/rubydex/reference.h +15 -16
- data/ext/rubydex/rubydex.c +22 -22
- data/ext/rubydex/utils.c +108 -86
- data/ext/rubydex/utils.h +34 -28
- data/lib/rubydex/comment.rb +17 -17
- data/lib/rubydex/declaration.rb +11 -0
- data/lib/rubydex/diagnostic.rb +21 -21
- data/lib/rubydex/failures.rb +15 -15
- data/lib/rubydex/graph.rb +98 -92
- data/lib/rubydex/keyword.rb +17 -0
- data/lib/rubydex/keyword_parameter.rb +13 -0
- data/lib/rubydex/location.rb +90 -90
- data/lib/rubydex/mixin.rb +22 -0
- data/lib/rubydex/version.rb +5 -5
- data/lib/rubydex.rb +24 -20
- data/rbi/rubydex.rbi +425 -310
- data/rust/Cargo.lock +1851 -1851
- data/rust/Cargo.toml +29 -29
- data/rust/about.toml +10 -10
- data/rust/{about.hbs → about_templates/about.hbs} +81 -78
- data/rust/about_templates/mingw_licenses.hbs +1071 -0
- data/rust/rubydex/Cargo.toml +42 -42
- data/rust/rubydex/src/compile_assertions.rs +13 -13
- data/rust/rubydex/src/diagnostic.rs +110 -109
- data/rust/rubydex/src/errors.rs +28 -28
- data/rust/rubydex/src/indexing/local_graph.rs +224 -224
- data/rust/rubydex/src/indexing/rbs_indexer.rs +1551 -1554
- data/rust/rubydex/src/indexing/ruby_indexer.rs +2329 -6753
- data/rust/rubydex/src/indexing/ruby_indexer_tests.rs +4962 -0
- data/rust/rubydex/src/indexing.rs +210 -210
- data/rust/rubydex/src/integrity.rs +279 -278
- data/rust/rubydex/src/job_queue.rs +199 -205
- data/rust/rubydex/src/lib.rs +17 -17
- data/rust/rubydex/src/listing.rs +371 -272
- data/rust/rubydex/src/main.rs +160 -160
- data/rust/rubydex/src/model/built_in.rs +83 -0
- data/rust/rubydex/src/model/comment.rs +24 -24
- data/rust/rubydex/src/model/declaration.rs +679 -588
- data/rust/rubydex/src/model/definitions.rs +1682 -1602
- data/rust/rubydex/src/model/document.rs +222 -252
- data/rust/rubydex/src/model/encoding.rs +22 -22
- data/rust/rubydex/src/model/graph.rs +3782 -3556
- data/rust/rubydex/src/model/id.rs +110 -110
- data/rust/rubydex/src/model/identity_maps.rs +58 -58
- data/rust/rubydex/src/model/ids.rs +60 -38
- data/rust/rubydex/src/model/keywords.rs +256 -256
- data/rust/rubydex/src/model/name.rs +298 -298
- data/rust/rubydex/src/model/references.rs +111 -111
- data/rust/rubydex/src/model/string_ref.rs +50 -50
- data/rust/rubydex/src/model/visibility.rs +41 -41
- data/rust/rubydex/src/model.rs +15 -14
- data/rust/rubydex/src/offset.rs +147 -147
- data/rust/rubydex/src/position.rs +6 -6
- data/rust/rubydex/src/query.rs +1841 -1700
- data/rust/rubydex/src/resolution.rs +1852 -5895
- data/rust/rubydex/src/resolution_tests.rs +4701 -0
- data/rust/rubydex/src/stats/memory.rs +71 -71
- data/rust/rubydex/src/stats/orphan_report.rs +264 -263
- data/rust/rubydex/src/stats/timer.rs +127 -127
- data/rust/rubydex/src/stats.rs +11 -11
- data/rust/rubydex/src/test_utils/context.rs +226 -226
- data/rust/rubydex/src/test_utils/graph_test.rs +730 -679
- data/rust/rubydex/src/test_utils/local_graph_test.rs +602 -602
- data/rust/rubydex/src/test_utils.rs +52 -52
- data/rust/rubydex/src/visualization/dot.rs +192 -176
- data/rust/rubydex/src/visualization.rs +6 -6
- data/rust/rubydex/tests/cli.rs +185 -167
- data/rust/rubydex-mcp/Cargo.toml +28 -28
- data/rust/rubydex-mcp/src/main.rs +48 -48
- data/rust/rubydex-mcp/src/server.rs +1145 -1145
- data/rust/rubydex-mcp/src/tools.rs +49 -49
- data/rust/rubydex-mcp/tests/mcp.rs +302 -302
- data/rust/rubydex-sys/Cargo.toml +20 -20
- data/rust/rubydex-sys/build.rs +14 -14
- data/rust/rubydex-sys/cbindgen.toml +12 -12
- data/rust/rubydex-sys/src/declaration_api.rs +485 -469
- data/rust/rubydex-sys/src/definition_api.rs +443 -352
- data/rust/rubydex-sys/src/diagnostic_api.rs +99 -99
- data/rust/rubydex-sys/src/document_api.rs +85 -54
- data/rust/rubydex-sys/src/graph_api.rs +1017 -700
- data/rust/rubydex-sys/src/lib.rs +79 -9
- data/rust/rubydex-sys/src/location_api.rs +79 -79
- data/rust/rubydex-sys/src/name_api.rs +187 -135
- data/rust/rubydex-sys/src/reference_api.rs +267 -195
- data/rust/rubydex-sys/src/utils.rs +70 -70
- data/rust/rustfmt.toml +2 -2
- metadata +16 -9
- data/lib/rubydex/librubydex_sys.so +0 -0
data/ext/rubydex/graph.h
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
#ifndef RUBYDEX_GRAPH_H
|
|
2
|
-
#define RUBYDEX_GRAPH_H
|
|
3
|
-
|
|
4
|
-
#include "ruby.h"
|
|
5
|
-
|
|
6
|
-
extern const rb_data_type_t graph_type;
|
|
7
|
-
|
|
8
|
-
void rdxi_initialize_graph(VALUE mRubydex);
|
|
9
|
-
|
|
10
|
-
#endif // RUBYDEX_GRAPH_H
|
|
1
|
+
#ifndef RUBYDEX_GRAPH_H
|
|
2
|
+
#define RUBYDEX_GRAPH_H
|
|
3
|
+
|
|
4
|
+
#include "ruby.h"
|
|
5
|
+
|
|
6
|
+
extern const rb_data_type_t graph_type;
|
|
7
|
+
|
|
8
|
+
void rdxi_initialize_graph(VALUE mRubydex);
|
|
9
|
+
|
|
10
|
+
#endif // RUBYDEX_GRAPH_H
|
data/ext/rubydex/handle.h
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
#ifndef RUBYDEX_HANDLE_H
|
|
2
|
-
#define RUBYDEX_HANDLE_H
|
|
3
|
-
|
|
4
|
-
#include "ruby.h"
|
|
5
|
-
|
|
6
|
-
typedef struct {
|
|
7
|
-
VALUE graph_obj; // Ruby Graph object to keep it alive
|
|
8
|
-
uint64_t id; // Canonical ID mapping to a DeclarationId, DefinitionId, UriId, etc. See `ids.rs`.
|
|
9
|
-
} HandleData;
|
|
10
|
-
|
|
11
|
-
static void handle_mark(void *ptr) {
|
|
12
|
-
if (ptr) {
|
|
13
|
-
HandleData *data = (HandleData *)ptr;
|
|
14
|
-
rb_gc_mark(data->graph_obj);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static void handle_free(void *ptr) {
|
|
19
|
-
if (ptr) {
|
|
20
|
-
xfree(ptr);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static const rb_data_type_t handle_type = {
|
|
25
|
-
"RubydexHandle", {handle_mark, handle_free, 0}, 0, 0, RUBY_TYPED_FREE_IMMEDIATELY};
|
|
26
|
-
|
|
27
|
-
static VALUE rdxr_handle_alloc(VALUE klass) {
|
|
28
|
-
HandleData *data = ALLOC(HandleData);
|
|
29
|
-
data->graph_obj = Qnil;
|
|
30
|
-
data->id = 0;
|
|
31
|
-
|
|
32
|
-
return TypedData_Wrap_Struct(klass, &handle_type, data);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static VALUE rdxr_handle_initialize(VALUE self, VALUE graph_obj, VALUE id_val) {
|
|
36
|
-
HandleData *data;
|
|
37
|
-
TypedData_Get_Struct(self, HandleData, &handle_type, data);
|
|
38
|
-
data->graph_obj = graph_obj;
|
|
39
|
-
data->id = NUM2ULL(id_val);
|
|
40
|
-
|
|
41
|
-
return self;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
#endif // RUBYDEX_HANDLE_H
|
|
1
|
+
#ifndef RUBYDEX_HANDLE_H
|
|
2
|
+
#define RUBYDEX_HANDLE_H
|
|
3
|
+
|
|
4
|
+
#include "ruby.h"
|
|
5
|
+
|
|
6
|
+
typedef struct {
|
|
7
|
+
VALUE graph_obj; // Ruby Graph object to keep it alive
|
|
8
|
+
uint64_t id; // Canonical ID mapping to a DeclarationId, DefinitionId, UriId, etc. See `ids.rs`.
|
|
9
|
+
} HandleData;
|
|
10
|
+
|
|
11
|
+
static void handle_mark(void *ptr) {
|
|
12
|
+
if (ptr) {
|
|
13
|
+
HandleData *data = (HandleData *)ptr;
|
|
14
|
+
rb_gc_mark(data->graph_obj);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static void handle_free(void *ptr) {
|
|
19
|
+
if (ptr) {
|
|
20
|
+
xfree(ptr);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static const rb_data_type_t handle_type = {
|
|
25
|
+
"RubydexHandle", {handle_mark, handle_free, 0}, 0, 0, RUBY_TYPED_FREE_IMMEDIATELY};
|
|
26
|
+
|
|
27
|
+
static VALUE rdxr_handle_alloc(VALUE klass) {
|
|
28
|
+
HandleData *data = ALLOC(HandleData);
|
|
29
|
+
data->graph_obj = Qnil;
|
|
30
|
+
data->id = 0;
|
|
31
|
+
|
|
32
|
+
return TypedData_Wrap_Struct(klass, &handle_type, data);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static VALUE rdxr_handle_initialize(VALUE self, VALUE graph_obj, VALUE id_val) {
|
|
36
|
+
HandleData *data;
|
|
37
|
+
TypedData_Get_Struct(self, HandleData, &handle_type, data);
|
|
38
|
+
data->graph_obj = graph_obj;
|
|
39
|
+
data->id = NUM2ULL(id_val);
|
|
40
|
+
|
|
41
|
+
return self;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#endif // RUBYDEX_HANDLE_H
|
data/ext/rubydex/location.c
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
#include "location.h"
|
|
2
|
-
|
|
3
|
-
VALUE cLocation;
|
|
4
|
-
|
|
5
|
-
VALUE rdxi_build_location_value(Location *loc) {
|
|
6
|
-
if (loc == NULL) {
|
|
7
|
-
return Qnil;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
VALUE uri = rb_utf8_str_new_cstr(loc->uri);
|
|
11
|
-
|
|
12
|
-
VALUE kwargs = rb_hash_new_capa(5);
|
|
13
|
-
rb_hash_aset(kwargs, ID2SYM(rb_intern("uri")), uri);
|
|
14
|
-
rb_hash_aset(kwargs, ID2SYM(rb_intern("start_line")), UINT2NUM(loc->start_line));
|
|
15
|
-
rb_hash_aset(kwargs, ID2SYM(rb_intern("end_line")), UINT2NUM(loc->end_line));
|
|
16
|
-
rb_hash_aset(kwargs, ID2SYM(rb_intern("start_column")), UINT2NUM(loc->start_column));
|
|
17
|
-
rb_hash_aset(kwargs, ID2SYM(rb_intern("end_column")), UINT2NUM(loc->end_column));
|
|
18
|
-
|
|
19
|
-
return rb_class_new_instance_kw(1, &kwargs, cLocation, RB_PASS_KEYWORDS);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
void rdxi_initialize_location(VALUE mRubydex) { cLocation = rb_define_class_under(mRubydex, "Location", rb_cObject); }
|
|
1
|
+
#include "location.h"
|
|
2
|
+
|
|
3
|
+
VALUE cLocation;
|
|
4
|
+
|
|
5
|
+
VALUE rdxi_build_location_value(Location *loc) {
|
|
6
|
+
if (loc == NULL) {
|
|
7
|
+
return Qnil;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
VALUE uri = rb_utf8_str_new_cstr(loc->uri);
|
|
11
|
+
|
|
12
|
+
VALUE kwargs = rb_hash_new_capa(5);
|
|
13
|
+
rb_hash_aset(kwargs, ID2SYM(rb_intern("uri")), uri);
|
|
14
|
+
rb_hash_aset(kwargs, ID2SYM(rb_intern("start_line")), UINT2NUM(loc->start_line));
|
|
15
|
+
rb_hash_aset(kwargs, ID2SYM(rb_intern("end_line")), UINT2NUM(loc->end_line));
|
|
16
|
+
rb_hash_aset(kwargs, ID2SYM(rb_intern("start_column")), UINT2NUM(loc->start_column));
|
|
17
|
+
rb_hash_aset(kwargs, ID2SYM(rb_intern("end_column")), UINT2NUM(loc->end_column));
|
|
18
|
+
|
|
19
|
+
return rb_class_new_instance_kw(1, &kwargs, cLocation, RB_PASS_KEYWORDS);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
void rdxi_initialize_location(VALUE mRubydex) { cLocation = rb_define_class_under(mRubydex, "Location", rb_cObject); }
|
data/ext/rubydex/location.h
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
#ifndef RUBYDEX_LOCATION_H
|
|
2
|
-
#define RUBYDEX_LOCATION_H
|
|
3
|
-
|
|
4
|
-
#include "ruby.h"
|
|
5
|
-
#include "rustbindings.h"
|
|
6
|
-
|
|
7
|
-
extern VALUE cLocation;
|
|
8
|
-
|
|
9
|
-
void rdxi_initialize_location(VALUE mRubydex);
|
|
10
|
-
|
|
11
|
-
// Helper to build a Ruby Rubydex::Location from a C Location pointer.
|
|
12
|
-
// Does not take ownership; caller remains responsible for freeing the C Location on the Rust side.
|
|
13
|
-
VALUE rdxi_build_location_value(Location *loc);
|
|
14
|
-
|
|
15
|
-
#endif // RUBYDEX_LOCATION_H
|
|
1
|
+
#ifndef RUBYDEX_LOCATION_H
|
|
2
|
+
#define RUBYDEX_LOCATION_H
|
|
3
|
+
|
|
4
|
+
#include "ruby.h"
|
|
5
|
+
#include "rustbindings.h"
|
|
6
|
+
|
|
7
|
+
extern VALUE cLocation;
|
|
8
|
+
|
|
9
|
+
void rdxi_initialize_location(VALUE mRubydex);
|
|
10
|
+
|
|
11
|
+
// Helper to build a Ruby Rubydex::Location from a C Location pointer.
|
|
12
|
+
// Does not take ownership; caller remains responsible for freeing the C Location on the Rust side.
|
|
13
|
+
VALUE rdxi_build_location_value(Location *loc);
|
|
14
|
+
|
|
15
|
+
#endif // RUBYDEX_LOCATION_H
|
data/ext/rubydex/reference.c
CHANGED
|
@@ -1,104 +1,123 @@
|
|
|
1
|
-
#include "reference.h"
|
|
2
|
-
#include "
|
|
3
|
-
#include "
|
|
4
|
-
#include "
|
|
5
|
-
#include "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
VALUE
|
|
9
|
-
VALUE
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
TypedData_Get_Struct(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
TypedData_Get_Struct(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
TypedData_Get_Struct(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
TypedData_Get_Struct(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
rb_define_alloc_func(
|
|
101
|
-
rb_define_method(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
1
|
+
#include "reference.h"
|
|
2
|
+
#include "declaration.h"
|
|
3
|
+
#include "graph.h"
|
|
4
|
+
#include "handle.h"
|
|
5
|
+
#include "location.h"
|
|
6
|
+
#include "rustbindings.h"
|
|
7
|
+
|
|
8
|
+
VALUE cReference;
|
|
9
|
+
VALUE cConstantReference;
|
|
10
|
+
VALUE cUnresolvedConstantReference;
|
|
11
|
+
VALUE cResolvedConstantReference;
|
|
12
|
+
VALUE cMethodReference;
|
|
13
|
+
|
|
14
|
+
// ConstantReference#name -> String
|
|
15
|
+
static VALUE rdxr_constant_reference_name(VALUE self) {
|
|
16
|
+
HandleData *data;
|
|
17
|
+
TypedData_Get_Struct(self, HandleData, &handle_type, data);
|
|
18
|
+
|
|
19
|
+
void *graph;
|
|
20
|
+
TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
|
|
21
|
+
|
|
22
|
+
const char *name = rdx_constant_reference_name(graph, data->id);
|
|
23
|
+
if (name == NULL) {
|
|
24
|
+
return Qnil;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
VALUE str = rb_utf8_str_new_cstr(name);
|
|
28
|
+
free_c_string(name);
|
|
29
|
+
return str;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ConstantReference#location -> Rubydex::Location
|
|
33
|
+
static VALUE rdxr_constant_reference_location(VALUE self) {
|
|
34
|
+
HandleData *data;
|
|
35
|
+
TypedData_Get_Struct(self, HandleData, &handle_type, data);
|
|
36
|
+
|
|
37
|
+
void *graph;
|
|
38
|
+
TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
|
|
39
|
+
|
|
40
|
+
Location *loc = rdx_constant_reference_location(graph, data->id);
|
|
41
|
+
VALUE location = rdxi_build_location_value(loc);
|
|
42
|
+
rdx_location_free(loc);
|
|
43
|
+
return location;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// MethodReference#name -> String
|
|
47
|
+
static VALUE rdxr_method_reference_name(VALUE self) {
|
|
48
|
+
HandleData *data;
|
|
49
|
+
TypedData_Get_Struct(self, HandleData, &handle_type, data);
|
|
50
|
+
|
|
51
|
+
void *graph;
|
|
52
|
+
TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
|
|
53
|
+
|
|
54
|
+
const char *name = rdx_method_reference_name(graph, data->id);
|
|
55
|
+
if (name == NULL) {
|
|
56
|
+
return Qnil;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
VALUE str = rb_utf8_str_new_cstr(name);
|
|
60
|
+
free_c_string(name);
|
|
61
|
+
return str;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// MethodReference#location -> Rubydex::Location
|
|
65
|
+
static VALUE rdxr_method_reference_location(VALUE self) {
|
|
66
|
+
HandleData *data;
|
|
67
|
+
TypedData_Get_Struct(self, HandleData, &handle_type, data);
|
|
68
|
+
|
|
69
|
+
void *graph;
|
|
70
|
+
TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
|
|
71
|
+
|
|
72
|
+
Location *loc = rdx_method_reference_location(graph, data->id);
|
|
73
|
+
VALUE location = rdxi_build_location_value(loc);
|
|
74
|
+
rdx_location_free(loc);
|
|
75
|
+
return location;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ResolvedConstantReference#declaration -> Declaration
|
|
79
|
+
static VALUE rdxr_resolved_constant_reference_declaration(VALUE self) {
|
|
80
|
+
HandleData *data;
|
|
81
|
+
TypedData_Get_Struct(self, HandleData, &handle_type, data);
|
|
82
|
+
|
|
83
|
+
void *graph;
|
|
84
|
+
TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
|
|
85
|
+
|
|
86
|
+
const struct CDeclaration *decl = rdx_resolved_constant_reference_declaration(graph, data->id);
|
|
87
|
+
if (decl == NULL) {
|
|
88
|
+
rb_raise(rb_eRuntimeError, "Invalid declaration for a resolved constant reference");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
VALUE decl_class = rdxi_declaration_class_for_kind(decl->kind);
|
|
92
|
+
VALUE argv[] = {data->graph_obj, ULL2NUM(decl->id)};
|
|
93
|
+
free_c_declaration(decl);
|
|
94
|
+
|
|
95
|
+
return rb_class_new_instance(2, argv, decl_class);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
void rdxi_initialize_reference(VALUE mRubydex) {
|
|
99
|
+
cReference = rb_define_class_under(mRubydex, "Reference", rb_cObject);
|
|
100
|
+
rb_define_alloc_func(cReference, rdxr_handle_alloc);
|
|
101
|
+
rb_define_method(cReference, "initialize", rdxr_handle_initialize, 2);
|
|
102
|
+
rb_funcall(rb_singleton_class(cReference), rb_intern("private"), 1, ID2SYM(rb_intern("new")));
|
|
103
|
+
|
|
104
|
+
cConstantReference = rb_define_class_under(mRubydex, "ConstantReference", cReference);
|
|
105
|
+
rb_define_alloc_func(cConstantReference, rdxr_handle_alloc);
|
|
106
|
+
rb_define_method(cConstantReference, "initialize", rdxr_handle_initialize, 2);
|
|
107
|
+
rb_define_method(cConstantReference, "location", rdxr_constant_reference_location, 0);
|
|
108
|
+
rb_funcall(rb_singleton_class(cConstantReference), rb_intern("private"), 1, ID2SYM(rb_intern("new")));
|
|
109
|
+
|
|
110
|
+
cUnresolvedConstantReference = rb_define_class_under(mRubydex, "UnresolvedConstantReference", cConstantReference);
|
|
111
|
+
rb_define_alloc_func(cUnresolvedConstantReference, rdxr_handle_alloc);
|
|
112
|
+
rb_define_method(cUnresolvedConstantReference, "name", rdxr_constant_reference_name, 0);
|
|
113
|
+
|
|
114
|
+
cResolvedConstantReference = rb_define_class_under(mRubydex, "ResolvedConstantReference", cConstantReference);
|
|
115
|
+
rb_define_alloc_func(cResolvedConstantReference, rdxr_handle_alloc);
|
|
116
|
+
rb_define_method(cResolvedConstantReference, "declaration", rdxr_resolved_constant_reference_declaration, 0);
|
|
117
|
+
|
|
118
|
+
cMethodReference = rb_define_class_under(mRubydex, "MethodReference", cReference);
|
|
119
|
+
rb_define_alloc_func(cMethodReference, rdxr_handle_alloc);
|
|
120
|
+
rb_define_method(cMethodReference, "initialize", rdxr_handle_initialize, 2);
|
|
121
|
+
rb_define_method(cMethodReference, "name", rdxr_method_reference_name, 0);
|
|
122
|
+
rb_define_method(cMethodReference, "location", rdxr_method_reference_location, 0);
|
|
123
|
+
}
|
data/ext/rubydex/reference.h
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
#ifndef RUBYDEX_REFERENCE_H
|
|
2
|
-
#define RUBYDEX_REFERENCE_H
|
|
3
|
-
|
|
4
|
-
#include "ruby.h"
|
|
5
|
-
#include "rustbindings.h"
|
|
6
|
-
|
|
7
|
-
extern VALUE cReference;
|
|
8
|
-
extern VALUE cConstantReference;
|
|
9
|
-
extern VALUE
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
#endif // RUBYDEX_REFERENCE_H
|
|
1
|
+
#ifndef RUBYDEX_REFERENCE_H
|
|
2
|
+
#define RUBYDEX_REFERENCE_H
|
|
3
|
+
|
|
4
|
+
#include "ruby.h"
|
|
5
|
+
#include "rustbindings.h"
|
|
6
|
+
|
|
7
|
+
extern VALUE cReference;
|
|
8
|
+
extern VALUE cConstantReference;
|
|
9
|
+
extern VALUE cUnresolvedConstantReference;
|
|
10
|
+
extern VALUE cResolvedConstantReference;
|
|
11
|
+
extern VALUE cMethodReference;
|
|
12
|
+
|
|
13
|
+
void rdxi_initialize_reference(VALUE mRubydex);
|
|
14
|
+
|
|
15
|
+
#endif // RUBYDEX_REFERENCE_H
|
data/ext/rubydex/rubydex.c
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
#include "declaration.h"
|
|
2
|
-
#include "definition.h"
|
|
3
|
-
#include "diagnostic.h"
|
|
4
|
-
#include "document.h"
|
|
5
|
-
#include "graph.h"
|
|
6
|
-
#include "location.h"
|
|
7
|
-
#include "reference.h"
|
|
8
|
-
|
|
9
|
-
VALUE mRubydex;
|
|
10
|
-
|
|
11
|
-
void Init_rubydex(void) {
|
|
12
|
-
rb_ext_ractor_safe(true);
|
|
13
|
-
|
|
14
|
-
mRubydex = rb_define_module("Rubydex");
|
|
15
|
-
rdxi_initialize_graph(mRubydex);
|
|
16
|
-
rdxi_initialize_declaration(mRubydex);
|
|
17
|
-
rdxi_initialize_document(mRubydex);
|
|
18
|
-
rdxi_initialize_definition(mRubydex);
|
|
19
|
-
rdxi_initialize_location(mRubydex);
|
|
20
|
-
rdxi_initialize_diagnostic(mRubydex);
|
|
21
|
-
rdxi_initialize_reference(mRubydex);
|
|
22
|
-
}
|
|
1
|
+
#include "declaration.h"
|
|
2
|
+
#include "definition.h"
|
|
3
|
+
#include "diagnostic.h"
|
|
4
|
+
#include "document.h"
|
|
5
|
+
#include "graph.h"
|
|
6
|
+
#include "location.h"
|
|
7
|
+
#include "reference.h"
|
|
8
|
+
|
|
9
|
+
VALUE mRubydex;
|
|
10
|
+
|
|
11
|
+
void Init_rubydex(void) {
|
|
12
|
+
rb_ext_ractor_safe(true);
|
|
13
|
+
|
|
14
|
+
mRubydex = rb_define_module("Rubydex");
|
|
15
|
+
rdxi_initialize_graph(mRubydex);
|
|
16
|
+
rdxi_initialize_declaration(mRubydex);
|
|
17
|
+
rdxi_initialize_document(mRubydex);
|
|
18
|
+
rdxi_initialize_definition(mRubydex);
|
|
19
|
+
rdxi_initialize_location(mRubydex);
|
|
20
|
+
rdxi_initialize_diagnostic(mRubydex);
|
|
21
|
+
rdxi_initialize_reference(mRubydex);
|
|
22
|
+
}
|