| 83 | } |
| 84 | |
| 85 | KDevVarLengthArray<Declaration*> DeclarationId::declarations(const TopDUContext* top) const |
| 86 | { |
| 87 | KDevVarLengthArray<Declaration*> ret; |
| 88 | |
| 89 | if (m_isDirect == false) { |
| 90 | //Find the declaration by its qualified identifier and additionalIdentity |
| 91 | const auto& id = m_indirectData.identifier; |
| 92 | |
| 93 | auto visitDeclaration = [&](const IndexedDeclaration& indexedDecl) { |
| 94 | auto decl = indexedDecl.data(); |
| 95 | if (decl && m_indirectData.additionalIdentity == decl->additionalIdentity()) { |
| 96 | // Hit |
| 97 | ret.append(decl); |
| 98 | } |
| 99 | return PersistentSymbolTable::VisitorState::Continue; |
| 100 | }; |
| 101 | |
| 102 | if (top) { |
| 103 | //Do filtering |
| 104 | PersistentSymbolTable::self().visitFilteredDeclarations(id, top->recursiveImportIndices(), |
| 105 | visitDeclaration); |
| 106 | } else { |
| 107 | //Just accept anything |
| 108 | PersistentSymbolTable::self().visitDeclarations(id, [&](const IndexedDeclaration& indexedDecl) { |
| 109 | ///@todo think this over once we don't pull in all imported top-context any more |
| 110 | //Don't trigger loading of top-contexts from here, it will create a lot of problems |
| 111 | if (DUChain::self()->isInMemory(indexedDecl.topContextIndex())) { |
| 112 | return visitDeclaration(indexedDecl); |
| 113 | } |
| 114 | return PersistentSymbolTable::VisitorState::Continue; |
| 115 | }); |
| 116 | } |
| 117 | } else { |
| 118 | Declaration* decl = m_directData.declaration(); |
| 119 | if (decl) |
| 120 | ret.append(decl); |
| 121 | } |
| 122 | |
| 123 | if (!ret.isEmpty() && m_specialization.index()) { |
| 124 | KDevVarLengthArray<Declaration*> newRet; |
| 125 | for (Declaration* decl : std::as_const(ret)) { |
| 126 | Declaration* specialized = decl->specialize(m_specialization, top ? top : decl->topContext()); |
| 127 | if (specialized) |
| 128 | newRet.append(specialized); |
| 129 | } |
| 130 | |
| 131 | return newRet; |
| 132 | } |
| 133 | return ret; |
| 134 | } |
| 135 | |
| 136 | Declaration* DeclarationId::declaration(const TopDUContext* top, bool instantiateIfRequired) const |
| 137 | { |
no test coverage detected