* @brief Builds per-line LineInfo and depth-at-start arrays, threading scanner state across lines. */
| 589 | * @brief Builds per-line LineInfo and depth-at-start arrays, threading scanner state across lines. |
| 590 | */ |
| 591 | static 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. |
no test coverage detected