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

Function reformatOne

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

* @brief Reformats one line based on its scanner state, brace depth and hanging indent. */

Source from the content-addressed store, hash-verified

628 * @brief Reformats one line based on its scanner state, brace depth and hanging indent.
629 */
630static QString reformatOne(
631 const QString& raw, const LineInfo& info, int depthAtStart, int hangAtStart, int indentSpaces)
632{
633 QString trimmed = rtrim(raw);
634
635 if (info.startsInsideMultiline)
636 return trimmed;
637
638 const int lead = leadingWhitespaceCount(QStringView(trimmed));
639 if (lead == trimmed.size())
640 return QString();
641
642 const QString body = trimmed.mid(lead);
643 return computeIndent(depthAtStart + hangAtStart, info.outdentLeading, indentSpaces) + body;
644}
645
646namespace DataModel::CodeFormatter {
647

Callers 2

formatDocumentFunction · 0.85
formatLineRangeFunction · 0.85

Calls 4

rtrimFunction · 0.85
leadingWhitespaceCountFunction · 0.85
computeIndentFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected