MCPcopy Create free account
hub / github.com/Snapchat/Valdi / getFunctionAST

Method getFunctionAST

compiler/companion/src/Workspace.ts:460–478  ·  view source on GitHub ↗
(fileName: string, position: number)

Source from the content-addressed store, hash-verified

458 }
459
460 async getFunctionAST(fileName: string, position: number): Promise<DumpFunctionResponseBody> {
461 const openedFile = this.getOpenedFile(fileName);
462 const node = findNode(openedFile.sourceFile, position, (node) => ts.isFunctionDeclaration(node));
463 if (!node) {
464 throw new Error(`Could not resolve function declaration at position ${position}`);
465 }
466
467 const references: AST.TypeReference[] = [];
468
469 const dumpedFunction = dumpFunction(node as ts.FunctionDeclaration, {
470 typeChecker: openedFile.workspaceProject.typeChecker,
471 references,
472 });
473
474 return {
475 function: dumpedFunction,
476 references,
477 };
478 }
479
480 async getEnumAST(fileName: string, position: number): Promise<DumpEnumResponseBody> {
481 const openedFile = this.getOpenedFile(fileName);

Callers

nothing calls this directly

Calls 3

getOpenedFileMethod · 0.95
findNodeFunction · 0.90
dumpFunctionFunction · 0.90

Tested by

no test coverage detected