MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / go_fn_ref_site

Function go_fn_ref_site

codegraph-kernel/src/go.rs:1528–1545  ·  view source on GitHub ↗

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>)

Source from the content-addressed store, hash-verified

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

Callers 1

go_scoped_fn_ref_scopesFunction · 0.85

Calls 1

idMethod · 0.80

Tested by

no test coverage detected