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

Method add

kdevplatform/util/formattinghelpers.cpp:448–488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

446 }
447
448 FuzzyMatchResult add(const QChar* characterLocation, bool isInserted) override
449 {
450 Q_ASSERT(characterLocation);
451 const auto& validRange = m_validRanges[isInserted];
452 Q_ASSERT(characterLocation >= validRange.first);
453 Q_ASSERT(characterLocation < validRange.last);
454
455 const auto c = *characterLocation;
456 switch (c.unicode()) {
457 case '"': {
458 const bool valid =
459 addDoubleQuote(characterLocation, isInserted) && m_doubleQuoteValidator.addDoubleQuote(isInserted);
460 return valid ? FuzzyMatchResult::Fuzzy : FuzzyMatchResult::MatchingFailed;
461 }
462 case '/':
463 case '*': {
464 const auto*& prev = m_lastEndOfCommentAddresses[isInserted];
465 Q_ASSERT(!prev || prev <= characterLocation);
466 if (prev == characterLocation) {
467 // a comment sequence ending at characterLocation has been added already, do nothing else
468 } else if (characterLocation > validRange.first && prev != characterLocation - 1
469 && addIfCommentSequence(*(characterLocation - 1), c, isInserted)) {
470 // NOTE: the (prev != characterLocation - 1) check above prevents
471 // finding two comment sequences in the string "/*/".
472 prev = characterLocation;
473 } else if (characterLocation + 1 < validRange.last
474 && addIfCommentSequence(c, *(characterLocation + 1), isInserted)) {
475 prev = characterLocation + 1;
476 }
477 return FuzzyMatchResult::Fuzzy;
478 }
479 default:
480 if (!isFuzzy(c)) {
481 return FuzzyMatchResult::NotFuzzy;
482 }
483 if (isFuzzyBracket(c)) {
484 m_bracketValidator.addBracket(c, isInserted);
485 }
486 return FuzzyMatchResult::Fuzzy;
487 }
488 }
489
490 bool validate()
491 {

Calls 4

isFuzzyFunction · 0.85
isFuzzyBracketFunction · 0.85
addDoubleQuoteMethod · 0.45
addBracketMethod · 0.45

Tested by

no test coverage detected