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

Method removeDeclaration

kdevplatform/language/duchain/persistentsymboltable.cpp:329–378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

327}
328
329void PersistentSymbolTable::removeDeclaration(const IndexedQualifiedIdentifier& id,
330 const IndexedDeclaration& declaration)
331{
332 ENSURE_CHAIN_WRITE_LOCKED
333
334 PersistentSymbolTableItem item;
335 item.id = id;
336
337 LockedItemRepository::write<PersistentSymbolTable>([&item, &declaration](PersistentSymbolTableRepo& repo) {
338 Q_ASSERT_X(repo.ongoingIterations == 0, Q_FUNC_INFO, "don't call removeDeclaration directly from a visitor");
339
340 repo.declarationsCache.remove(item.id);
341
342 uint index = repo.findIndex(item);
343
344 if (index) {
345 // Check whether the item is already in the mapped list, else copy the list into the new created item
346 const PersistentSymbolTableItem* oldItem = repo.itemFromIndex(index);
347
348 EmbeddedTreeAlgorithms<IndexedDeclaration, IndexedDeclarationHandler> alg(
349 oldItem->declarations(), oldItem->declarationsSize(), oldItem->centralFreeItem);
350
351 if (alg.indexOf(declaration) == -1)
352 return;
353
354 DynamicItem<PersistentSymbolTableItem, true> editableItem = repo.dynamicItemFromIndex(index);
355
356 EmbeddedTreeRemoveItem<IndexedDeclaration, IndexedDeclarationHandler> remove(
357 const_cast<IndexedDeclaration*>(editableItem->declarations()), editableItem->declarationsSize(),
358 editableItem->centralFreeItem, declaration);
359
360 uint newSize = remove.newItemCount();
361 if (newSize != editableItem->declarationsSize()) {
362 // We need to resize. Update and fill the new item, and delete the old item.
363 item.declarationsList().resize(newSize);
364 remove.transferData(item.declarationsList().data(), newSize, &item.centralFreeItem);
365
366 repo.deleteItem(index);
367 Q_ASSERT(!repo.findIndex(item));
368 } else {
369 // We're fine, the item could be added to the existing list
370 return;
371 }
372 }
373
374 // This inserts the changed item
375 if (item.declarationsSize())
376 repo.index(item);
377 });
378}
379
380void PersistentSymbolTable::visitDeclarations(const IndexedQualifiedIdentifier& id,
381 const DeclarationVisitor& visitor) const

Callers

nothing calls this directly

Calls 11

dynamicItemFromIndexMethod · 0.80
removeMethod · 0.45
findIndexMethod · 0.45
itemFromIndexMethod · 0.45
declarationsMethod · 0.45
indexOfMethod · 0.45
newItemCountMethod · 0.45
transferDataMethod · 0.45
dataMethod · 0.45
deleteItemMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected