rubydex 0.2.4 → 0.2.6

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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -16
  3. data/THIRD_PARTY_LICENSES.html +6 -6
  4. data/exe/rubydex_mcp +17 -0
  5. data/ext/rubydex/definition.c +89 -2
  6. data/ext/rubydex/document.c +36 -0
  7. data/ext/rubydex/extconf.rb +8 -0
  8. data/ext/rubydex/graph.c +32 -18
  9. data/ext/rubydex/handle.h +21 -5
  10. data/lib/rubydex/bin/rubydex_mcp.exe +0 -0
  11. data/lib/rubydex/declaration.rb +3 -3
  12. data/lib/rubydex/errors.rb +8 -0
  13. data/lib/rubydex/graph.rb +3 -1
  14. data/lib/rubydex/location.rb +24 -0
  15. data/lib/rubydex/version.rb +1 -1
  16. data/lib/rubydex.rb +1 -0
  17. data/rbi/rubydex.rbi +37 -14
  18. data/rust/Cargo.lock +3 -3
  19. data/rust/rubydex/Cargo.toml +7 -1
  20. data/rust/rubydex/src/dot.rs +609 -0
  21. data/rust/rubydex/src/indexing/local_graph.rs +38 -0
  22. data/rust/rubydex/src/indexing/rbs_indexer.rs +19 -1
  23. data/rust/rubydex/src/indexing/ruby_indexer.rs +10 -0
  24. data/rust/rubydex/src/indexing/ruby_indexer_tests.rs +5 -1
  25. data/rust/rubydex/src/indexing.rs +38 -12
  26. data/rust/rubydex/src/lib.rs +2 -1
  27. data/rust/rubydex/src/listing.rs +14 -3
  28. data/rust/rubydex/src/main.rs +35 -7
  29. data/rust/rubydex/src/model/built_in.rs +5 -2
  30. data/rust/rubydex/src/model/comment.rs +2 -0
  31. data/rust/rubydex/src/model/declaration.rs +1 -0
  32. data/rust/rubydex/src/model/definitions.rs +20 -19
  33. data/rust/rubydex/src/model/document.rs +2 -0
  34. data/rust/rubydex/src/model/encoding.rs +2 -0
  35. data/rust/rubydex/src/model/graph.rs +51 -13
  36. data/rust/rubydex/src/model/identity_maps.rs +3 -0
  37. data/rust/rubydex/src/model/ids.rs +27 -1
  38. data/rust/rubydex/src/model/keywords.rs +3 -0
  39. data/rust/rubydex/src/model/name.rs +2 -0
  40. data/rust/rubydex/src/model/string_ref.rs +2 -0
  41. data/rust/rubydex/src/model/visibility.rs +3 -0
  42. data/rust/rubydex/src/operation/applier.rs +520 -0
  43. data/rust/rubydex/src/operation/mod.rs +285 -0
  44. data/rust/rubydex/src/operation/printer.rs +260 -0
  45. data/rust/rubydex/src/operation/ruby_builder.rs +2919 -0
  46. data/rust/rubydex/src/query.rs +114 -33
  47. data/rust/rubydex/src/resolution.rs +22 -9
  48. data/rust/rubydex/src/resolution_tests.rs +349 -209
  49. data/rust/rubydex/src/test_utils/graph_test.rs +19 -4
  50. data/rust/rubydex/src/test_utils/local_graph_test.rs +7 -6
  51. data/rust/rubydex/tests/cli.rs +17 -61
  52. data/rust/rubydex-mcp/Cargo.toml +9 -3
  53. data/rust/rubydex-mcp/src/server.rs +5 -1
  54. data/rust/rubydex-sys/Cargo.toml +9 -2
  55. data/rust/rubydex-sys/src/definition_api.rs +96 -2
  56. data/rust/rubydex-sys/src/document_api.rs +28 -0
  57. data/rust/rubydex-sys/src/graph_api.rs +2 -4
  58. metadata +11 -4
  59. data/rust/rubydex/src/visualization/dot.rs +0 -192
  60. data/rust/rubydex/src/visualization.rs +0 -6
data/rbi/rubydex.rbi CHANGED
@@ -104,8 +104,8 @@ class Rubydex::Namespace < Rubydex::Declaration
104
104
  sig { returns(T::Enumerable[Rubydex::Namespace]) }
105
105
  def ancestors; end
106
106
 
107
- sig { params(ancestor_name: String).returns(T::Boolean) }
108
- def has_ancestor?(ancestor_name); end
107
+ sig { params(ancestor_names: String).returns(T::Boolean) }
108
+ def has_ancestor?(*ancestor_names); end
109
109
 
110
110
  sig { returns(T::Enumerable[Rubydex::Namespace]) }
111
111
  def descendants; end
@@ -152,6 +152,12 @@ class Rubydex::Definition
152
152
  sig { returns(T.nilable(Rubydex::Declaration)) }
153
153
  def declaration; end
154
154
 
155
+ sig { returns(T.nilable(Rubydex::Definition)) }
156
+ def lexical_owner; end
157
+
158
+ sig { returns(T::Array[Rubydex::Definition]) }
159
+ def lexical_nesting; end
160
+
155
161
  class << self
156
162
  private
157
163
 
@@ -168,7 +174,10 @@ class Rubydex::ConstantDefinition < Rubydex::Definition; end
168
174
  class Rubydex::GlobalVariableAliasDefinition < Rubydex::Definition; end
169
175
  class Rubydex::GlobalVariableDefinition < Rubydex::Definition; end
170
176
  class Rubydex::InstanceVariableDefinition < Rubydex::Definition; end
171
- class Rubydex::MethodAliasDefinition < Rubydex::Definition; end
177
+ class Rubydex::MethodAliasDefinition < Rubydex::Definition
178
+ sig { returns(T.nilable(Rubydex::Method)) }
179
+ def target; end
180
+ end
172
181
  class Rubydex::MethodDefinition < Rubydex::Definition; end
173
182
 
174
183
  class Rubydex::ModuleDefinition < Rubydex::Definition
@@ -240,6 +249,9 @@ class Rubydex::Document
240
249
  sig { returns(T::Enumerable[Rubydex::Definition]) }
241
250
  def definitions; end
242
251
 
252
+ sig { returns(T::Enumerable[Rubydex::MethodReference]) }
253
+ def method_references; end
254
+
243
255
  sig { returns(String) }
244
256
  def uri; end
245
257
 
@@ -251,6 +263,7 @@ class Rubydex::Document
251
263
  end
252
264
 
253
265
  class Rubydex::Error < StandardError; end
266
+ class Rubydex::AliasCycleError < Rubydex::Error; end
254
267
 
255
268
  class Rubydex::Failure
256
269
  sig { params(message: String).void }
@@ -338,48 +351,48 @@ class Rubydex::Graph
338
351
  # Returns completion candidates for an expression context. This includes all keywords, constants, methods, instance
339
352
  # variables, class variables and global variables reachable from the current lexical scope and self type.
340
353
  #
341
- # The nesting array represents the lexical scope stack. The optional `self_receiver` keyword argument overrides the
354
+ # The nesting array represents the lexical scope stack. The required `self_receiver` keyword argument overrides the
342
355
  # self type independently of the lexical scope (e.g., `"Foo::<Foo>"` for `def Foo.bar`). This distinction is important
343
356
  # because constants and class variables are always attached to the lexical scope. Meanwhile, methods and instance
344
- # variables are attached to the type of `self` and those don't always match.
357
+ # variables are attached to the type of `self` and those don't always match. Pass `nil` when the self type is unknown
345
358
  sig do
346
359
  params(
347
360
  nesting: T::Array[String],
348
361
  self_receiver: T.nilable(String),
349
362
  ).returns(T::Array[T.any(Rubydex::Declaration, Rubydex::Keyword)])
350
363
  end
351
- def complete_expression(nesting, self_receiver: nil); end
364
+ def complete_expression(nesting, self_receiver:); end
352
365
 
353
366
  # Returns completion candidates after a namespace access operator (e.g., `Foo::`). This includes all constants and
354
367
  # singleton methods for the namespace and its ancestors.
355
368
  #
356
- # The optional `self_receiver` kwarg is the caller's runtime self type. It's used to filter visibility-restricted
357
- # singleton methods (e.g., `private_class_method`). Pass `nil` (the default) for top-level/script scope.
369
+ # The required `self_receiver` kwarg is the caller's runtime self type. It's used to filter visibility-restricted
370
+ # singleton methods (e.g., `private_class_method`). Pass `nil` for top-level/script scope.
358
371
  sig do
359
372
  params(
360
373
  name: String,
361
374
  self_receiver: T.nilable(String),
362
375
  ).returns(T::Array[Rubydex::Declaration])
363
376
  end
364
- def complete_namespace_access(name, self_receiver: nil); end
377
+ def complete_namespace_access(name, self_receiver:); end
365
378
 
366
379
  # Returns completion candidates after a method call operator (e.g., `foo.`). This includes all methods that exist on
367
380
  # the type of the receiver and its ancestors.
368
381
  #
369
- # The optional `self_receiver` kwarg is the caller's runtime self type. It's used for visibility checks for `private`
370
- # and `protected` methods. Pass `nil` (the default) for top-level/script scope.
382
+ # The required `self_receiver` kwarg is the caller's runtime self type. It's used for visibility checks for `private`
383
+ # and `protected` methods. Pass `nil` for top-level/script scope.
371
384
  sig do
372
385
  params(
373
386
  name: String,
374
387
  self_receiver: T.nilable(String),
375
388
  ).returns(T::Array[Rubydex::Method])
376
389
  end
377
- def complete_method_call(name, self_receiver: nil); end
390
+ def complete_method_call(name, self_receiver:); end
378
391
 
379
392
  # Returns completion candidates inside a method call's argument list (e.g., `foo.bar(|)`). This includes everything
380
393
  # that expression completion provides plus keyword argument names of the method being called.
381
394
  #
382
- # See `complete_expression` for the semantics of `nesting` and `self_receiver`.
395
+ # See `complete_expression` for the semantics of `nesting` and `self_receiver` (required, may be `nil`).
383
396
  sig do
384
397
  params(
385
398
  name: String,
@@ -387,7 +400,7 @@ class Rubydex::Graph
387
400
  self_receiver: T.nilable(String),
388
401
  ).returns(T::Array[T.any(Rubydex::Declaration, Rubydex::Keyword, Rubydex::KeywordParameter)])
389
402
  end
390
- def complete_method_argument(name, nesting, self_receiver: nil); end
403
+ def complete_method_argument(name, nesting, self_receiver:); end
391
404
 
392
405
  private
393
406
 
@@ -405,6 +418,11 @@ class Rubydex::Graph
405
418
  end
406
419
 
407
420
  class Rubydex::DisplayLocation < Rubydex::Location
421
+ class << self
422
+ sig { params(prism_location: Prism::Location, uri: String).returns(T.noreturn) }
423
+ def from_prism(prism_location, uri:); end
424
+ end
425
+
408
426
  sig { returns([String, Integer, Integer, Integer, Integer]) }
409
427
  def comparable_values; end
410
428
 
@@ -418,6 +436,11 @@ end
418
436
  class Rubydex::Location
419
437
  include ::Comparable
420
438
 
439
+ class << self
440
+ sig { params(prism_location: Prism::Location, uri: String).returns(Rubydex::Location) }
441
+ def from_prism(prism_location, uri:); end
442
+ end
443
+
421
444
  sig do
422
445
  params(
423
446
  uri: String,
data/rust/Cargo.lock CHANGED
@@ -1048,7 +1048,7 @@ dependencies = [
1048
1048
 
1049
1049
  [[package]]
1050
1050
  name = "rubydex"
1051
- version = "0.1.0"
1051
+ version = "0.2.6"
1052
1052
  dependencies = [
1053
1053
  "assert_cmd",
1054
1054
  "bitflags",
@@ -1072,7 +1072,7 @@ dependencies = [
1072
1072
 
1073
1073
  [[package]]
1074
1074
  name = "rubydex-mcp"
1075
- version = "0.1.0"
1075
+ version = "0.2.6"
1076
1076
  dependencies = [
1077
1077
  "assert_cmd",
1078
1078
  "clap",
@@ -1087,7 +1087,7 @@ dependencies = [
1087
1087
 
1088
1088
  [[package]]
1089
1089
  name = "rubydex-sys"
1090
- version = "0.1.0"
1090
+ version = "0.2.6"
1091
1091
  dependencies = [
1092
1092
  "cbindgen",
1093
1093
  "libc",
@@ -1,9 +1,15 @@
1
1
  [package]
2
2
  name = "rubydex"
3
- version = "0.1.0"
3
+ version = "0.2.6"
4
4
  edition = "2024"
5
5
  rust-version = "1.89.0"
6
6
  license = "MIT"
7
+ description = "High-performance Ruby code indexing and static analysis library."
8
+ homepage = "https://github.com/Shopify/rubydex"
9
+ repository = "https://github.com/Shopify/rubydex"
10
+ readme = "README.md"
11
+ keywords = ["ruby", "indexing", "static-analysis"]
12
+ categories = ["development-tools"]
7
13
 
8
14
  [[bin]]
9
15
  name = "rubydex_cli"