| 122 | } |
| 123 | |
| 124 | void 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 | |
| 151 | void Uses::removeUse(const DeclarationId& id, const IndexedTopDUContext& use) |
| 152 | { |
no test coverage detected