getFunctionReferencedBeforeDeclarationAtTopLevel() — react Function Reference
Architecture documentation for the getFunctionReferencedBeforeDeclarationAtTopLevel() function in Program.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 58e83968_5fd8_9e9f_e4be_1f50e95f54dc["getFunctionReferencedBeforeDeclarationAtTopLevel()"] 9aa4477d_960b_1ea1_b6d9_36076aaa70bd["Program.ts"] 58e83968_5fd8_9e9f_e4be_1f50e95f54dc -->|defined in| 9aa4477d_960b_1ea1_b6d9_36076aaa70bd 11c511ca_2971_a23f_cfd6_2897f2fe1b13["applyCompiledFunctions()"] 11c511ca_2971_a23f_cfd6_2897f2fe1b13 -->|calls| 58e83968_5fd8_9e9f_e4be_1f50e95f54dc 1351f300_d3f0_8ef1_7520_1bc143225b34["getFunctionName()"] 58e83968_5fd8_9e9f_e4be_1f50e95f54dc -->|calls| 1351f300_d3f0_8ef1_7520_1bc143225b34 8e8b7ee8_d3c2_f98d_17e1_c5ff5fff1940["map()"] 58e83968_5fd8_9e9f_e4be_1f50e95f54dc -->|calls| 8e8b7ee8_d3c2_f98d_17e1_c5ff5fff1940 style 58e83968_5fd8_9e9f_e4be_1f50e95f54dc fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts lines 1366–1425
function getFunctionReferencedBeforeDeclarationAtTopLevel(
program: NodePath<t.Program>,
fns: Array<CompileResult>,
): Set<CompileResult> {
const fnNames = new Map<string, {id: t.Identifier; fn: CompileResult}>(
fns
.map<[NodePath<t.Expression> | null, CompileResult]>(fn => [
getFunctionName(fn.originalFn),
fn,
])
.filter(
(entry): entry is [NodePath<t.Identifier>, CompileResult] =>
!!entry[0] && entry[0].isIdentifier(),
)
.map(entry => [entry[0].node.name, {id: entry[0].node, fn: entry[1]}]),
);
const referencedBeforeDeclaration = new Set<CompileResult>();
program.traverse({
TypeAnnotation(path) {
path.skip();
},
TSTypeAnnotation(path) {
path.skip();
},
TypeAlias(path) {
path.skip();
},
TSTypeAliasDeclaration(path) {
path.skip();
},
Identifier(id) {
const fn = fnNames.get(id.node.name);
// We're not tracking this identifier.
if (!fn) {
return;
}
/*
* We've reached the declaration, hoisting is no longer possible, stop
* checking for this component name.
*/
if (id.node === fn.id) {
fnNames.delete(id.node.name);
return;
}
const scope = id.scope.getFunctionParent();
/*
* A null scope means there's no function scope, which means we're at the
* top level scope.
*/
if (scope === null && id.isReferencedIdentifier()) {
referencedBeforeDeclaration.add(fn.fn);
}
},
});
return referencedBeforeDeclaration;
}
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does getFunctionReferencedBeforeDeclarationAtTopLevel() do?
getFunctionReferencedBeforeDeclarationAtTopLevel() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts.
Where is getFunctionReferencedBeforeDeclarationAtTopLevel() defined?
getFunctionReferencedBeforeDeclarationAtTopLevel() is defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts at line 1366.
What does getFunctionReferencedBeforeDeclarationAtTopLevel() call?
getFunctionReferencedBeforeDeclarationAtTopLevel() calls 2 function(s): getFunctionName, map.
What calls getFunctionReferencedBeforeDeclarationAtTopLevel()?
getFunctionReferencedBeforeDeclarationAtTopLevel() is called by 1 function(s): applyCompiledFunctions.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free