MCPcopy Create free account
hub / github.com/KDE/kdevelop / findClosingAngleBracket

Function findClosingAngleBracket

kdevplatform/language/duchain/stringhelpers.cpp:260–293  ·  view source on GitHub ↗

Finds in @p str the position of a fitting closing angle bracket for the opening angle bracket @p str[@p pos] == '<'. @return the position of a fitting closing bracket or str.size() if not found.

Source from the content-addressed store, hash-verified

258/// Finds in @p str the position of a fitting closing angle bracket for the opening angle bracket @p str[@p pos] == '<'.
259/// @return the position of a fitting closing bracket or str.size() if not found.
260int findClosingAngleBracket(QStringView str, int pos)
261{
262 Q_ASSERT(pos >= 0 && pos < str.size());
263 Q_ASSERT(str[pos] == QLatin1Char{'<'});
264
265 int depth = 1;
266
267 for (++pos; pos < str.size(); ++pos) {
268 switch (str[pos].unicode()) {
269 case '<':
270 if (!isOperator(str, pos)) {
271 ++depth;
272 }
273 break;
274 case '>':
275 if (!isOperatorOrArrowOperator(str, pos)) {
276 if (--depth == 0) {
277 return pos;
278 }
279 }
280 break;
281 case '(':
282 case '[':
283 case '{':
284 pos = findClosingNonAngleBracket(str, pos);
285 break;
286 default:
287 pos = trySkipStringOrCharLiteralOrComment(str, pos);
288 }
289 }
290
291 Q_ASSERT(depth > 0);
292 return str.size();
293}
294
295/// Finds in @p str the position of @p parens[0] or @p parens[2] starting from @p pos at the top level.
296/// @return the position of the found symbol or str.size() if not found.

Callers 2

findOpeningBracketOrEndFunction · 0.85
findCommaOrEndFunction · 0.85

Calls 5

isOperatorFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected