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

Method skipToMatchingPositions

kdevplatform/util/formattinghelpers.cpp:670–713  ·  view source on GitHub ↗

* Skips fuzzy and whitespace characters in prefix and text until @a *m_prefixFirst == @a *m_textFirst * or until a fuzzy @a *m_textFirst replaces a fuzzy @a *m_prefixFirst using @a m_fuzzyMatcher. * * @return @c true in case of success; * @c false in case of no matching characters left (successful match), * unrecoverable mismatch or match failure.

Source from the content-addressed store, hash-verified

668 * @post @a m_result is set and ready to be returned if this function returns @c false.
669 */
670 bool skipToMatchingPositions()
671 {
672 Q_ASSERT(m_prefixFirst != m_prefixLast);
673 Q_ASSERT(!m_prefixFirst->isSpace());
674
675 Q_ASSERT(m_textFirst != m_textLast);
676 Q_ASSERT(!m_textFirst->isSpace());
677
678 Q_ASSERT(*m_prefixFirst != *m_textFirst);
679
680 const bool prefixIsFuzzy = isFuzzy(*m_prefixFirst);
681 const bool textIsFuzzy = isFuzzy(*m_textFirst);
682 if (!prefixIsFuzzy && !textIsFuzzy) {
683 setUnrecoverableMismatchResult();
684 return false;
685 }
686 if (prefixIsFuzzy != textIsFuzzy) {
687 auto& first = prefixIsFuzzy ? m_prefixFirst : m_textFirst;
688 const auto last = prefixIsFuzzy ? m_prefixLast : m_textLast;
689 const auto result = skipFuzzyAndWhitespace(first, last, m_fuzzyMatcher, /*isInserted=*/textIsFuzzy);
690 switch (result) {
691 case FuzzyMatchResult::Fuzzy:
692 Q_ASSERT(first == last);
693 if (prefixIsFuzzy) {
694 setResult(HasMatched::Yes);
695 } else {
696 setUnmatchedPrefixCharacterResult();
697 }
698 return false;
699 case FuzzyMatchResult::NotFuzzy:
700 if (*m_prefixFirst == *m_textFirst) {
701 return true;
702 }
703 setUnrecoverableMismatchResult();
704 return false;
705 case FuzzyMatchResult::MatchingFailed:
706 setResult(HasMatched::No);
707 return false;
708 }
709 Q_UNREACHABLE();
710 }
711 Q_ASSERT(prefixIsFuzzy && textIsFuzzy);
712 return selectFuzzyInsertionRemovalOrReplacement();
713 }
714
715 /// Chooses between valid insertion and valid removal.
716 bool shouldRemove(const FindResult<ForwardIt>& insertionResult, const FindResult<ForwardIt>& removalResult) const

Callers

nothing calls this directly

Calls 2

isFuzzyFunction · 0.85
skipFuzzyAndWhitespaceFunction · 0.85

Tested by

no test coverage detected