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

Function emitLeadingCommentsOfNode

test/fixtures/snapshot/typescript.js:114728–114758  ·  view source on GitHub ↗
(node, emitFlags, pos, end)

Source from the content-addressed store, hash-verified

114726 }
114727 }
114728 function emitLeadingCommentsOfNode(node, emitFlags, pos, end) {
114729 enterComment();
114730 hasWrittenComment = false;
114731 // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation.
114732 // It is expensive to walk entire tree just to set one kind of node to have no comments.
114733 var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */;
114734 var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */;
114735 // Save current container state on the stack.
114736 if ((pos > 0 || end > 0) && pos !== end) {
114737 // Emit leading comments if the position is not synthesized and the node
114738 // has not opted out from emitting leading comments.
114739 if (!skipLeadingComments) {
114740 emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* SyntaxKind.NotEmittedStatement */);
114741 }
114742 if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0)) {
114743 // Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments.
114744 containerPos = pos;
114745 }
114746 if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0)) {
114747 // As above.
114748 containerEnd = end;
114749 // To avoid invalid comment emit in a down-level binding pattern, we
114750 // keep track of the last declaration list container's end
114751 if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) {
114752 declarationListContainerEnd = end;
114753 }
114754 }
114755 }
114756 ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment);
114757 exitComment();
114758 }
114759 function emitTrailingCommentsOfNode(node, emitFlags, pos, end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) {
114760 enterComment();
114761 var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */;

Callers 1

emitCommentsBeforeNodeFunction · 0.85

Calls 2

emitLeadingCommentsFunction · 0.85
forEachMethod · 0.65

Tested by

no test coverage detected