Skip to content

Index includes, prepends, and extends with RBS indexer#617

Merged
alexcrocha merged 1 commit intomainfrom
02-27-index_includes_prepends_and_extends_with_rbs_indexer
Mar 4, 2026
Merged

Index includes, prepends, and extends with RBS indexer#617
alexcrocha merged 1 commit intomainfrom
02-27-index_includes_prepends_and_extends_with_rbs_indexer

Conversation

@alexcrocha
Copy link
Contributor

@alexcrocha alexcrocha commented Feb 28, 2026

One more step towards #87.

This PR adds visit_include_node, visit_prepend_node, and visit_extend_node with a shared index_mixin helper. Mixins resolve into the ancestor chain matching the Ruby indexer.

Also moves assert_def_mixins_eq! to the shared test macros in local_graph_test.

Copy link
Contributor Author

alexcrocha commented Feb 28, 2026

@alexcrocha alexcrocha self-assigned this Feb 28, 2026
@alexcrocha alexcrocha added the enhancement New feature or request label Feb 28, 2026
@alexcrocha alexcrocha marked this pull request as ready for review February 28, 2026 00:34
@alexcrocha alexcrocha requested a review from a team as a code owner February 28, 2026 00:34
Copy link
Contributor

@soutaro soutaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Note: Rubydex doesn't index the comments for mixins.

include Bar::Baz
end
"
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test name says "qualified name" but assert_def_mixins_eq\! only checks the leaf segment ("Baz"), not the full Bar::Baz path. I wonder if we should assert the full path here to confirm the qualified name resolves correctly — maybe using assert_name_path_eq\! on the mixin's reference?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we should assert on the entire string Bar::Baz and not just Baz. Although, that's an existing limitation. If this involves updating too many tests, let's do it in a different PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take the suggestion and fix the macro to assert the full qualified path in a follow-up PR 👍

@@ -486,6 +537,62 @@ mod tests {
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Ruby indexer has index_includes_at_top_level to confirm top-level mixins are silently ignored. Should we add an equivalent here for the RBS indexer to document that behavior explicitly?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, is that the case? If so, we have a bug. Mixin operations at the top level impact Object:

module Foo; end

include Foo

puts Object.ancestors.inspect
# => [Object, Foo, Kernel, BasicObject]

Regardless, we should add the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including at the top level returns a parse error.

In RBS docs, mixins are not part of the declarations and I believe we're hitting the default case here.

Doesn't look like this is an issue for the RBS indexer

@@ -486,6 +537,62 @@ mod tests {
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, is that the case? If so, we have a bug. Mixin operations at the top level impact Object:

module Foo; end

include Foo

puts Object.ancestors.inspect
# => [Object, Foo, Kernel, BasicObject]

Regardless, we should add the test.

include Bar::Baz
end
"
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we should assert on the entire string Bar::Baz and not just Baz. Although, that's an existing limitation. If this involves updating too many tests, let's do it in a different PR.

@alexcrocha alexcrocha force-pushed the 02-27-index_includes_prepends_and_extends_with_rbs_indexer branch from a305dc9 to fab7552 Compare March 3, 2026 03:45
@alexcrocha alexcrocha force-pushed the 02-27-index_globals_with_rbs_indexer branch from f77fbfe to f7e2542 Compare March 3, 2026 03:45
Base automatically changed from 02-27-index_globals_with_rbs_indexer to main March 3, 2026 03:55
  This adds visit_include_node, visit_prepend_node, and
  visit_extend_node with a shared index_mixin helper. Mixins
  resolve into the ancestor chain matching the Ruby indexer.

  Also moves assert_def_mixins_eq! to the shared test macros
@alexcrocha alexcrocha force-pushed the 02-27-index_includes_prepends_and_extends_with_rbs_indexer branch from fab7552 to 19add0c Compare March 3, 2026 17:05
@alexcrocha alexcrocha merged commit 4e441be into main Mar 4, 2026
33 checks passed
@alexcrocha alexcrocha deleted the 02-27-index_includes_prepends_and_extends_with_rbs_indexer branch March 4, 2026 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants