normalizeValue with GO_SPEC's transparent layers (literal_element, expression_list — both fan out to named children).
(&mut self, v: Node<'t>, from: u32, depth: u32, container: Node<'t>)
| 1204 | /// normalizeValue with GO_SPEC's transparent layers (literal_element, |
| 1205 | /// expression_list — both fan out to named children). |
| 1206 | fn normalize_fn_ref_value(&mut self, v: Node<'t>, from: u32, depth: u32, container: Node<'t>) { |
| 1207 | stack_guard!(); |
| 1208 | if depth > 4 { |
| 1209 | return; |
| 1210 | } |
| 1211 | match v.kind() { |
| 1212 | "identifier" => { |
| 1213 | let name = self.text(v).to_string(); |
| 1214 | if name.is_empty() || is_stoplisted(&name) { |
| 1215 | return; |
| 1216 | } |
| 1217 | let p = v.start_position(); |
| 1218 | self.fn_ref_cands.push(Cand { |
| 1219 | from, |
| 1220 | name, |
| 1221 | line: p.row as u32 + 1, |
| 1222 | column_byte: v.start_byte(), |
| 1223 | row: p.row, |
| 1224 | node: container, |
| 1225 | }); |
| 1226 | } |
| 1227 | // #1820: preserve the receiver of a method value. The name is |
| 1228 | // rebuilt from operand and field, as normalizeSpecial does, so a |
| 1229 | // comment or line break beside the dot keeps the candidate. |
| 1230 | // NAME_STOPLIST applies to the whole name and holds no dotted |
| 1231 | // word, so it never drops one: `raft.None` is a candidate even |
| 1232 | // though a bare `None` is not. |
| 1233 | "selector_expression" => { |
| 1234 | let (Some(operand), Some(field)) = |
| 1235 | (v.child_by_field_name("operand"), v.child_by_field_name("field")) |
| 1236 | else { |
| 1237 | return; |
| 1238 | }; |
| 1239 | let name = format!("{}.{}", self.text(operand), self.text(field)); |
| 1240 | if !name.split('.').all(|part| { |
| 1241 | !part.is_empty() && part.chars().enumerate().all(|(i, c)| { |
| 1242 | c == '_' || c.is_ascii_alphabetic() || (i > 0 && c.is_ascii_digit()) |
| 1243 | }) |
| 1244 | }) { return; } |
| 1245 | let p = field.start_position(); |
| 1246 | self.fn_ref_cands.push(Cand { |
| 1247 | from, |
| 1248 | name, |
| 1249 | line: p.row as u32 + 1, |
| 1250 | column_byte: field.start_byte(), |
| 1251 | row: p.row, |
| 1252 | node: container, |
| 1253 | }); |
| 1254 | } |
| 1255 | "literal_element" | "expression_list" => { |
| 1256 | for i in 0..v.named_child_count() { |
| 1257 | if let Some(c) = v.named_child(i) { |
| 1258 | self.normalize_fn_ref_value(c, from, depth + 1, container); |
| 1259 | } |
| 1260 | } |
| 1261 | } |
| 1262 | _ => {} |
| 1263 | } |
no test coverage detected