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

Method loadChain

kdevplatform/language/duchain/duchain.cpp:648–690  ·  view source on GitHub ↗

Makes sure that the chain with the given index is loaded @warning m_chainsMutex must NOT be locked when this is called

Source from the content-addressed store, hash-verified

646 ///Makes sure that the chain with the given index is loaded
647 ///@warning m_chainsMutex must NOT be locked when this is called
648 void loadChain(uint index, QSet<uint>& loaded)
649 {
650 QMutexLocker l(&m_chainsMutex);
651
652 if (!hasChainForIndex(index)) {
653 if (!Algorithm::insert(m_loading, index).inserted) {
654 //It's probably being loaded by another thread. So wait until the load is ready
655 while (m_loading.contains(index)) {
656 l.unlock();
657 qCDebug(LANGUAGE) << "waiting for another thread to load index" << index;
658 QThread::usleep(50000);
659 l.relock();
660 }
661 loaded.insert(index);
662 return;
663 }
664 loaded.insert(index);
665
666 l.unlock();
667 qCDebug(LANGUAGE) << "loading top-context" << index;
668 TopDUContext* chain = TopDUContextDynamicData::load(index);
669 if (chain) {
670 chain->setParsingEnvironmentFile(loadInformation(chain->ownIndex()));
671
672 if (!chain->usingImportsCache()) {
673 //Eventually also load all the imported chains, so the import-structure is built
674 const auto importedParentContexts = chain->DUContext::importedParentContexts();
675 for (const DUContext::Import& import : importedParentContexts) {
676 if (!loaded.contains(import.topContextIndex())) {
677 loadChain(import.topContextIndex(), loaded);
678 }
679 }
680 }
681 chain->rebuildDynamicImportStructure();
682
683 chain->setInDuChain(true);
684 instance->addDocumentChain(chain);
685 }
686
687 l.relock();
688 m_loading.remove(index);
689 }
690 }
691
692 ///Stores all environment-information
693 ///Also makes sure that all information that stays is referenced, so it stays alive.

Callers

nothing calls this directly

Calls 12

insertFunction · 0.85
relockMethod · 0.80
usingImportsCacheMethod · 0.80
setInDuChainMethod · 0.80
addDocumentChainMethod · 0.80
containsMethod · 0.45
unlockMethod · 0.45
insertMethod · 0.45
ownIndexMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected