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

Function isValidCompletionIdentifier

plugins/clang/codecompletion/context.cpp:630–647  ·  view source on GitHub ↗

* @return Whether the declaration represented by identifier @p identifier qualifies as completion result * * For example, we don't want to offer SomeClass::SomeClass as completion item to the user * (otherwise we'd end up generating code such as 's.SomeClass();') */

Source from the content-addressed store, hash-verified

628 * (otherwise we'd end up generating code such as 's.SomeClass();')
629 */
630bool isValidCompletionIdentifier(const QualifiedIdentifier& identifier)
631{
632 const int count = identifier.count();
633 if (identifier.count() < 2) {
634 return true;
635 }
636
637 const Identifier scope = identifier.at(count-2);
638 const Identifier id = identifier.last();
639 if (scope == id) {
640 return false; // is constructor
641 }
642 const QString idString = id.toString();
643 if (idString.startsWith(QLatin1Char('~')) && scope.toString() == QStringView{idString}.sliced(1)) {
644 return false; // is destructor
645 }
646 return true;
647}
648
649/**
650 * @return Whether the declaration represented by identifier @p identifier qualifies as "special" completion result

Callers 1

completionItemsMethod · 0.85

Calls 4

countMethod · 0.45
atMethod · 0.45
lastMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected