| 557 | } |
| 558 | |
| 559 | void DocumentChangeSetPrivate::updateFiles() |
| 560 | { |
| 561 | ModificationRevisionSet::clearCache(); |
| 562 | const auto files = changes.keys(); |
| 563 | for (const IndexedString& file : files) { |
| 564 | ModificationRevision::clearModificationCache(file); |
| 565 | } |
| 566 | |
| 567 | if (updatePolicy != DocumentChangeSet::NoUpdate && ICore::self()) { |
| 568 | // The active document should be updated first, so that the user sees the results instantly |
| 569 | if (IDocument* activeDoc = ICore::self()->documentController()->activeDocument()) { |
| 570 | ICore::self()->languageController()->backgroundParser()->addDocument(IndexedString(activeDoc->url())); |
| 571 | } |
| 572 | |
| 573 | // If there are currently open documents that now need an update, update them too |
| 574 | const auto documents = ICore::self()->languageController()->backgroundParser()->managedDocuments(); |
| 575 | for (const IndexedString& doc : documents) { |
| 576 | DUChainReadLocker lock(DUChain::lock()); |
| 577 | TopDUContext* top = DUChainUtils::standardContextForUrl(doc.toUrl(), true); |
| 578 | if ((top && top->parsingEnvironmentFile() && top->parsingEnvironmentFile()->needsUpdate()) || !top) { |
| 579 | lock.unlock(); |
| 580 | ICore::self()->languageController()->backgroundParser()->addDocument(doc); |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | // Eventually update _all_ affected files |
| 585 | const auto files = changes.keys(); |
| 586 | for (const IndexedString& file : files) { |
| 587 | if (!file.toUrl().isValid()) { |
| 588 | qCWarning(LANGUAGE) << "Trying to apply changes to an invalid document"; |
| 589 | continue; |
| 590 | } |
| 591 | |
| 592 | ICore::self()->languageController()->backgroundParser()->addDocument(file); |
| 593 | } |
| 594 | } |
| 595 | } |
| 596 | } |
no test coverage detected