MCPcopy Index your code
hub / github.com/nodejs/node / withContext

Function withContext

test/fixtures/snapshot/typescript.js:52330–52363  ·  view source on GitHub ↗
(enclosingDeclaration, flags, tracker, cb)

Source from the content-addressed store, hash-verified

52328 },
52329 };
52330 function withContext(enclosingDeclaration, flags, tracker, cb) {
52331 var _a, _b;
52332 ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* NodeFlags.Synthesized */) === 0);
52333 var context = {
52334 enclosingDeclaration: enclosingDeclaration,
52335 flags: flags || 0 /* NodeBuilderFlags.None */,
52336 // If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost
52337 tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */ ? {
52338 getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; },
52339 getCurrentDirectory: function () { return host.getCurrentDirectory(); },
52340 getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache),
52341 getPackageJsonInfoCache: function () { var _a; return (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host); },
52342 useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
52343 redirectTargetsMap: host.redirectTargetsMap,
52344 getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); },
52345 isSourceOfProjectReferenceRedirect: function (fileName) { return host.isSourceOfProjectReferenceRedirect(fileName); },
52346 fileExists: function (fileName) { return host.fileExists(fileName); },
52347 getFileIncludeReasons: function () { return host.getFileIncludeReasons(); },
52348 readFile: host.readFile ? (function (fileName) { return host.readFile(fileName); }) : undefined,
52349 } : undefined },
52350 encounteredError: false,
52351 reportedDiagnostic: false,
52352 visitedTypes: undefined,
52353 symbolDepth: undefined,
52354 inferTypeParameters: undefined,
52355 approximateLength: 0
52356 };
52357 context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker);
52358 var resultingNode = cb(context);
52359 if (context.truncating && context.flags & 1 /* NodeBuilderFlags.NoTruncation */) {
52360 (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportTruncationError) === null || _b === void 0 ? void 0 : _b.call(_a);
52361 }
52362 return context.encounteredError ? undefined : resultingNode;
52363 }
52364 function wrapSymbolTrackerToReportForContext(context, tracker) {
52365 var oldTrackSymbol = tracker.trackSymbol;
52366 return __assign(__assign({}, tracker), { reportCyclicStructureError: wrapReportedDiagnostic(tracker.reportCyclicStructureError), reportInaccessibleThisError: wrapReportedDiagnostic(tracker.reportInaccessibleThisError), reportInaccessibleUniqueSymbolError: wrapReportedDiagnostic(tracker.reportInaccessibleUniqueSymbolError), reportLikelyUnsafeImportRequiredError: wrapReportedDiagnostic(tracker.reportLikelyUnsafeImportRequiredError), reportNonlocalAugmentation: wrapReportedDiagnostic(tracker.reportNonlocalAugmentation), reportPrivateInBaseOfClassExpression: wrapReportedDiagnostic(tracker.reportPrivateInBaseOfClassExpression), reportNonSerializableProperty: wrapReportedDiagnostic(tracker.reportNonSerializableProperty), trackSymbol: oldTrackSymbol && (function () {

Callers 1

createNodeBuilderFunction · 0.85

Calls 5

assertMethod · 0.80
cbFunction · 0.50
callMethod · 0.45
readFileMethod · 0.45

Tested by

no test coverage detected