Skip to content

fix(index): index Ruby methods in modules and classes nested in modules - #801

Merged
ajianaz merged 1 commit into
developfrom
fix/ruby-module-methods
Nov 17, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/ruby-module-methods

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

What

Three fixes in the Tree-sitter extractor for Ruby (src/index/ast.rs):

  1. The first "module" arm, which only recorded the module, is removed; the second one, which also extracts the methods of the module, was unreachable and now runs (this also drops the targeted #[allow(unreachable_patterns)] added in refactor: remove the dead code hidden behind allow(dead_code) #798).
  2. New walk_ruby_nested: the classes and modules nested in a class or module body are visited (only class and module children, so a method is not indexed twice). Before, only the direct children of the file were walked.
  3. The target of a Ruby inheritance edge is the class name; it was < Base because the text of the superclass node starts with <, so the edge never matched the symbol Base.

Why

Ruby code lives in module Outer; class Inner; def run ... end; end; end, and none of it was indexed, so brain, callers and impact missed most of a Ruby project; the missing methods were a compiler warning that a module-wide allow hid. Closes #791.

Testing

  • Tests first, red before: methods of a module (with the module as parent), classes and modules nested two levels deep with their methods, a nested class indexed once, and the superclass edge to Base; a class-methods test guards the existing behavior.
  • Measured on a real Ruby project, Sinatra (147 Ruby files), same machine and offline, cora built before and after:
before after
symbols 184 853
methods 79 622
modules / classes 58 / 46 128 / 102
cora explore halt no symbols Sinatra::Base#halt found

The index time stays in the same range (a fraction of a second).

  • cargo test --features tree-sitter: 1546 passed, 0 failed; cargo fmt --all -- --check and clippy with -D warnings clean; Cora review of the staged diff: no findings.
  • Existing indexes need one cora index to pick this up; the CHANGELOG says so.

@ajianaz
ajianaz merged commit 6cd1bfb into develop Nov 17, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(index): Ruby methods in modules and classes nested in modules are not indexed

1 participant