diff --git a/language/duchain/duchain.cpp b/language/duchain/duchain.cpp --- a/language/duchain/duchain.cpp +++ b/language/duchain/duchain.cpp @@ -1454,14 +1454,31 @@ { if(sdDUChainPrivate->m_destroyed) return; + //Check whether the document has an attached environment-manager, and whether that one thinks the document needs to be updated. //If yes, update it. DUChainReadLocker lock( DUChain::lock() ); QMutexLocker l(&sdDUChainPrivate->m_chainsMutex); + + auto backgroundParser = ICore::self()->languageController()->backgroundParser(); TopDUContext* ctx = DUChainUtils::standardContextForUrl(doc->url(), true); - if(ctx && ctx->parsingEnvironmentFile()) - if(ctx->parsingEnvironmentFile()->needsUpdate()) - ICore::self()->languageController()->backgroundParser()->addDocument(IndexedString(doc->url())); + if(ctx && ctx->parsingEnvironmentFile()) { + if(ctx->parsingEnvironmentFile()->needsUpdate()) { + qCDebug(LANGUAGE) << "Document needs up-date, using best priority since it just got activated:" << doc->url(); + backgroundParser->addDocument(IndexedString(doc->url()), + TopDUContext::VisibleDeclarationsAndContexts, + BackgroundParser::BestPriority); + return; + } + } + + // increase priority for queued parse job of this document + if (backgroundParser->managedDocuments().contains(IndexedString(doc->url()))) { + qCDebug(LANGUAGE) << "Prioritizing activated document:" << doc->url(); + backgroundParser->addDocument(IndexedString(doc->url()), + TopDUContext::VisibleDeclarationsAndContexts, + BackgroundParser::BestPriority); + } } void DUChain::documentClosed(IDocument* document) @@ -1490,6 +1507,8 @@ auto languages = ICore::self()->languageController()->languagesForUrl(doc->url()); + qWarning() << "LOADED" << url << standardContext; + if(standardContext) { Q_ASSERT(chains.contains(standardContext)); //We have just loaded it Q_ASSERT((standardContext->url() == url)); @@ -1529,6 +1548,7 @@ return; } } + qWarning() << "LOADED2" << url << standardContext; //Add for highlighting etc. ICore::self()->languageController()->backgroundParser()->addDocument(IndexedString(doc->url()), TopDUContext::AllDeclarationsContextsAndUses);