| 1855 | } |
| 1856 | |
| 1857 | void 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 | |
| 1891 | void DUChain::disablePersistentStorage(bool disable) |
| 1892 | { |