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

Method mergeDeclarationsInternal

kdevplatform/language/duchain/ducontext.cpp:966–1032  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

964}
965
966void DUContext::mergeDeclarationsInternal(QVector<QPair<Declaration*, int>>& definitions,
967 const CursorInRevision& position,
968 QHash<const DUContext*, bool>& hadContexts,
969 const TopDUContext* source,
970 bool searchInParents, int currentDepth) const
971{
972 ENSURE_CAN_READ
973
974 if ((currentDepth > 300 && currentDepth < 1000) || currentDepth > 1300) {
975 qCDebug(LANGUAGE) << "too much depth";
976 return;
977 }
978 DUCHAIN_D(DUContext);
979
980 if (hadContexts.contains(this) && !searchInParents)
981 return;
982
983 if (!hadContexts.contains(this)) {
984 hadContexts[this] = true;
985
986 if ((type() == DUContext::Namespace || type() == DUContext::Global) && currentDepth < 1000)
987 currentDepth += 1000;
988
989 {
990 DUContextDynamicData::VisibleDeclarationIterator it(m_dynamicData);
991 while (it) {
992 Declaration* decl = *it;
993
994 if (decl && (!position.isValid() || decl->range().start <= position))
995 definitions << qMakePair(decl, currentDepth);
996 ++it;
997 }
998 }
999
1000 for (int a = d->m_importedContextsSize() - 1; a >= 0; --a) {
1001 const Import* import(&d->m_importedContexts()[a]);
1002 DUContext* context = import->context(source);
1003 while (!context && a > 0) {
1004 --a;
1005 import = &d->m_importedContexts()[a];
1006 context = import->context(source);
1007 }
1008 if (!context)
1009 break;
1010
1011 if (context == this) {
1012 qCDebug(LANGUAGE) << "resolved self as import:" << scopeIdentifier(true);
1013 continue;
1014 }
1015
1016 if (position.isValid() && import->position.isValid() && position < import->position)
1017 continue;
1018
1019 context->mergeDeclarationsInternal(definitions,
1020 CursorInRevision::invalid(), hadContexts, source,
1021 searchInParents && context->shouldSearchInParent(
1022 InImportedParentContext) && context->parentContext()->type() == DUContext::Helper,
1023 currentDepth + 1);

Callers

nothing calls this directly

Calls 9

shouldSearchInParentMethod · 0.80
typeFunction · 0.70
invalidFunction · 0.50
containsMethod · 0.45
isValidMethod · 0.45
rangeMethod · 0.45
contextMethod · 0.45
typeMethod · 0.45
parentContextMethod · 0.45

Tested by

no test coverage detected