| 220 | } |
| 221 | |
| 222 | fn scope(mut node: Node<'_>, source: &str) -> (Vec<String>, Option<String>) { |
| 223 | let (mut parts, mut receiver) = (Vec::new(), None); |
| 224 | let mut nested_function = false; |
| 225 | while let Some(parent) = node.parent() { |
| 226 | if let Some(name) = owner(parent, source) { |
| 227 | if receiver.is_none() && !nested_function { |
| 228 | receiver = Some(name.clone()); |
| 229 | } |
| 230 | parts.push(name); |
| 231 | } else if callable(parent) |
| 232 | || matches!( |
| 233 | parent.kind(), |
| 234 | "mod_item" | "namespace_definition" | "internal_module" |
| 235 | ) |
| 236 | { |
| 237 | if let Some(name) = parent.child_by_field_name("name") { |
| 238 | parts.push(text(name, source).into()); |
| 239 | } |
| 240 | if callable(parent) { |
| 241 | nested_function = true; |
| 242 | } |
| 243 | } |
| 244 | node = parent; |
| 245 | } |
| 246 | parts.reverse(); |
| 247 | (parts, receiver) |
| 248 | } |
| 249 | |
| 250 | fn module_scope(mut node: Node<'_>, source: &str) -> Vec<String> { |
| 251 | let mut parts = Vec::new(); |