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

Method addDefinition

kdevplatform/language/duchain/definitions.cpp:199–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199void Definitions::addDefinition(const DeclarationId& id, const IndexedDeclaration& definition)
200{
201 DefinitionsItem item;
202 item.declaration = id;
203 item.definitionsList().append(definition);
204 DefinitionsRequestItem request(item);
205
206 LockedItemRepository::write<Definitions>([&](DefinitionsRepo& repo) {
207 uint index = repo.findIndex(item);
208
209 if (index) {
210 // Check whether the item is already in the mapped list, else copy the list into the new created item
211 const DefinitionsItem* oldItem = repo.itemFromIndex(index);
212 for (unsigned int a = 0; a < oldItem->definitionsSize(); ++a) {
213 if (oldItem->definitions()[a] == definition)
214 return; // Already there
215 item.definitionsList().append(oldItem->definitions()[a]);
216 }
217
218 repo.deleteItem(index);
219 }
220
221 // This inserts the changed item
222 repo.index(request);
223 });
224}
225
226void Definitions::removeDefinition(const DeclarationId& id, const IndexedDeclaration& definition)
227{

Callers 2

ifFunction · 0.80
testDefinitionsMethod · 0.80

Calls 6

appendMethod · 0.45
findIndexMethod · 0.45
itemFromIndexMethod · 0.45
definitionsMethod · 0.45
deleteItemMethod · 0.45
indexMethod · 0.45

Tested by 1

testDefinitionsMethod · 0.64