MCPcopy Index your code
hub / github.com/microsoft/vscode-js-debug / parseSource

Function parseSource

src/common/sourceCodeManipulations.ts:40–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38 (strict ? parseStrict : parse)(str, acornOptions) as unknown as Program;
39
40export const parseSource: (str: string) => (Statement & AcornNode)[] = str => {
41 const parsed = parseProgram(str) as unknown as {
42 body: (Statement & AcornNode)[];
43 };
44
45 // acorn-loose adds a "dummy" identifier to function expressions parsing
46 // as a program, which creates an invalid name. But this isn't actually necesary.
47 for (const stmt of parsed.body) {
48 if (stmt.type === 'FunctionDeclaration' && stmt.id && isDummy(stmt.id)) {
49 // eslint-disable-next-line @typescript-eslint/no-explicit-any
50 (stmt as any).id = null;
51 }
52 }
53 return parsed.body;
54};
55
56/**
57 * function (params) { code } => function (params) { catchAndReturnErrors?(code) }

Calls 1

parseProgramFunction · 0.85

Tested by

no test coverage detected