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

Method uses

kdevplatform/language/duchain/declaration.cpp:675–720  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

673}
674
675QMap<IndexedString, QVector<RangeInRevision>> Declaration::uses() const
676{
677 ENSURE_CAN_READ
678 QMap<IndexedString, QMap<RangeInRevision, bool>> tempUses;
679
680 //First, search for uses within the own context
681 {
682 QMap<RangeInRevision, bool>& ranges(tempUses[topContext()->url()]);
683 const auto useRanges = allUses(topContext(), const_cast<Declaration*>(this));
684 for (const RangeInRevision range : useRanges) {
685 ranges[range] = true;
686 }
687 }
688
689 DeclarationId _id = id();
690 KDevVarLengthArray<IndexedTopDUContext> useContexts = DUChain::uses()->uses(_id);
691 if (!_id.isDirect()) { // also check uses based on direct IDs
692 KDevVarLengthArray<IndexedTopDUContext> directUseContexts = DUChain::uses()->uses(id(true));
693 useContexts.append(directUseContexts.data(), directUseContexts.size());
694 }
695
696 for (const IndexedTopDUContext indexedContext : std::as_const(useContexts)) {
697 TopDUContext* context = indexedContext.data();
698 if (context) {
699 QMap<RangeInRevision, bool>& ranges(tempUses[context->url()]);
700 const auto useRanges = allUses(context, const_cast<Declaration*>(this));
701 for (const RangeInRevision range : useRanges) {
702 ranges[range] = true;
703 }
704 }
705 }
706
707 QMap<IndexedString, QVector<RangeInRevision>> ret;
708
709 for (QMap<IndexedString, QMap<RangeInRevision, bool>>::const_iterator it = tempUses.constBegin();
710 it != tempUses.constEnd(); ++it) {
711 if (!(*it).isEmpty()) {
712 auto& list = ret[it.key()];
713 list.reserve((*it).size());
714 for (QMap<RangeInRevision, bool>::const_iterator it2 = (*it).constBegin(); it2 != (*it).constEnd(); ++it2)
715 list << it2.key();
716 }
717 }
718
719 return ret;
720}
721
722bool hasDeclarationUse(DUContext* context, int declIdx)
723{

Callers 2

hasDeclarationUseFunction · 0.45
usesCurrentRevisionMethod · 0.45

Calls 13

topContextFunction · 0.85
constBeginMethod · 0.80
constEndMethod · 0.80
allUsesFunction · 0.70
idFunction · 0.50
urlMethod · 0.45
isDirectMethod · 0.45
appendMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
isEmptyMethod · 0.45
keyMethod · 0.45

Tested by

no test coverage detected