feat(javascript): add local semantic call flow

This commit is contained in:
morluto
2026-07-22 23:22:55 +00:00
parent 74d1c7b274
commit a26a1c73df
8 changed files with 864 additions and 7 deletions
+7 -3
View File
@@ -42,8 +42,10 @@ export const collectSemanticCallable = (input: CollectCallableInput): void => {
reachSemanticLimit(state, "maxCallables");
return;
}
const callableId =
semanticCallableIdForNode(node) ?? "callable:unknown:-1:-1";
state.callables.push({
callableId: semanticCallableIdForNode(node) ?? "callable:unknown:-1:-1",
callableId,
kind,
name: callableName(node, parent),
containerScopeId: containerScope.scopeId,
@@ -60,6 +62,7 @@ export const collectSemanticCallable = (input: CollectCallableInput): void => {
limitsReached: [],
},
});
state.callableNodesById.set(callableId, node);
};
/** Collect one static import/export relationship for later composition. */
@@ -102,7 +105,7 @@ export const collectSemanticReferences = (
traverseJavaScriptAst(program, {
enter: (node, parent) => {
if (!t.isIdentifier(node) || parent === null) return;
const role = referenceRole(node, parent);
const role = semanticReferenceRole(node, parent);
if (role === null) return;
const key = `${String(node.start)}:${role}:${node.name}`;
if (seen.has(key)) return;
@@ -403,7 +406,8 @@ const declarationCallableId = (
: semanticCallableIdForNode(declarator.init);
};
const referenceRole = (
/** Classify one identifier occurrence consistently with semantic references. */
export const semanticReferenceRole = (
node: t.Identifier,
parent: t.Node,
): JavaScriptSemanticReference["role"] | null => {