rubydex 0.2.3 → 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.
@@ -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 { graph: Graph::new() }
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::index_source(&mut self.graph, uri, &source, &LanguageId::Ruby);
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::ruby_indexer::RubyIndexer;
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
 
@@ -12,7 +12,7 @@ path = "src/main.rs"
12
12
  [dependencies]
13
13
  rubydex = { path = "../rubydex" }
14
14
  clap = { version = "4.5.16", features = ["derive"] }
15
- rmcp = { version = "0.15", features = ["server", "macros", "transport-io", "schemars"] }
15
+ rmcp = { version = "1.4", features = ["server", "macros", "transport-io", "schemars"] }
16
16
  tokio = { version = "1", features = ["macros", "rt", "io-std"] }
17
17
  serde = { version = "1", features = ["derive"] }
18
18
  serde_json = "1"
@@ -54,7 +54,11 @@ impl RubydexServer {
54
54
  }
55
55
 
56
56
  let mut graph = Graph::new();
57
- let errors = rubydex::indexing::index_files(&mut graph, file_paths);
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
  }
@@ -565,14 +569,13 @@ Pagination: tools that may return a high number of results include `total` for p
565
569
 
566
570
  Use Grep instead for: literal string search, log messages, comments, non-Ruby files, or content search rather than structural queries."#;
567
571
 
568
- #[tool_handler]
572
+ #[tool_handler(router = self.tool_router)]
569
573
  impl ServerHandler for RubydexServer {
570
574
  fn get_info(&self) -> ServerInfo {
571
- ServerInfo {
572
- instructions: Some(SERVER_INSTRUCTIONS.into()),
573
- capabilities: ServerCapabilities::builder().enable_tools().build(),
574
- ..Default::default()
575
- }
575
+ let mut info = ServerInfo::default();
576
+ info.instructions = Some(SERVER_INSTRUCTIONS.into());
577
+ info.capabilities = ServerCapabilities::builder().enable_tools().build();
578
+ info
576
579
  }
577
580
  }
578
581
 
@@ -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.3
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 00:00:00.000000000 Z
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