mirror of
https://github.com/morluto/rea
synced 2026-10-27 06:33:32 -04:00
feat(javascript): retain queryable static route inventories (#6019)
This commit is contained in:
@@ -22,6 +22,7 @@ import {
|
||||
} from "./javascriptSemanticState.js";
|
||||
import {
|
||||
semanticStaticPropertyKey,
|
||||
semanticMemberChain,
|
||||
unwrapJavaScriptExpression,
|
||||
} from "./javascriptAstValues.js";
|
||||
import { semanticPropertyPathKeyMatches } from "./javascriptSemanticPropertyPaths.js";
|
||||
@@ -1354,32 +1355,6 @@ export const semanticGlobalProcessPathOrigin = (
|
||||
};
|
||||
};
|
||||
|
||||
/** Strip a static member chain, returning its root expression and member path. */
|
||||
export const semanticMemberChain = (
|
||||
node: t.Node | null | undefined,
|
||||
):
|
||||
| { readonly root: t.Node | null | undefined; readonly members: string[] }
|
||||
| undefined => {
|
||||
const members: string[] = [];
|
||||
let current = node;
|
||||
while (current !== null && current !== undefined) {
|
||||
current = unwrapJavaScriptExpression(current).node;
|
||||
if (
|
||||
!t.isMemberExpression(current) &&
|
||||
!t.isOptionalMemberExpression(current)
|
||||
)
|
||||
break;
|
||||
const member = semanticStaticPropertyKey(
|
||||
current.property,
|
||||
current.computed,
|
||||
);
|
||||
if (member === null || !t.isNode(current.object)) return undefined;
|
||||
members.push(member);
|
||||
current = current.object;
|
||||
}
|
||||
return { root: current, members: members.reverse() };
|
||||
};
|
||||
|
||||
/** Recover an unshadowed literal require origin and its exact member path. */
|
||||
export const semanticRequireOrigin = (
|
||||
node: t.Node | null | undefined,
|
||||
|
||||
Reference in New Issue
Block a user