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

Function tryLuaLongClose

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

* @brief If line[i:] closes a Lua long-bracket form at the given level, returns the length. */

Source from the content-addressed store, hash-verified

156 * @brief If line[i:] closes a Lua long-bracket form at the given level, returns the length.
157 */
158static bool tryLuaLongClose(QStringView line, int i, int level, int& outConsume)
159{
160 if (i >= line.size() || line[i] != QLatin1Char(']'))
161 return false;
162
163 int j = i + 1;
164 int seen = 0;
165 while (seen < level && j < line.size() && line[j] == QLatin1Char('=')) {
166 ++seen;
167 ++j;
168 }
169
170 if (seen != level)
171 return false;
172
173 if (j >= line.size() || line[j] != QLatin1Char(']'))
174 return false;
175
176 outConsume = (j - i) + 1;
177 return true;
178}
179
180/**
181 * @brief Skips a quoted string literal starting at line[i] (assumes line[i] is the open quote).

Callers 1

advanceLuaLongFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected