MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / GetLineCol

Method GetLineCol

CodeFormatServer/src/Lib/LineIndex/LineIndex.cpp:27–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27LineCol LineIndex::GetLineCol(std::size_t offset) {
28 auto lineIt = std::partition_point(
29 _newLines.begin(), _newLines.end(),
30 [offset](LineOffset &lo) {
31 return lo.Start <= offset;
32 });
33 std::size_t line = 0;
34 if (lineIt > _newLines.begin()) {
35 line = static_cast<std::size_t>(lineIt - _newLines.begin() - 1);
36 }
37 auto lineStartOffset = _newLines.at(line).Start;
38 auto colOffset = offset - lineStartOffset;
39 auto col = _newLines.at(line).GetCol(colOffset);
40 return {line, col};
41}
42
43std::size_t LineIndex::GetOffset(const LineCol &lineCol) {
44 if (lineCol.Line < _newLines.size()) {

Callers 1

DiagnosticMethod · 0.80

Calls 3

GetColMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected