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

Method usesCurrentRevision

kdevplatform/language/duchain/declaration.cpp:760–806  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

758}
759
760QMap<IndexedString, QVector<KTextEditor::Range>> Declaration::usesCurrentRevision() const
761{
762 ENSURE_CAN_READ
763 QMap<IndexedString, QMap<KTextEditor::Range, bool>> tempUses;
764
765 //First, search for uses within the own context
766 {
767 QMap<KTextEditor::Range, bool>& ranges(tempUses[topContext()->url()]);
768 const auto useRanges = allUses(topContext(), const_cast<Declaration*>(this));
769 for (const RangeInRevision range : useRanges) {
770 ranges[topContext()->transformFromLocalRevision(range)] = true;
771 }
772 }
773
774 DeclarationId _id = id();
775 KDevVarLengthArray<IndexedTopDUContext> useContexts = DUChain::uses()->uses(_id);
776 if (!_id.isDirect()) { // also check uses based on direct IDs
777 KDevVarLengthArray<IndexedTopDUContext> directUseContexts = DUChain::uses()->uses(id(true));
778 useContexts.append(directUseContexts.data(), directUseContexts.size());
779 }
780
781 for (const IndexedTopDUContext indexedContext : std::as_const(useContexts)) {
782 TopDUContext* context = indexedContext.data();
783 if (context) {
784 QMap<KTextEditor::Range, bool>& ranges(tempUses[context->url()]);
785 const auto useRanges = allUses(context, const_cast<Declaration*>(this));
786 for (const RangeInRevision range : useRanges) {
787 ranges[context->transformFromLocalRevision(range)] = true;
788 }
789 }
790 }
791
792 QMap<IndexedString, QVector<KTextEditor::Range>> ret;
793
794 for (QMap<IndexedString, QMap<KTextEditor::Range, bool>>::const_iterator it = tempUses.constBegin();
795 it != tempUses.constEnd(); ++it) {
796 if (!(*it).isEmpty()) {
797 auto& list = ret[it.key()];
798 list.reserve((*it).size());
799 for (QMap<KTextEditor::Range, bool>::const_iterator it2 = (*it).constBegin(); it2 != (*it).constEnd();
800 ++it2)
801 list << it2.key();
802 }
803 }
804
805 return ret;
806}
807}

Callers 2

addHighlightMethod · 0.80

Calls 15

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

Tested by 1