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
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
use std::sync::Mutex;
|
|
2
|
-
use std::time::{Duration, Instant};
|
|
3
|
-
|
|
4
|
-
/// Generates a global timer for measuring performance across different phases of execution in the main thread.
|
|
5
|
-
///
|
|
6
|
-
/// This macro creates:
|
|
7
|
-
/// - A `Timer` struct with fields for each defined phase
|
|
8
|
-
/// - A global `TIMER` static for tracking measurements
|
|
9
|
-
/// - A `time_it!` macro to measure and record individual phase durations
|
|
10
|
-
///
|
|
11
|
-
/// The timer is only created when running with the `--stats` flag.
|
|
12
|
-
///
|
|
13
|
-
/// Usage:
|
|
14
|
-
/// 1. To add a new phase, add an entry to the `make_timer!` invocation at the bottom of this file
|
|
15
|
-
/// 2. Wrap code blocks with `time_it!(phase_name, { ... })` to measure them
|
|
16
|
-
macro_rules! make_timer {
|
|
17
|
-
(
|
|
18
|
-
$(
|
|
19
|
-
$phase:ident, $label:literal;
|
|
20
|
-
)*
|
|
21
|
-
) => {
|
|
22
|
-
#[derive(Clone)]
|
|
23
|
-
pub struct Timer {
|
|
24
|
-
start_time: Instant,
|
|
25
|
-
$(
|
|
26
|
-
pub $phase: Duration,
|
|
27
|
-
)*
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
pub static TIMER: Mutex<Option<Timer>> = Mutex::new(None);
|
|
31
|
-
|
|
32
|
-
impl Default for Timer {
|
|
33
|
-
fn default() -> Self {
|
|
34
|
-
Self::new()
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
impl Timer {
|
|
39
|
-
#[must_use]
|
|
40
|
-
pub fn new() -> Self {
|
|
41
|
-
Self {
|
|
42
|
-
start_time: Instant::now(),
|
|
43
|
-
$(
|
|
44
|
-
$phase: Duration::ZERO,
|
|
45
|
-
)*
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
pub fn set_global_timer(timer: Timer) {
|
|
50
|
-
*TIMER.lock().unwrap() = Some(timer);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
pub fn print_breakdown() {
|
|
54
|
-
if let Some(ref timer) = *TIMER.lock().unwrap() {
|
|
55
|
-
macro_rules! format_breakdown {
|
|
56
|
-
($name:expr, $duration:expr, $total:expr) => {
|
|
57
|
-
format!(
|
|
58
|
-
"{:<16} {:8.3}s ({:5.1}%)",
|
|
59
|
-
$name,
|
|
60
|
-
$duration.as_secs_f64(),
|
|
61
|
-
$duration.as_secs_f64() * 100.0 / $total.as_secs_f64()
|
|
62
|
-
)
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
let total_duration = timer.start_time.elapsed();
|
|
67
|
-
let mut accounted_time = Duration::ZERO;
|
|
68
|
-
$(
|
|
69
|
-
accounted_time += timer.$phase;
|
|
70
|
-
)*
|
|
71
|
-
let cleanup = total_duration - accounted_time;
|
|
72
|
-
|
|
73
|
-
println!();
|
|
74
|
-
println!("Timing breakdown");
|
|
75
|
-
|
|
76
|
-
$(
|
|
77
|
-
if timer.$phase != Duration::ZERO {
|
|
78
|
-
println!(" {}", format_breakdown!($label, timer.$phase, total_duration));
|
|
79
|
-
}
|
|
80
|
-
)*
|
|
81
|
-
|
|
82
|
-
println!(" {}", format_breakdown!("Cleanup", cleanup, total_duration));
|
|
83
|
-
println!(" Total: {:8.3}s", total_duration.as_secs_f64());
|
|
84
|
-
println!();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
#[macro_export]
|
|
90
|
-
macro_rules! time_it {
|
|
91
|
-
$(
|
|
92
|
-
($phase, $body:block) => {
|
|
93
|
-
{
|
|
94
|
-
let timer_enabled = {
|
|
95
|
-
let guard = $crate::stats::timer::TIMER.lock().unwrap();
|
|
96
|
-
guard.is_some()
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
if timer_enabled {
|
|
100
|
-
let start = std::time::Instant::now();
|
|
101
|
-
let result = $body;
|
|
102
|
-
let elapsed = start.elapsed();
|
|
103
|
-
|
|
104
|
-
if let Some(ref mut timer) = *$crate::stats::timer::TIMER.lock().unwrap() {
|
|
105
|
-
timer.$phase = elapsed;
|
|
106
|
-
}
|
|
107
|
-
result
|
|
108
|
-
} else {
|
|
109
|
-
$body
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
)*
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
pub use time_it;
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
make_timer! {
|
|
121
|
-
setup, "Initialization";
|
|
122
|
-
listing, "Listing";
|
|
123
|
-
indexing, "Indexing";
|
|
124
|
-
resolution, "Resolution";
|
|
125
|
-
integrity_check, "Integrity check";
|
|
126
|
-
querying, "Querying";
|
|
127
|
-
}
|
|
1
|
+
use std::sync::Mutex;
|
|
2
|
+
use std::time::{Duration, Instant};
|
|
3
|
+
|
|
4
|
+
/// Generates a global timer for measuring performance across different phases of execution in the main thread.
|
|
5
|
+
///
|
|
6
|
+
/// This macro creates:
|
|
7
|
+
/// - A `Timer` struct with fields for each defined phase
|
|
8
|
+
/// - A global `TIMER` static for tracking measurements
|
|
9
|
+
/// - A `time_it!` macro to measure and record individual phase durations
|
|
10
|
+
///
|
|
11
|
+
/// The timer is only created when running with the `--stats` flag.
|
|
12
|
+
///
|
|
13
|
+
/// Usage:
|
|
14
|
+
/// 1. To add a new phase, add an entry to the `make_timer!` invocation at the bottom of this file
|
|
15
|
+
/// 2. Wrap code blocks with `time_it!(phase_name, { ... })` to measure them
|
|
16
|
+
macro_rules! make_timer {
|
|
17
|
+
(
|
|
18
|
+
$(
|
|
19
|
+
$phase:ident, $label:literal;
|
|
20
|
+
)*
|
|
21
|
+
) => {
|
|
22
|
+
#[derive(Clone)]
|
|
23
|
+
pub struct Timer {
|
|
24
|
+
start_time: Instant,
|
|
25
|
+
$(
|
|
26
|
+
pub $phase: Duration,
|
|
27
|
+
)*
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
pub static TIMER: Mutex<Option<Timer>> = Mutex::new(None);
|
|
31
|
+
|
|
32
|
+
impl Default for Timer {
|
|
33
|
+
fn default() -> Self {
|
|
34
|
+
Self::new()
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
impl Timer {
|
|
39
|
+
#[must_use]
|
|
40
|
+
pub fn new() -> Self {
|
|
41
|
+
Self {
|
|
42
|
+
start_time: Instant::now(),
|
|
43
|
+
$(
|
|
44
|
+
$phase: Duration::ZERO,
|
|
45
|
+
)*
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
pub fn set_global_timer(timer: Timer) {
|
|
50
|
+
*TIMER.lock().unwrap() = Some(timer);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
pub fn print_breakdown() {
|
|
54
|
+
if let Some(ref timer) = *TIMER.lock().unwrap() {
|
|
55
|
+
macro_rules! format_breakdown {
|
|
56
|
+
($name:expr, $duration:expr, $total:expr) => {
|
|
57
|
+
format!(
|
|
58
|
+
"{:<16} {:8.3}s ({:5.1}%)",
|
|
59
|
+
$name,
|
|
60
|
+
$duration.as_secs_f64(),
|
|
61
|
+
$duration.as_secs_f64() * 100.0 / $total.as_secs_f64()
|
|
62
|
+
)
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let total_duration = timer.start_time.elapsed();
|
|
67
|
+
let mut accounted_time = Duration::ZERO;
|
|
68
|
+
$(
|
|
69
|
+
accounted_time += timer.$phase;
|
|
70
|
+
)*
|
|
71
|
+
let cleanup = total_duration - accounted_time;
|
|
72
|
+
|
|
73
|
+
println!();
|
|
74
|
+
println!("Timing breakdown");
|
|
75
|
+
|
|
76
|
+
$(
|
|
77
|
+
if timer.$phase != Duration::ZERO {
|
|
78
|
+
println!(" {}", format_breakdown!($label, timer.$phase, total_duration));
|
|
79
|
+
}
|
|
80
|
+
)*
|
|
81
|
+
|
|
82
|
+
println!(" {}", format_breakdown!("Cleanup", cleanup, total_duration));
|
|
83
|
+
println!(" Total: {:8.3}s", total_duration.as_secs_f64());
|
|
84
|
+
println!();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
#[macro_export]
|
|
90
|
+
macro_rules! time_it {
|
|
91
|
+
$(
|
|
92
|
+
($phase, $body:block) => {
|
|
93
|
+
{
|
|
94
|
+
let timer_enabled = {
|
|
95
|
+
let guard = $crate::stats::timer::TIMER.lock().unwrap();
|
|
96
|
+
guard.is_some()
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
if timer_enabled {
|
|
100
|
+
let start = std::time::Instant::now();
|
|
101
|
+
let result = $body;
|
|
102
|
+
let elapsed = start.elapsed();
|
|
103
|
+
|
|
104
|
+
if let Some(ref mut timer) = *$crate::stats::timer::TIMER.lock().unwrap() {
|
|
105
|
+
timer.$phase = elapsed;
|
|
106
|
+
}
|
|
107
|
+
result
|
|
108
|
+
} else {
|
|
109
|
+
$body
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
)*
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
pub use time_it;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
make_timer! {
|
|
121
|
+
setup, "Initialization";
|
|
122
|
+
listing, "Listing";
|
|
123
|
+
indexing, "Indexing";
|
|
124
|
+
resolution, "Resolution";
|
|
125
|
+
integrity_check, "Integrity check";
|
|
126
|
+
querying, "Querying";
|
|
127
|
+
}
|
data/rust/rubydex/src/stats.rs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
pub mod memory;
|
|
2
|
-
// TODO: When the rubydex is stable enough, turn this into a debug-only feature or revisit if we still need it.
|
|
3
|
-
pub mod orphan_report;
|
|
4
|
-
pub mod timer;
|
|
5
|
-
|
|
6
|
-
/// Helper function to compute percentage
|
|
7
|
-
#[allow(clippy::cast_precision_loss)]
|
|
8
|
-
#[must_use]
|
|
9
|
-
pub fn percentage(numerator: usize, denominator: usize) -> f64 {
|
|
10
|
-
(numerator as f64 / denominator as f64) * 100.0
|
|
11
|
-
}
|
|
1
|
+
pub mod memory;
|
|
2
|
+
// TODO: When the rubydex is stable enough, turn this into a debug-only feature or revisit if we still need it.
|
|
3
|
+
pub mod orphan_report;
|
|
4
|
+
pub mod timer;
|
|
5
|
+
|
|
6
|
+
/// Helper function to compute percentage
|
|
7
|
+
#[allow(clippy::cast_precision_loss)]
|
|
8
|
+
#[must_use]
|
|
9
|
+
pub fn percentage(numerator: usize, denominator: usize) -> f64 {
|
|
10
|
+
(numerator as f64 / denominator as f64) * 100.0
|
|
11
|
+
}
|