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

Function tryLuaLongOpen

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

* @brief If line[i:] opens a Lua long-bracket form, returns its level and length. */

Source from the content-addressed store, hash-verified

133 * @brief If line[i:] opens a Lua long-bracket form, returns its level and length.
134 */
135static bool tryLuaLongOpen(QStringView line, int i, int& outLevel, int& outConsume)
136{
137 if (i >= line.size() || line[i] != QLatin1Char('['))
138 return false;
139
140 int level = 0;
141 int j = i + 1;
142 while (j < line.size() && line[j] == QLatin1Char('=')) {
143 ++level;
144 ++j;
145 }
146
147 if (j >= line.size() || line[j] != QLatin1Char('['))
148 return false;
149
150 outLevel = level;
151 outConsume = (j - i) + 1;
152 return true;
153}
154
155/**
156 * @brief If line[i:] closes a Lua long-bracket form at the given level, returns the length.

Callers 2

tryEnterCommentFunction · 0.85
tryEnterStringLiteralFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected