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

Function createPrinter

test/fixtures/snapshot/typescript.js:110707–115166  ·  view source on GitHub ↗
(printerOptions, handlers)

Source from the content-addressed store, hash-verified

110705 PipelinePhase[PipelinePhase["Emit"] = 4] = "Emit";
110706 })(PipelinePhase || (PipelinePhase = {}));
110707 function createPrinter(printerOptions, handlers) {
110708 if (printerOptions === void 0) { printerOptions = {}; }
110709 if (handlers === void 0) { handlers = {}; }
110710 var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, isEmitNotificationEnabled = handlers.isEmitNotificationEnabled, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNode = handlers.onBeforeEmitNode, onAfterEmitNode = handlers.onAfterEmitNode, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken;
110711 var extendedDiagnostics = !!printerOptions.extendedDiagnostics;
110712 var newLine = ts.getNewLineCharacter(printerOptions);
110713 var moduleKind = ts.getEmitModuleKind(printerOptions);
110714 var bundledHelpers = new ts.Map();
110715 var currentSourceFile;
110716 var nodeIdToGeneratedName; // Map of generated names for specific nodes.
110717 var autoGeneratedIdToGeneratedName; // Map of generated names for temp and loop variables.
110718 var generatedNames; // Set of names generated by the NameGenerator.
110719 var tempFlagsStack; // Stack of enclosing name generation scopes.
110720 var tempFlags; // TempFlags for the current name generation scope.
110721 var reservedNamesStack; // Stack of TempFlags reserved in enclosing name generation scopes.
110722 var reservedNames; // TempFlags to reserve in nested name generation scopes.
110723 var preserveSourceNewlines = printerOptions.preserveSourceNewlines; // Can be overridden inside nodes with the `IgnoreSourceNewlines` emit flag.
110724 var nextListElementPos; // See comment in `getLeadingLineTerminatorCount`.
110725 var writer;
110726 var ownWriter; // Reusable `EmitTextWriter` for basic printing.
110727 var write = writeBase;
110728 var isOwnFileEmit;
110729 var bundleFileInfo = printerOptions.writeBundleFileInfo ? { sections: [] } : undefined;
110730 var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined;
110731 var recordInternalSection = printerOptions.recordInternalSection;
110732 var sourceFileTextPos = 0;
110733 var sourceFileTextKind = "text" /* BundleFileSectionKind.Text */;
110734 // Source Maps
110735 var sourceMapsDisabled = true;
110736 var sourceMapGenerator;
110737 var sourceMapSource;
110738 var sourceMapSourceIndex = -1;
110739 var mostRecentlyAddedSourceMapSource;
110740 var mostRecentlyAddedSourceMapSourceIndex = -1;
110741 // Comments
110742 var containerPos = -1;
110743 var containerEnd = -1;
110744 var declarationListContainerEnd = -1;
110745 var currentLineMap;
110746 var detachedCommentsInfo;
110747 var hasWrittenComment = false;
110748 var commentsDisabled = !!printerOptions.removeComments;
110749 var lastSubstitution;
110750 var currentParenthesizerRule;
110751 var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit;
110752 var parenthesizer = ts.factory.parenthesizer;
110753 var typeArgumentParenthesizerRuleSelector = {
110754 select: function (index) { return index === 0 ? parenthesizer.parenthesizeLeadingTypeArgument : undefined; }
110755 };
110756 var emitBinaryExpression = createEmitBinaryExpression();
110757 reset();
110758 return {
110759 // public API
110760 printNode: printNode,
110761 printList: printList,
110762 printFile: printFile,
110763 printBundle: printBundle,
110764 // internal API

Callers 2

emitJsFileOrBundleFunction · 0.85

Calls 2

resetFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…