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

Function definitionsInRepo

kdevplatform/language/duchain/definitions.cpp:127–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125namespace {
126template<typename Repo>
127[[nodiscard]] KDevVarLengthArray<IndexedDeclaration> definitionsInRepo(const DeclarationId& id, const Repo& repo)
128{
129 KDevVarLengthArray<IndexedDeclaration> ret;
130
131 DefinitionsItem item;
132 item.declaration = id;
133 const auto collectDefinitions = [&item, &ret](const DefinitionsRepo& repo) {
134 if (const auto index = repo.findIndex(item)) {
135 const auto* const repositoryItem = repo.itemFromIndex(index);
136 FOREACH_FUNCTION (const IndexedDeclaration& decl, repositoryItem->definitions)
137 ret.append(decl);
138 }
139 };
140
141 if constexpr (std::is_same_v<Repo, std::nullptr_t>) {
142 LockedItemRepository::read<Definitions>(collectDefinitions);
143 } else {
144 static_assert(std::is_same_v<Repo, DefinitionsRepo>);
145 collectDefinitions(repo);
146 }
147
148 return ret;
149}
150
151} // unnamed namespace
152

Callers 2

operator()Method · 0.85
definitionsMethod · 0.85

Calls 3

findIndexMethod · 0.45
itemFromIndexMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected