MCPcopy
hub / github.com/lingodotdev/lingo.dev / getAstKey

Function getAstKey

packages/compiler/src/utils/ast-key.ts:5–20  ·  view source on GitHub ↗
(nodePath: NodePath)

Source from the content-addressed store, hash-verified

3import { traverse } from "../babel-interop";
4
5export function getAstKey(nodePath: NodePath) {
6 const keyChunks: any[] = [];
7
8 let current: NodePath | null = nodePath;
9 while (current) {
10 keyChunks.push(current.key);
11 current = current.parentPath;
12
13 if (t.isProgram(current?.node)) {
14 break;
15 }
16 }
17
18 const result = keyChunks.reverse().join("/");
19 return result;
20}
21
22export function getAstByKey(ast: t.File, key: string) {
23 const programPath = _getProgramNodePath(ast);

Callers 4

jsx-scope-flag.tsFile · 0.90
jsxScopesExportMutationFunction · 0.90
ast-key.spec.tsFile · 0.90

Calls 1

pushMethod · 0.65

Tested by

no test coverage detected