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

Method addUse

kdevplatform/language/duchain/uses.cpp:124–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124void Uses::addUse(const DeclarationId& id, const IndexedTopDUContext& use)
125{
126 UsesItem item;
127 item.declaration = id;
128 item.usesList().append(use);
129 UsesRequestItem request(item);
130
131 LockedItemRepository::write<Uses>([&](UsesRepo& repo) {
132 uint index = repo.findIndex(item);
133
134 if (index) {
135 // Check whether the item is already in the mapped list, else copy the list into the new created item
136 const UsesItem* oldItem = repo.itemFromIndex(index);
137 for (unsigned int a = 0; a < oldItem->usesSize(); ++a) {
138 if (oldItem->uses()[a] == use)
139 return; // Already there
140 item.usesList().append(oldItem->uses()[a]);
141 }
142
143 repo.deleteItem(index);
144 }
145
146 // This inserts the changed item
147 repo.index(request);
148 });
149}
150
151void Uses::removeUse(const DeclarationId& id, const IndexedTopDUContext& use)
152{

Callers 1

Calls 6

appendMethod · 0.45
findIndexMethod · 0.45
itemFromIndexMethod · 0.45
usesMethod · 0.45
deleteItemMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected