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

Method GetLine

LuaParser/src/File/LuaSource.cpp:16–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14}
15
16std::size_t LuaSource::GetLine(std::size_t offset) const {
17 if (_lineOffsetVec.empty()) {
18 return 0;
19 }
20
21 int maxLine = static_cast<int>(_lineOffsetVec.size()) - 1;
22 int targetLine = maxLine;
23 int upperLine = maxLine;
24 int lowestLine = 0;
25
26 while (true) {
27 if (_lineOffsetVec[targetLine] > offset) {
28 upperLine = targetLine;
29
30 targetLine = (upperLine + lowestLine) / 2;
31
32 if (targetLine == 0) {
33 return targetLine;
34 }
35 } else {
36 if (upperLine - targetLine <= 1) {
37 return targetLine;
38 }
39
40 lowestLine = targetLine;
41
42 targetLine = (upperLine + lowestLine) / 2;
43 }
44 }
45
46 return 0;
47}
48
49std::size_t LuaSource::GetColumn(std::size_t offset) const {
50 auto line = GetLine(offset);

Callers 9

DiagnosticInspectionFunction · 0.80
DiagnosticToJsonFunction · 0.80
RangeReformatMethod · 0.80
MakeDiagnosticInfoMethod · 0.80
MakeDiagnosticInfoMethod · 0.80
EatInlineCommentMethod · 0.80
GetStartLineMethod · 0.80
GetEndLineMethod · 0.80
MakeErrorsFunction · 0.80

Calls 2

emptyMethod · 0.45
sizeMethod · 0.45

Tested by 1

MakeErrorsFunction · 0.64