mirror of
https://github.com/morluto/rea.git
synced 2026-11-09 16:26:36 +00:00
refactor(javascript): share Babel child traversal
This commit is contained in:
1 parent
617cd84d27
commit
0f10499245
3 files changed
+13
-46
No files matched your search
@@ -26,7 +26,10 @@ import {
|
||||
import { evaluateSemanticExpression } from "./javascriptSemanticValues.js";
|
||||
import { range } from "./javascriptStaticAnalysisHelpers.js";
|
||||
import { semanticReturnCoverage } from "./javascriptSemanticCoverage.js";
|
||||
import { traverseJavaScriptAst } from "./javascriptSemanticTraversal.js";
|
||||
import {
|
||||
childNodes,
|
||||
traverseJavaScriptAst,
|
||||
} from "./javascriptSemanticTraversal.js";
|
||||
|
||||
interface ReturnExpression {
|
||||
readonly node: t.Node | null;
|
||||
@@ -145,15 +148,6 @@ const directReturnExpressions = (callable: t.Node): ReturnExpression[] => {
|
||||
return output;
|
||||
};
|
||||
|
||||
const childNodes = (node: t.Node): t.Node[] =>
|
||||
(t.VISITOR_KEYS[node.type] ?? []).flatMap((key) => {
|
||||
const value: unknown = Reflect.get(node, key);
|
||||
if (t.isNode(value)) return [value];
|
||||
return Array.isArray(value)
|
||||
? value.filter((item): item is t.Node => t.isNode(item))
|
||||
: [];
|
||||
});
|
||||
|
||||
const callableIdsForBinding = (
|
||||
binding: JavaScriptSemanticBindingState,
|
||||
state: JavaScriptSemanticAnalysisState,
|
||||
|
||||
Reference in new issue
Block a user