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

Method load

kdevplatform/language/duchain/topducontextdynamicdata.cpp:581–614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

579}
580
581TopDUContext* TopDUContextDynamicData::load(uint topContextIndex)
582{
583 QFile file(pathForTopContext(topContextIndex));
584 if (file.open(QIODevice::ReadOnly)) {
585 if (file.size() == 0) {
586 qCWarning(LANGUAGE) << "Top-context file is empty" << file.fileName();
587 return nullptr;
588 }
589
590 uint readValue;
591 file.read(reinterpret_cast<char*>(&readValue), sizeof(uint));
592 //now readValue is filled with the top-context data size
593 QByteArray topContextData = file.read(readValue);
594
595 auto* topData = reinterpret_cast<DUChainBaseData*>(topContextData.data());
596 auto* ret = dynamic_cast<TopDUContext*>(DUChainItemSystem::self().create(topData));
597 if (!ret) {
598 qCWarning(LANGUAGE) << "Cannot load a top-context from file" << file.fileName() <<
599 "- the required language-support for handling ID" << topData->classId << "is probably not loaded";
600 return nullptr;
601 }
602
603 TopDUContextDynamicData& target(*ret->m_dynamicData);
604
605 target.m_data.clear();
606 target.m_dataLoaded = false;
607 target.m_onDisk = true;
608 ret->rebuildDynamicData(nullptr, topContextIndex);
609 target.m_topContextData.append({topContextData, ( uint )0});
610 return ret;
611 } else {
612 return nullptr;
613 }
614}
615
616bool TopDUContextDynamicData::isOnDisk() const
617{

Callers

nothing calls this directly

Calls 10

pathForTopContextFunction · 0.85
openMethod · 0.45
sizeMethod · 0.45
fileNameMethod · 0.45
readMethod · 0.45
dataMethod · 0.45
createMethod · 0.45
clearMethod · 0.45
rebuildDynamicDataMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected