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

Function createEmitBinaryExpression

test/fixtures/snapshot/typescript.js:112334–112422  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

112332 writeTokenText(node.operator, writeOperator);
112333 }
112334 function createEmitBinaryExpression() {
112335 return ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, /*foldState*/ undefined);
112336 function onEnter(node, state) {
112337 if (state) {
112338 state.stackIndex++;
112339 state.preserveSourceNewlinesStack[state.stackIndex] = preserveSourceNewlines;
112340 state.containerPosStack[state.stackIndex] = containerPos;
112341 state.containerEndStack[state.stackIndex] = containerEnd;
112342 state.declarationListContainerEndStack[state.stackIndex] = declarationListContainerEnd;
112343 var emitComments_1 = state.shouldEmitCommentsStack[state.stackIndex] = shouldEmitComments(node);
112344 var emitSourceMaps = state.shouldEmitSourceMapsStack[state.stackIndex] = shouldEmitSourceMaps(node);
112345 onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(node);
112346 if (emitComments_1)
112347 emitCommentsBeforeNode(node);
112348 if (emitSourceMaps)
112349 emitSourceMapsBeforeNode(node);
112350 beforeEmitNode(node);
112351 }
112352 else {
112353 state = {
112354 stackIndex: 0,
112355 preserveSourceNewlinesStack: [undefined],
112356 containerPosStack: [-1],
112357 containerEndStack: [-1],
112358 declarationListContainerEndStack: [-1],
112359 shouldEmitCommentsStack: [false],
112360 shouldEmitSourceMapsStack: [false],
112361 };
112362 }
112363 return state;
112364 }
112365 function onLeft(next, _workArea, parent) {
112366 return maybeEmitExpression(next, parent, "left");
112367 }
112368 function onOperator(operatorToken, _state, node) {
112369 var isCommaOperator = operatorToken.kind !== 27 /* SyntaxKind.CommaToken */;
112370 var linesBeforeOperator = getLinesBetweenNodes(node, node.left, operatorToken);
112371 var linesAfterOperator = getLinesBetweenNodes(node, operatorToken, node.right);
112372 writeLinesAndIndent(linesBeforeOperator, isCommaOperator);
112373 emitLeadingCommentsOfPosition(operatorToken.pos);
112374 writeTokenNode(operatorToken, operatorToken.kind === 101 /* SyntaxKind.InKeyword */ ? writeKeyword : writeOperator);
112375 emitTrailingCommentsOfPosition(operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts
112376 writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true);
112377 }
112378 function onRight(next, _workArea, parent) {
112379 return maybeEmitExpression(next, parent, "right");
112380 }
112381 function onExit(node, state) {
112382 var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken);
112383 var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right);
112384 decreaseIndentIf(linesBeforeOperator, linesAfterOperator);
112385 if (state.stackIndex > 0) {
112386 var savedPreserveSourceNewlines = state.preserveSourceNewlinesStack[state.stackIndex];
112387 var savedContainerPos = state.containerPosStack[state.stackIndex];
112388 var savedContainerEnd = state.containerEndStack[state.stackIndex];
112389 var savedDeclarationListContainerEnd = state.declarationListContainerEndStack[state.stackIndex];
112390 var shouldEmitComments_1 = state.shouldEmitCommentsStack[state.stackIndex];
112391 var shouldEmitSourceMaps_1 = state.shouldEmitSourceMapsStack[state.stackIndex];

Callers 1

createPrinterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…