MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / formatLineRange

Function formatLineRange

app/src/DataModel/Editors/CodeFormatter.cpp:671–694  ·  view source on GitHub ↗

* @brief Reformats only the given inclusive line range, preserving everything else. */

Source from the content-addressed store, hash-verified

669 * @brief Reformats only the given inclusive line range, preserving everything else.
670 */
671QString formatLineRange(
672 const QString& source, Language language, int firstLine, int lastLine, int indentSpaces)
673{
674 if (source.isEmpty())
675 return source;
676
677 QStringList lines = splitLines(source);
678 if (firstLine < 0)
679 firstLine = 0;
680
681 if (lastLine >= lines.size())
682 lastLine = lines.size() - 1;
683
684 if (firstLine > lastLine)
685 return source;
686
687 const ScanResult scan = scanAllLines(lines, language);
688
689 for (int i = firstLine; i <= lastLine; ++i)
690 lines[i] =
691 reformatOne(lines[i], scan.infos[i], scan.depthAtStart[i], scan.hangAtStart[i], indentSpaces);
692
693 return lines.join(QLatin1Char('\n'));
694}
695
696} // namespace DataModel::CodeFormatter

Callers 6

onFormatLineMethod · 0.85
formatSelectionMethod · 0.85
formatSelectionMethod · 0.85
onFormatLineMethod · 0.85
formatSelectionMethod · 0.85
formatSelectionMethod · 0.85

Calls 5

splitLinesFunction · 0.85
scanAllLinesFunction · 0.85
reformatOneFunction · 0.85
isEmptyMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected