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

Function classDeclarationForContext

plugins/clang/codecompletion/context.cpp:724–751  ·  view source on GitHub ↗

If any parent of this context is a class, the closest class declaration is returned, nullptr otherwise

Source from the content-addressed store, hash-verified

722
723/// If any parent of this context is a class, the closest class declaration is returned, nullptr otherwise
724Declaration* classDeclarationForContext(const DUContextPointer& context, const CursorInRevision& position)
725{
726 auto parent = context;
727 while (parent) {
728 if (parent->type() == DUContext::Class) {
729 break;
730 }
731
732 if (auto owner = parent->owner()) {
733 // Work-around for out-of-line methods. They have Helper context instead of Class context
734 if (owner->context() && owner->context()->type() == DUContext::Helper) {
735 auto qid = owner->qualifiedIdentifier();
736 qid.pop();
737
738 QSet<Declaration*> tmp;
739 auto decl = findDeclaration(qid, context, position, tmp);
740
741 if (decl && decl->internalContext() && decl->internalContext()->type() == DUContext::Class) {
742 parent = decl->internalContext();
743 break;
744 }
745 }
746 }
747 parent = parent->parentContext();
748 }
749
750 return parent ? parent->owner() : nullptr;
751}
752
753class LookAheadItemMatcher
754{

Callers 1

completionItemsMethod · 0.85

Calls 8

findDeclarationFunction · 0.85
typeMethod · 0.45
ownerMethod · 0.45
contextMethod · 0.45
qualifiedIdentifierMethod · 0.45
popMethod · 0.45
internalContextMethod · 0.45
parentContextMethod · 0.45

Tested by

no test coverage detected