Where a function-value candidate sits: the innermost scope node's id (usize::MAX when there is none) and the unit it is written in: the function or method declaration, or for a func literal at file scope the outermost literal, else None. Mirrors goFnRefSite.
(node: Node<'t>)
| 1523 | /// function or method declaration, or for a func literal at file scope the |
| 1524 | /// outermost literal, else None. Mirrors goFnRefSite. |
| 1525 | fn go_fn_ref_site<'t>(node: Node<'t>) -> (usize, Option<Node<'t>>) { |
| 1526 | let mut scope = usize::MAX; |
| 1527 | let mut literal: Option<Node<'t>> = None; |
| 1528 | let mut cur = Some(node); |
| 1529 | while let Some(n) = cur { |
| 1530 | if scope == usize::MAX && GO_SCOPE_TYPES.contains(&n.kind()) { |
| 1531 | scope = n.id(); |
| 1532 | } |
| 1533 | if matches!(n.kind(), "function_declaration" | "method_declaration") { |
| 1534 | return (scope, Some(n)); |
| 1535 | } |
| 1536 | if n.kind() == "func_literal" { |
| 1537 | literal = Some(n); |
| 1538 | } |
| 1539 | cur = n.parent(); |
| 1540 | } |
| 1541 | (scope, literal) |
| 1542 | } |
| 1543 | |
| 1544 | /// The names among `names` that a function binds itself, as (unit id, name): |
| 1545 | /// its func literals' parameters, `:=`, `var` and `const`, range and |
no test coverage detected