| 197 | } |
| 198 | |
| 199 | void 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 | |
| 226 | void Definitions::removeDefinition(const DeclarationId& id, const IndexedDeclaration& definition) |
| 227 | { |