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

Method ParamIterator

kdevplatform/language/duchain/stringhelpers.cpp:474–511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

472ParamIterator::~ParamIterator() = default;
473
474ParamIterator::ParamIterator(QStringView parens, QStringView source, int offset)
475 : d_ptr(new ParamIteratorPrivate{parens, source})
476{
477 Q_D(ParamIterator);
478
479 const auto foundPos = findOpeningBracketOrEnd(parens, source, offset);
480 if (foundPos != source.size()) {
481 if (parens.size() > 2 && source[foundPos] == parens[2]) {
482 //We have to stop the search, because we found an interrupting end-sign before the opening-paren
483 d->m_prefix = d->sourceRange(offset, foundPos);
484 d->m_curEnd = d->m_end = d->m_cur = foundPos;
485 return;
486 }
487
488 Q_ASSERT(source[foundPos] == parens[0]);
489 //We have a valid prefix before an opening-paren. Take the prefix, and start iterating parameters.
490 d->m_cur = foundPos + 1;
491 d->m_curEnd = d->next();
492 if (d->m_curEnd != d->m_source.length()) {
493 d->m_prefix = d->sourceRange(offset, foundPos);
494 d->m_end = d->m_source.size();
495
496 if (d->m_source[d->m_curEnd] == d->m_parens[1]) {
497 const auto singleParam = d->sourceRange(d->m_cur, d->m_curEnd);
498 if (consistsOfWhitespace(singleParam)) {
499 // Only whitespace characters are present between parentheses => assume that
500 // there are zero parameters, not a single empty parameter, and stop iterating.
501 d->m_cur = d->m_end = d->m_curEnd + 1;
502 }
503 }
504
505 return;
506 } // else: the paren was not closed. It might be an identifier like "operator<", so count everything as prefix.
507 } // else: we have neither found an ending-character, nor an opening-paren, so take the whole input and end.
508
509 d->m_prefix = d->m_source.sliced(offset);
510 d->m_curEnd = d->m_end = d->m_cur = d->m_source.length();
511}
512
513ParamIterator& ParamIterator::operator ++()
514{

Callers

nothing calls this directly

Calls 6

findOpeningBracketOrEndFunction · 0.85
consistsOfWhitespaceFunction · 0.85
sourceRangeMethod · 0.80
sizeMethod · 0.45
nextMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected