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

Function getEndLinePosition

test/fixtures/snapshot/typescript.js:14564–14588  ·  view source on GitHub ↗
(line, sourceFile)

Source from the content-addressed store, hash-verified

14562 }
14563 ts.nodePosToString = nodePosToString;
14564 function getEndLinePosition(line, sourceFile) {
14565 ts.Debug.assert(line >= 0);
14566 var lineStarts = ts.getLineStarts(sourceFile);
14567 var lineIndex = line;
14568 var sourceText = sourceFile.text;
14569 if (lineIndex + 1 === lineStarts.length) {
14570 // last line - return EOF
14571 return sourceText.length - 1;
14572 }
14573 else {
14574 // current line start
14575 var start = lineStarts[lineIndex];
14576 // take the start position of the next line - 1 = it should be some line break
14577 var pos = lineStarts[lineIndex + 1] - 1;
14578 ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos)));
14579 // walk backwards skipping line breaks, stop the the beginning of current line.
14580 // i.e:
14581 // <some text>
14582 // $ <- end of line for this position should match the start position
14583 while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) {
14584 pos--;
14585 }
14586 return pos;
14587 }
14588 }
14589 ts.getEndLinePosition = getEndLinePosition;
14590 /**
14591 * Returns a value indicating whether a name is unique globally or within the current file.

Callers 1

Calls 1

assertMethod · 0.80

Tested by

no test coverage detected