Find the `@template` definition for a template parameter name at the given cursor offset. Returns the closest (most specific) `TemplateParamDef` whose scope covers `cursor_offset` and whose name matches. Method-level template params are preferred over class-level ones because their `scope_start` is larger (they are defined later in the file).
(&self, name: &str, cursor_offset: u32)
| 616 | /// template params are preferred over class-level ones because their |
| 617 | /// `scope_start` is larger (they are defined later in the file). |
| 618 | pub fn find_template_def(&self, name: &str, cursor_offset: u32) -> Option<&TemplateParamDef> { |
| 619 | // Iterate in reverse so that narrower / later-defined scopes |
| 620 | // (method-level) are checked before broader ones (class-level). |
| 621 | self.template_defs.iter().rev().find(|d| { |
| 622 | d.name == name && cursor_offset >= d.scope_start && cursor_offset <= d.scope_end |
| 623 | }) |
| 624 | } |
| 625 | |
| 626 | /// Find the most recent definition of `$var_name` before |
| 627 | /// `cursor_offset` within the same scope. |