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

Function analyzeLine

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

* @brief Computes outdent/indent deltas for a single line and updates the carry-over state. */

Source from the content-addressed store, hash-verified

431 * @brief Computes outdent/indent deltas for a single line and updates the carry-over state.
432 */
433static 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;

Callers 1

scanAllLinesFunction · 0.85

Calls 12

advanceJsBlockCommentFunction · 0.85
advanceJsTemplateFunction · 0.85
advanceLuaLongFunction · 0.85
tryEnterStringLiteralFunction · 0.85
markCodeFunction · 0.85
isLuaIdentCharFunction · 0.85
consumeLuaWordFunction · 0.85
isJsIdentCharFunction · 0.85
consumeJsWordFunction · 0.85
finalizeJsHangingFunction · 0.85
tryEnterCommentFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected