| 964 | } |
| 965 | |
| 966 | void 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); |
nothing calls this directly
no test coverage detected