* @brief Reformats the entire source string with normalized indentation. */
| 649 | * @brief Reformats the entire source string with normalized indentation. |
| 650 | */ |
| 651 | QString formatDocument(const QString& source, Language language, int indentSpaces) |
| 652 | { |
| 653 | if (source.isEmpty()) |
| 654 | return source; |
| 655 | |
| 656 | const QStringList lines = splitLines(source); |
| 657 | const ScanResult scan = scanAllLines(lines, language); |
| 658 | |
| 659 | QStringList out; |
| 660 | out.reserve(lines.size()); |
| 661 | for (int i = 0; i < lines.size(); ++i) |
| 662 | out.append(reformatOne( |
| 663 | lines[i], scan.infos[i], scan.depthAtStart[i], scan.hangAtStart[i], indentSpaces)); |
| 664 | |
| 665 | return out.join(QLatin1Char('\n')); |
| 666 | } |
| 667 | |
| 668 | /** |
| 669 | * @brief Reformats only the given inclusive line range, preserving everything else. |
no test coverage detected