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

Method updateContextForUrl

kdevplatform/language/duchain/duchain.cpp:1857–1889  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1855}
1856
1857void DUChain::updateContextForUrl(const IndexedString& document, TopDUContext::Features minFeatures,
1858 QObject* notifyReady, int priority) const
1859{
1860 // the call to DUChainUtils::standardContextForUrl(...) takes surprisingly long
1861 // however if a document is already scheduled for parsing, we know it needs parsing and can
1862 // skip the expansive check.
1863 auto* backgroundParser = ICore::self()->languageController()->backgroundParser();
1864 // atomically check if the document is already scheduled and if so add a new listener:
1865 bool listenerAdded = backgroundParser->addListenerToDocumentIfExist(document, minFeatures, priority, notifyReady);
1866 // if the document isn't already scheduled and the listener was added:
1867 if (!listenerAdded)
1868 {
1869 DUChainReadLocker lock(DUChain::lock());
1870 // check if the document needs parsing
1871 TopDUContext* standardContext = DUChainUtils::standardContextForUrl(document.toUrl());
1872 if (standardContext && standardContext->parsingEnvironmentFile() &&
1873 !standardContext->parsingEnvironmentFile()->needsUpdate() &&
1874 standardContext->parsingEnvironmentFile()->featuresSatisfied(minFeatures)) {
1875 // if the document doesn't need parsing we can immedistely return the already parsed context to the listener
1876 lock.unlock();
1877 if (notifyReady) {
1878 // do not remove qualification KDevelop:: or invokeMethod will not find the proper method
1879 QMetaObject::invokeMethod(notifyReady, "updateReady", Qt::DirectConnection,
1880 Q_ARG(KDevelop::IndexedString, document),
1881 Q_ARG(KDevelop::ReferencedTopDUContext, ReferencedTopDUContext(standardContext)));
1882 }
1883 } else {
1884 ///Start a parse-job for the given document
1885 lock.unlock();
1886 backgroundParser->addDocument(document, minFeatures, priority, notifyReady);
1887 }
1888 }
1889}
1890
1891void DUChain::disablePersistentStorage(bool disable)
1892{

Callers 8

executeActionMethod · 0.80
startCollectingMethod · 0.80
parseMethod · 0.80
addToBackgroundParserMethod · 0.80
textChangedMethod · 0.80
findTestCasesMethod · 0.80
forceFullUpdateMethod · 0.80
textDocumentCreatedMethod · 0.80

Calls 10

backgroundParserMethod · 0.80
languageControllerMethod · 0.80
featuresSatisfiedMethod · 0.80
toUrlMethod · 0.45
needsUpdateMethod · 0.45
unlockMethod · 0.45
addDocumentMethod · 0.45

Tested by 2

parseMethod · 0.64
findTestCasesMethod · 0.64