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>)
| 1551 | /// function or method declaration, or for a func literal at file scope the |
| 1552 | /// outermost literal, else None. Mirrors goFnRefSite. |
| 1553 | fn go_fn_ref_site<'t>(node: Node<'t>) -> (usize, Option<Node<'t>>) { |
| 1554 | let mut scope = usize::MAX; |
| 1555 | let mut literal: Option<Node<'t>> = None; |
| 1556 | let mut cur = Some(node); |
| 1557 | while let Some(n) = cur { |
| 1558 | if scope == usize::MAX && GO_SCOPE_TYPES.contains(&n.kind()) { |
| 1559 | scope = n.id(); |
| 1560 | } |
| 1561 | if matches!(n.kind(), "function_declaration" | "method_declaration") { |
| 1562 | return (scope, Some(n)); |
| 1563 | } |
| 1564 | if n.kind() == "func_literal" { |
| 1565 | literal = Some(n); |
| 1566 | } |
| 1567 | cur = n.parent(); |
| 1568 | } |
| 1569 | (scope, literal) |
| 1570 | } |
| 1571 | |
| 1572 | /// The names among `names` that a function binds itself, as (unit id, name): |
| 1573 | /// its func literals' parameters, `:=`, `var` and `const`, range and |
no test coverage detected