MCPcopy Create free account
hub / github.com/nodejs/node / trimTrailingWhitespacesForLines

Function trimTrailingWhitespacesForLines

test/fixtures/snapshot/typescript.js:147823–147837  ·  view source on GitHub ↗
(line1, line2, range)

Source from the content-addressed store, hash-verified

147821 }
147822 }
147823 function trimTrailingWhitespacesForLines(line1, line2, range) {
147824 for (var line = line1; line < line2; line++) {
147825 var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile);
147826 var lineEndPosition = ts.getEndLinePosition(line, sourceFile);
147827 // do not trim whitespaces in comments or template expression
147828 if (range && (ts.isComment(range.kind) || ts.isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) {
147829 continue;
147830 }
147831 var whitespaceStart = getTrailingWhitespaceStartPosition(lineStartPosition, lineEndPosition);
147832 if (whitespaceStart !== -1) {
147833 ts.Debug.assert(whitespaceStart === lineStartPosition || !ts.isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(whitespaceStart - 1)));
147834 recordDelete(whitespaceStart, lineEndPosition + 1 - whitespaceStart);
147835 }
147836 }
147837 }
147838 /**
147839 * @param start The position of the first character in range
147840 * @param end The position of the last character in range

Callers 3

processRangeFunction · 0.85
processPairFunction · 0.85

Calls 3

recordDeleteFunction · 0.85
assertMethod · 0.80

Tested by

no test coverage detected