Conversation
soutaro
commented
Mar 4, 2026
- Index method
- Index method parameters
- Add test to confirm resolution works
| let line_text = if i == 0 { | ||
| line.to_string() | ||
| } else { | ||
| line[indent_len..].to_string() |
There was a problem hiding this comment.
This can panic if a subsequent comment line has fewer leading spaces than indent_len. For example, if the first line has 4 spaces of indentation but a later line accidentally starts at column 0, line[4..] would panic with an out-of-bounds string slice.
Might be safer to use line.get(indent_len..).unwrap_or(line) here:
| line[indent_len..].to_string() | |
| line.get(indent_len..).unwrap_or(line).to_string() |
| } | ||
|
|
||
| fn visit_method_definition_node(&mut self, def_node: &node::MethodDefinitionNode) { | ||
| // Singleton and singleton_instance methods are not indexed for now. |
There was a problem hiding this comment.
We should have the mechanisms for indexing singleton methods. Not sure what singleton_instance method means.
There was a problem hiding this comment.
I’ve been working on instance method support because it's easier to finish.
I’ll work on singleton method support once I finish indexing instance methods.
singleton_instance is for module_function. (Yeah, that makes things even more complicated. 😄)
| comments, | ||
| flags, | ||
| lexical_nesting_id, | ||
| Vec::new(), |
There was a problem hiding this comment.
I was reflecting on this for the parameters. I think we have a few options, but my suggestion is that we make parameters in MethodDefinition an enum.
enum MethodParameters {
Simple(Signature),
Overloaded(Vec<Signature>),
}
// where Signature just holds the vector of parameters for convenienceThe reason I feel like this is the best option is because a lot of methods in RBS will not have overloads. If we were to create a separate RBSMethodDefinition that always accepted a vector of signatures, we would pay the price of allocating vectors for a bunch of RBS methods that don't have overloads.
I believe we'll reduce our memory usage and keep the implementation simple by simply allowing method defs to accept a single signature or overloads.