rubydex 0.2.4 → 0.2.5
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/exe/rubydex_mcp +17 -0
- data/ext/rubydex/definition.c +56 -0
- data/ext/rubydex/extconf.rb +8 -0
- data/lib/rubydex/bin/rubydex_mcp.exe +0 -0
- data/lib/rubydex/declaration.rb +3 -3
- data/lib/rubydex/graph.rb +3 -1
- data/lib/rubydex/version.rb +1 -1
- data/rbi/rubydex.rbi +8 -2
- data/rust/rubydex/src/indexing/local_graph.rs +38 -0
- data/rust/rubydex/src/indexing/ruby_indexer.rs +6 -0
- data/rust/rubydex/src/indexing/ruby_indexer_tests.rs +5 -1
- data/rust/rubydex/src/indexing.rs +38 -12
- data/rust/rubydex/src/lib.rs +1 -0
- data/rust/rubydex/src/listing.rs +14 -3
- data/rust/rubydex/src/main.rs +27 -2
- data/rust/rubydex/src/model/definitions.rs +7 -18
- data/rust/rubydex/src/model/ids.rs +27 -1
- data/rust/rubydex/src/operation/applier.rs +519 -0
- data/rust/rubydex/src/operation/mod.rs +284 -0
- data/rust/rubydex/src/operation/printer.rs +260 -0
- data/rust/rubydex/src/operation/ruby_builder.rs +2915 -0
- data/rust/rubydex/src/resolution.rs +6 -1
- data/rust/rubydex/src/resolution_tests.rs +217 -209
- data/rust/rubydex/src/test_utils/graph_test.rs +19 -4
- data/rust/rubydex/src/test_utils/local_graph_test.rs +7 -6
- data/rust/rubydex-mcp/src/server.rs +5 -1
- data/rust/rubydex-sys/src/definition_api.rs +24 -0
- data/rust/rubydex-sys/src/graph_api.rs +1 -1
- metadata +9 -2
|
@@ -1,20 +1,34 @@
|
|
|
1
1
|
use super::normalize_indentation;
|
|
2
2
|
#[cfg(test)]
|
|
3
3
|
use crate::diagnostic::Rule;
|
|
4
|
-
use crate::indexing::{self, LanguageId};
|
|
4
|
+
use crate::indexing::{self, IndexerBackend, LanguageId};
|
|
5
5
|
use crate::model::graph::{Graph, NameDependent};
|
|
6
6
|
use crate::model::ids::{NameId, StringId};
|
|
7
7
|
use crate::resolution::Resolver;
|
|
8
8
|
|
|
9
|
-
#[derive(Default)]
|
|
10
9
|
pub struct GraphTest {
|
|
11
10
|
graph: Graph,
|
|
11
|
+
backend: IndexerBackend,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
impl Default for GraphTest {
|
|
15
|
+
fn default() -> Self {
|
|
16
|
+
Self::new()
|
|
17
|
+
}
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
impl GraphTest {
|
|
15
21
|
#[must_use]
|
|
16
22
|
pub fn new() -> Self {
|
|
17
|
-
Self
|
|
23
|
+
Self::new_with_backend(IndexerBackend::RubyIndexer)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#[must_use]
|
|
27
|
+
pub fn new_with_backend(backend: IndexerBackend) -> Self {
|
|
28
|
+
Self {
|
|
29
|
+
graph: Graph::new(),
|
|
30
|
+
backend,
|
|
31
|
+
}
|
|
18
32
|
}
|
|
19
33
|
|
|
20
34
|
#[must_use]
|
|
@@ -30,7 +44,8 @@ impl GraphTest {
|
|
|
30
44
|
/// Indexes a Ruby source
|
|
31
45
|
pub fn index_uri(&mut self, uri: &str, source: &str) {
|
|
32
46
|
let source = normalize_indentation(source);
|
|
33
|
-
indexing::
|
|
47
|
+
let local_graph = indexing::build_local_graph(uri.to_string(), &source, &LanguageId::Ruby, self.backend);
|
|
48
|
+
self.graph.consume_document_changes(local_graph);
|
|
34
49
|
}
|
|
35
50
|
|
|
36
51
|
/// Indexes an RBS source
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
use super::normalize_indentation;
|
|
2
2
|
use crate::indexing::local_graph::LocalGraph;
|
|
3
3
|
use crate::indexing::rbs_indexer::RBSIndexer;
|
|
4
|
-
use crate::indexing::
|
|
4
|
+
use crate::indexing::{IndexerBackend, LanguageId, build_local_graph};
|
|
5
5
|
use crate::model::definitions::Definition;
|
|
6
6
|
use crate::model::graph::NameDependent;
|
|
7
7
|
use crate::model::ids::{NameId, StringId, UriId};
|
|
@@ -19,13 +19,14 @@ pub struct LocalGraphTest {
|
|
|
19
19
|
impl LocalGraphTest {
|
|
20
20
|
#[must_use]
|
|
21
21
|
pub fn new(uri: &str, source: &str) -> Self {
|
|
22
|
+
Self::new_with_backend(uri, source, IndexerBackend::RubyIndexer)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
#[must_use]
|
|
26
|
+
pub fn new_with_backend(uri: &str, source: &str, backend: IndexerBackend) -> Self {
|
|
22
27
|
let uri = uri.to_string();
|
|
23
28
|
let source = normalize_indentation(source);
|
|
24
|
-
|
|
25
|
-
let mut indexer = RubyIndexer::new(uri.clone(), &source);
|
|
26
|
-
indexer.index();
|
|
27
|
-
let graph = indexer.local_graph();
|
|
28
|
-
|
|
29
|
+
let graph = build_local_graph(uri.clone(), &source, &LanguageId::Ruby, backend);
|
|
29
30
|
Self { uri, source, graph }
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -54,7 +54,11 @@ impl RubydexServer {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
let mut graph = Graph::new();
|
|
57
|
-
let errors = rubydex::indexing::index_files(
|
|
57
|
+
let errors = rubydex::indexing::index_files(
|
|
58
|
+
&mut graph,
|
|
59
|
+
file_paths,
|
|
60
|
+
rubydex::indexing::IndexerBackend::RubyIndexer,
|
|
61
|
+
);
|
|
58
62
|
for error in &errors {
|
|
59
63
|
eprintln!("Indexing error: {error}");
|
|
60
64
|
}
|
|
@@ -276,6 +276,30 @@ pub unsafe extern "C" fn rdx_definition_declaration(pointer: GraphPointer, defin
|
|
|
276
276
|
})
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
+
/// Returns the lexical nesting definition id for the given definition, or NULL if there is no lexical nesting.
|
|
280
|
+
/// Caller must free the returned pointer with `free_u64`.
|
|
281
|
+
///
|
|
282
|
+
/// # Safety
|
|
283
|
+
/// - `pointer` must be a valid pointer previously returned by `rdx_graph_new`.
|
|
284
|
+
/// - `definition_id` must be a valid definition id.
|
|
285
|
+
///
|
|
286
|
+
/// # Panics
|
|
287
|
+
/// This function will panic if the definition cannot be found.
|
|
288
|
+
#[unsafe(no_mangle)]
|
|
289
|
+
pub unsafe extern "C" fn rdx_definition_lexical_nesting_id(pointer: GraphPointer, definition_id: u64) -> *const u64 {
|
|
290
|
+
with_graph(pointer, |graph| {
|
|
291
|
+
let def_id = DefinitionId::new(definition_id);
|
|
292
|
+
let Some(defn) = graph.definitions().get(&def_id) else {
|
|
293
|
+
panic!("Definition not found: {definition_id:?}");
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
match defn.lexical_nesting_id() {
|
|
297
|
+
Some(lexical_nesting_id) => Box::into_raw(Box::new(**lexical_nesting_id)).cast_const(),
|
|
298
|
+
None => ptr::null(),
|
|
299
|
+
}
|
|
300
|
+
})
|
|
301
|
+
}
|
|
302
|
+
|
|
279
303
|
/// Creates a new iterator over definition IDs for a given declaration by snapshotting the current set of IDs.
|
|
280
304
|
///
|
|
281
305
|
/// # Panics
|
|
@@ -233,7 +233,7 @@ pub unsafe extern "C" fn rdx_index_all(
|
|
|
233
233
|
|
|
234
234
|
with_mut_graph(pointer, |graph| {
|
|
235
235
|
let (file_paths, listing_errors) = listing::collect_file_paths(file_paths, graph.excluded_paths());
|
|
236
|
-
let indexing_errors = indexing::index_files(graph, file_paths);
|
|
236
|
+
let indexing_errors = indexing::index_files(graph, file_paths, indexing::IndexerBackend::RubyIndexer);
|
|
237
237
|
|
|
238
238
|
let all_errors: Vec<String> = listing_errors
|
|
239
239
|
.into_iter()
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubydex
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shopify
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-05-
|
|
11
|
+
date: 2026-05-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A high-performance static analysis suite for Ruby, built in Rust with
|
|
14
14
|
Ruby APIs
|
|
@@ -16,6 +16,7 @@ email:
|
|
|
16
16
|
- ruby@shopify.com
|
|
17
17
|
executables:
|
|
18
18
|
- rdx
|
|
19
|
+
- rubydex_mcp
|
|
19
20
|
extensions:
|
|
20
21
|
- ext/rubydex/extconf.rb
|
|
21
22
|
extra_rdoc_files: []
|
|
@@ -24,6 +25,7 @@ files:
|
|
|
24
25
|
- README.md
|
|
25
26
|
- THIRD_PARTY_LICENSES.html
|
|
26
27
|
- exe/rdx
|
|
28
|
+
- exe/rubydex_mcp
|
|
27
29
|
- ext/rubydex/declaration.c
|
|
28
30
|
- ext/rubydex/declaration.h
|
|
29
31
|
- ext/rubydex/definition.c
|
|
@@ -46,6 +48,7 @@ files:
|
|
|
46
48
|
- ext/rubydex/utils.c
|
|
47
49
|
- ext/rubydex/utils.h
|
|
48
50
|
- lib/rubydex.rb
|
|
51
|
+
- lib/rubydex/bin/rubydex_mcp.exe
|
|
49
52
|
- lib/rubydex/comment.rb
|
|
50
53
|
- lib/rubydex/declaration.rb
|
|
51
54
|
- lib/rubydex/diagnostic.rb
|
|
@@ -114,6 +117,10 @@ files:
|
|
|
114
117
|
- rust/rubydex/src/model/string_ref.rs
|
|
115
118
|
- rust/rubydex/src/model/visibility.rs
|
|
116
119
|
- rust/rubydex/src/offset.rs
|
|
120
|
+
- rust/rubydex/src/operation/applier.rs
|
|
121
|
+
- rust/rubydex/src/operation/mod.rs
|
|
122
|
+
- rust/rubydex/src/operation/printer.rs
|
|
123
|
+
- rust/rubydex/src/operation/ruby_builder.rs
|
|
117
124
|
- rust/rubydex/src/position.rs
|
|
118
125
|
- rust/rubydex/src/query.rs
|
|
119
126
|
- rust/rubydex/src/resolution.rs
|