MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / get_substring

Function get_substring

utils/dasFormatter/formatter.cpp:72–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70 }
71
72 string get_substring(Pos pos1, Pos pos2) {
73 if (!state.enabled || pos1 < state.last) {
74 return "";
75 }
76
77 TextPrinter tp;
78 string result;
79 for (; pos1.line < pos2.line; pos1.line++, pos1.column = 0) {
80 if (pos1.line > state.content_.size()) {
81 tp << "Warning, location line out of range\n";
82 return "";
83 } else if (pos1.column > state.content_[pos1.line - 1].length()) {
84// tp << "incorrect location info, extra symbols "
85// << pos1.column << " "
86// << state.content_[pos1.line - 1].length() << '\n';
87 } else {
88 result += state.content_[pos1.line - 1].substr(pos1.column);
89 }
90 result += '\n';
91 }
92 if (pos2.column < pos1.column || pos2.line < pos1.line) {
93 assert(result.empty());
94 assert(pos1.line == pos2.line);
95 return "";
96 }
97
98 if (pos1.line > state.content_.size()) {
99 tp << "Warning, location line out of range\n";
100 return "";
101 }
102 if (pos1.column > state.content_[pos1.line - 1].size()) {
103 tp << "Warning, location column out of range\n";
104 return "";
105 }
106 result += state.content_[pos1.line - 1].substr(pos1.column, pos2.column - pos1.column);
107 return result;
108 }
109
110
111 string get_substring(LineInfo info) {

Callers 9

yyparseFunction · 0.85
convert_to_stringFunction · 0.85
try_print_untilFunction · 0.85
substring_betweenFunction · 0.85
type_to_stringFunction · 0.85
handle_mkaFunction · 0.85
get_indentFunction · 0.85
replace_withFunction · 0.85
wrap_par_exprFunction · 0.85

Calls 4

assertFunction · 0.85
sizeMethod · 0.45
lengthMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected