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

Function emitTokenWithComment

test/fixtures/snapshot/typescript.js:112620–112643  ·  view source on GitHub ↗
(token, pos, writer, contextNode, indentLeading)

Source from the content-addressed store, hash-verified

112618 writeTrailingSemicolon();
112619 }
112620 function emitTokenWithComment(token, pos, writer, contextNode, indentLeading) {
112621 var node = ts.getParseTreeNode(contextNode);
112622 var isSimilarNode = node && node.kind === contextNode.kind;
112623 var startPos = pos;
112624 if (isSimilarNode && currentSourceFile) {
112625 pos = ts.skipTrivia(currentSourceFile.text, pos);
112626 }
112627 if (isSimilarNode && contextNode.pos !== startPos) {
112628 var needsIndent = indentLeading && currentSourceFile && !ts.positionsAreOnSameLine(startPos, pos, currentSourceFile);
112629 if (needsIndent) {
112630 increaseIndent();
112631 }
112632 emitLeadingCommentsOfPosition(startPos);
112633 if (needsIndent) {
112634 decreaseIndent();
112635 }
112636 }
112637 pos = writeTokenText(token, writer, pos);
112638 if (isSimilarNode && contextNode.end !== pos) {
112639 var isJsxExprContext = contextNode.kind === 288 /* SyntaxKind.JsxExpression */;
112640 emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext);
112641 }
112642 return pos;
112643 }
112644 function commentWillEmitNewLine(node) {
112645 return node.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || !!node.hasTrailingNewLine;
112646 }

Callers 15

emitTupleTypeFunction · 0.85
emitNamedTupleMemberFunction · 0.85
emitNewExpressionFunction · 0.85
emitDeleteExpressionFunction · 0.85
emitTypeOfExpressionFunction · 0.85
emitVoidExpressionFunction · 0.85
emitAwaitExpressionFunction · 0.85
emitYieldExpressionFunction · 0.85
emitSpreadElementFunction · 0.85

Calls 5

increaseIndentFunction · 0.85
decreaseIndentFunction · 0.85
writeTokenTextFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…