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

Function shouldEmitBlockFunctionBodyOnSingleLine

test/fixtures/snapshot/typescript.js:112797–112826  ·  view source on GitHub ↗
(body)

Source from the content-addressed store, hash-verified

112795 emitTypeAnnotation(node.type);
112796 }
112797 function shouldEmitBlockFunctionBodyOnSingleLine(body) {
112798 // We must emit a function body as a single-line body in the following case:
112799 // * The body has NodeEmitFlags.SingleLine specified.
112800 // We must emit a function body as a multi-line body in the following cases:
112801 // * The body is explicitly marked as multi-line.
112802 // * A non-synthesized body's start and end position are on different lines.
112803 // * Any statement in the body starts on a new line.
112804 if (ts.getEmitFlags(body) & 1 /* EmitFlags.SingleLine */) {
112805 return true;
112806 }
112807 if (body.multiLine) {
112808 return false;
112809 }
112810 if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
112811 return false;
112812 }
112813 if (getLeadingLineTerminatorCount(body, body.statements, 2 /* ListFormat.PreserveLines */)
112814 || getClosingLineTerminatorCount(body, body.statements, 2 /* ListFormat.PreserveLines */)) {
112815 return false;
112816 }
112817 var previousStatement;
112818 for (var _a = 0, _b = body.statements; _a < _b.length; _a++) {
112819 var statement = _b[_a];
112820 if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* ListFormat.PreserveLines */) > 0) {
112821 return false;
112822 }
112823 previousStatement = statement;
112824 }
112825 return true;
112826 }
112827 function emitBlockFunctionBody(body) {
112828 onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(body);
112829 writeSpace();

Callers 1

emitBlockFunctionBodyFunction · 0.85

Tested by

no test coverage detected