MCPcopy Index your code
hub / github.com/ternjs/tern / asLineChar

Function asLineChar

lib/tern.js:622–637  ·  view source on GitHub ↗
(file, pos)

Source from the content-addressed store, hash-verified

620 }
621
622 function asLineChar(file, pos) {
623 if (!file) return {line: 0, ch: 0};
624 var offsets = file.lineOffsets || (file.lineOffsets = [0]);
625 var text = file.text, line, lineStart;
626 for (var i = offsets.length - 1; i >= 0; --i) if (offsets[i] <= pos) {
627 line = i * offsetSkipLines;
628 lineStart = offsets[i];
629 }
630 for (;;) {
631 var eol = text.indexOf("\n", lineStart);
632 if (eol >= pos || eol < 0) break;
633 lineStart = eol + 1;
634 ++line;
635 }
636 return {line: line, ch: charDistanceBetween(file, lineStart, pos)};
637 }
638
639 var outputPos = exports.outputPos = function(query, file, pos) {
640 if (query.lineCharPositions) {

Callers 3

tern.jsFile · 0.85
storeRefFunction · 0.85
findRefsToVariableFunction · 0.85

Calls 1

charDistanceBetweenFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…