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

Function scanAllLines

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

* @brief Builds per-line LineInfo and depth-at-start arrays, threading scanner state across lines. */

Source from the content-addressed store, hash-verified

589 * @brief Builds per-line LineInfo and depth-at-start arrays, threading scanner state across lines.
590 */
591static ScanResult scanAllLines(const QStringList& lines, Language lang)
592{
593 ScanResult result;
594 result.infos.reserve(lines.size());
595 result.depthAtStart.reserve(lines.size());
596 result.hangAtStart.reserve(lines.size());
597
598 ScanState state;
599 HangState hang;
600 int depth = 0;
601 for (const auto& raw : lines) {
602 const QString trimmed = rtrim(raw);
603 LineInfo info = analyzeLine(QStringView(trimmed), lang, state);
604 result.infos.append(info);
605 result.depthAtStart.append(depth);
606 result.hangAtStart.append(applyHanging(info, hang));
607 depth += info.netDelta;
608 if (depth < 0)
609 depth = 0;
610 }
611
612 return result;
613}
614
615/**
616 * @brief Returns the rendered indentation string for a line.

Callers 2

formatDocumentFunction · 0.85
formatLineRangeFunction · 0.85

Calls 5

rtrimFunction · 0.85
analyzeLineFunction · 0.85
applyHangingFunction · 0.85
sizeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected