normalizeValue for RUBY_SPEC: idTypes EMPTY (bare identifiers never qualify); `block_argument` is a transparent layer; specials are the `method(:sym)` call form and hook-DSL `simple_symbol`s.
(&mut self, v: Node<'t>, from: u32, depth: u32)
| 872 | /// qualify); `block_argument` is a transparent layer; specials are the |
| 873 | /// `method(:sym)` call form and hook-DSL `simple_symbol`s. |
| 874 | fn normalize_fn_ref_value(&mut self, v: Node<'t>, from: u32, depth: u32) { |
| 875 | if depth > 4 { |
| 876 | return; |
| 877 | } |
| 878 | match v.kind() { |
| 879 | "block_argument" => { |
| 880 | for i in 0..v.named_child_count() { |
| 881 | if let Some(c) = v.named_child(i) { |
| 882 | self.normalize_fn_ref_value(c, from, depth + 1); |
| 883 | } |
| 884 | } |
| 885 | } |
| 886 | "call" => { |
| 887 | // `method(:target_cb)` — method field literally `method`, one |
| 888 | // simple_symbol argument. Candidate = bare symbol name at the |
| 889 | // SYMBOL node (gated at flush on defined-in-file ∪ imports). |
| 890 | let Some(method) = v.child_by_field_name("method") else { return }; |
| 891 | if self.text(method) != "method" { |
| 892 | return; |
| 893 | } |
| 894 | let Some(args) = v.child_by_field_name("arguments") else { return }; |
| 895 | if args.named_child_count() != 1 { |
| 896 | return; |
| 897 | } |
| 898 | let Some(sym) = args.named_child(0) else { return }; |
| 899 | if sym.kind() != "simple_symbol" { |
| 900 | return; |
| 901 | } |
| 902 | let name = self.text(sym).strip_prefix(':').unwrap_or(self.text(sym)); |
| 903 | if !name.is_empty() { |
| 904 | self.push_fn_ref_cand(from, name, sym); |
| 905 | } |
| 906 | } |
| 907 | "simple_symbol" => { |
| 908 | // Hook-DSL symbols (`before_action :authenticate`) → class- |
| 909 | // scoped `this.<sym>` candidates (always flushed). |
| 910 | let Some(call) = ruby_enclosing_call(v) else { return }; |
| 911 | let Some(method) = call.child_by_field_name("method") else { return }; |
| 912 | if !is_ruby_hook_call(self.text(method)) { |
| 913 | return; |
| 914 | } |
| 915 | let sym = self.text(v).strip_prefix(':').unwrap_or(self.text(v)); |
| 916 | if !ruby_sym_re().is_match(sym) { |
| 917 | return; |
| 918 | } |
| 919 | let name = format!("this.{sym}"); |
| 920 | self.push_fn_ref_cand(from, &name, v); |
| 921 | } |
| 922 | _ => {} |
| 923 | } |
| 924 | } |
| 925 | |
| 926 | fn push_fn_ref_cand(&mut self, from: u32, name: &str, node: Node) { |
| 927 | if name.is_empty() || is_stoplisted(name) { |
no test coverage detected