MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / readVariableDeclaration

Function readVariableDeclaration

src/lib/prettierFormatter.js:348–367  ·  view source on GitHub ↗
(statement, scope)

Source from the content-addressed store, hash-verified

346}
347
348function readVariableDeclaration(statement, scope) {
349 if (statement?.type !== "VariableDeclaration") return null;
350 const values = new Map();
351 const lookupScope = new Map(scope);
352
353 for (const decl of statement.declarations || []) {
354 if (!decl || decl.type !== "VariableDeclarator") continue;
355 if (decl.id?.type !== "Identifier") continue;
356 if (!decl.init) continue;
357 try {
358 const value = evaluateNode(decl.init, lookupScope);
359 values.set(decl.id.name, value);
360 lookupScope.set(decl.id.name, value);
361 } catch (_) {
362 // Ignore unsupported declarations
363 }
364 }
365
366 return values.size ? values : null;
367}
368
369function readCommonJsExport(statement, scope) {
370 if (statement?.type !== "ExpressionStatement") return undefined;

Callers 1

extractConfigFromProgramFunction · 0.85

Calls 2

evaluateNodeFunction · 0.85
setMethod · 0.80

Tested by

no test coverage detected