(parentNode, children, format)
| 114112 | } |
| 114113 | } |
| 114114 | function getLeadingLineTerminatorCount(parentNode, children, format) { |
| 114115 | if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { |
| 114116 | if (format & 65536 /* ListFormat.PreferNewLine */) { |
| 114117 | return 1; |
| 114118 | } |
| 114119 | var firstChild_1 = children[0]; |
| 114120 | if (firstChild_1 === undefined) { |
| 114121 | return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; |
| 114122 | } |
| 114123 | if (firstChild_1.pos === nextListElementPos) { |
| 114124 | // If this child starts at the beginning of a list item in a parent list, its leading |
| 114125 | // line terminators have already been written as the separating line terminators of the |
| 114126 | // parent list. Example: |
| 114127 | // |
| 114128 | // class Foo { |
| 114129 | // constructor() {} |
| 114130 | // public foo() {} |
| 114131 | // } |
| 114132 | // |
| 114133 | // The outer list is the list of class members, with one line terminator between the |
| 114134 | // constructor and the method. The constructor is written, the separating line terminator |
| 114135 | // is written, and then we start emitting the method. Its modifiers ([public]) constitute an inner |
| 114136 | // list, so we look for its leading line terminators. If we didn't know that we had already |
| 114137 | // written a newline as part of the parent list, it would appear that we need to write a |
| 114138 | // leading newline to start the modifiers. |
| 114139 | return 0; |
| 114140 | } |
| 114141 | if (firstChild_1.kind === 11 /* SyntaxKind.JsxText */) { |
| 114142 | // JsxText will be written with its leading whitespace, so don't add more manually. |
| 114143 | return 0; |
| 114144 | } |
| 114145 | if (currentSourceFile && parentNode && |
| 114146 | !ts.positionIsSynthesized(parentNode.pos) && |
| 114147 | !ts.nodeIsSynthesized(firstChild_1) && |
| 114148 | (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) { |
| 114149 | if (preserveSourceNewlines) { |
| 114150 | return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(firstChild_1.pos, parentNode.pos, currentSourceFile, includeComments); }); |
| 114151 | } |
| 114152 | return ts.rangeStartPositionsAreOnSameLine(parentNode, firstChild_1, currentSourceFile) ? 0 : 1; |
| 114153 | } |
| 114154 | if (synthesizedNodeStartsOnNewLine(firstChild_1, format)) { |
| 114155 | return 1; |
| 114156 | } |
| 114157 | } |
| 114158 | return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; |
| 114159 | } |
| 114160 | function getSeparatingLineTerminatorCount(previousNode, nextNode, format) { |
| 114161 | if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { |
| 114162 | if (previousNode === undefined || nextNode === undefined) { |
no test coverage detected