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

Method AddEndOfLine

CodeFormatCore/src/Format/FormatBuilder.cpp:304–340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302}
303
304void FormatBuilder::AddEndOfLine(std::size_t line) {
305 auto endOfLine = _state.GetEndOfLine();
306 switch (endOfLine) {
307 case EndOfLine::CRLF: {
308 if (line == 1) {
309 _formattedText.push_back('\r');
310 _formattedText.push_back('\n');
311 } else {
312 auto index = _formattedText.size();
313 _formattedText.resize(index + 2 * line, '\n');
314 for (; index < _formattedText.size(); index += 2) {
315 _formattedText[index] = '\r';
316 }
317 }
318 break;
319 }
320 case EndOfLine::CR: {
321 if (line == 1) {
322 _formattedText.push_back('\r');
323 } else {
324 _formattedText.resize(_formattedText.size() + line, '\r');
325 }
326 break;
327 }
328 case EndOfLine::UNKNOWN:
329 case EndOfLine::MIX:
330 case EndOfLine::LF: {
331 if (line == 1) {
332 _formattedText.push_back('\n');
333 } else {
334 _formattedText.resize(_formattedText.size() + line, '\n');
335 }
336 break;
337 }
338 }
339 _state.CurrentWidth() = 0;
340}
341
342void FormatBuilder::WriteLine(std::size_t line) {
343 if (line == 0) {

Callers

nothing calls this directly

Calls 4

GetEndOfLineMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected