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

Function getSeparatingLineTerminatorCount

test/fixtures/snapshot/typescript.js:114160–114193  ·  view source on GitHub ↗
(previousNode, nextNode, format)

Source from the content-addressed store, hash-verified

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) {
114163 return 0;
114164 }
114165 if (nextNode.kind === 11 /* SyntaxKind.JsxText */) {
114166 // JsxText will be written with its leading whitespace, so don't add more manually.
114167 return 0;
114168 }
114169 else if (currentSourceFile && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
114170 if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) {
114171 return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); });
114172 }
114173 // If `preserveSourceNewlines` is `false` we do not intend to preserve the effective lines between the
114174 // previous and next node. Instead we naively check whether nodes are on separate lines within the
114175 // same node parent. If so, we intend to preserve a single line terminator. This is less precise and
114176 // expensive than checking with `preserveSourceNewlines` as above, but the goal is not to preserve the
114177 // effective source lines between two sibling nodes.
114178 else if (!preserveSourceNewlines && originalNodesHaveSameParent(previousNode, nextNode)) {
114179 return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1;
114180 }
114181 // If the two nodes are not comparable, add a line terminator based on the format that can indicate
114182 // whether new lines are preferred or not.
114183 return format & 65536 /* ListFormat.PreferNewLine */ ? 1 : 0;
114184 }
114185 else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) {
114186 return 1;
114187 }
114188 }
114189 else if (ts.getStartsOnNewLine(nextNode)) {
114190 return 1;
114191 }
114192 return format & 1 /* ListFormat.MultiLine */ ? 1 : 0;
114193 }
114194 function getClosingLineTerminatorCount(parentNode, children, format) {
114195 if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) {
114196 if (format & 65536 /* ListFormat.PreferNewLine */) {

Callers 2

emitNodeListFunction · 0.85

Tested by

no test coverage detected