* @brief Computes outdent/indent deltas for a single line and updates the carry-over state. */
| 431 | * @brief Computes outdent/indent deltas for a single line and updates the carry-over state. |
| 432 | */ |
| 433 | static LineInfo analyzeLine(QStringView line, Language lang, ScanState& state) |
| 434 | { |
| 435 | LineInfo info; |
| 436 | info.startsInsideMultiline = (state.in != ScanIn::Code); |
| 437 | |
| 438 | TokenTrack tk; |
| 439 | |
| 440 | int i = 0; |
| 441 | const int n = line.size(); |
| 442 | while (i < n) { |
| 443 | if (state.in == ScanIn::JsBlockComment) { |
| 444 | advanceJsBlockComment(line, i, n, state); |
| 445 | continue; |
| 446 | } |
| 447 | |
| 448 | if (state.in == ScanIn::JsTemplate) { |
| 449 | advanceJsTemplate(line, i, state); |
| 450 | continue; |
| 451 | } |
| 452 | |
| 453 | if (state.in == ScanIn::LuaLongString || state.in == ScanIn::LuaBlockComment) { |
| 454 | advanceLuaLong(line, i, state); |
| 455 | continue; |
| 456 | } |
| 457 | |
| 458 | bool stop = false; |
| 459 | if (tryEnterComment(line, i, n, lang, state, stop)) { |
| 460 | if (stop) |
| 461 | break; |
| 462 | |
| 463 | continue; |
| 464 | } |
| 465 | |
| 466 | const QChar c = line[i]; |
| 467 | if (tryEnterStringLiteral(line, i, lang, state, tk.sawCode)) { |
| 468 | markCode(tk, c, false); |
| 469 | continue; |
| 470 | } |
| 471 | |
| 472 | if (c == QLatin1Char('{')) { |
| 473 | ++info.netDelta; |
| 474 | markCode(tk, c, false); |
| 475 | ++i; |
| 476 | continue; |
| 477 | } |
| 478 | if (c == QLatin1Char('}')) { |
| 479 | if (!tk.sawCode) |
| 480 | ++info.outdentLeading; |
| 481 | |
| 482 | --info.netDelta; |
| 483 | markCode(tk, c, false); |
| 484 | ++i; |
| 485 | continue; |
| 486 | } |
| 487 | |
| 488 | if (lang == Language::Lua && isLuaIdentChar(c, true)) { |
| 489 | i = consumeLuaWord(line, i, tk, info); |
| 490 | continue; |
no test coverage detected