| 103 | } |
| 104 | |
| 105 | void ParseProjectJob::queueFilesToParse() |
| 106 | { |
| 107 | Q_D(ParseProjectJob); |
| 108 | |
| 109 | const auto isJobKilled = [this] { |
| 110 | if (Q_UNLIKELY(isFinished())) { |
| 111 | qCDebug(LANGUAGE) << "Aborting queuing project files to parse." |
| 112 | " This job has been killed:" << objectName(); |
| 113 | return true; |
| 114 | } |
| 115 | return false; |
| 116 | }; |
| 117 | |
| 118 | if (isJobKilled()) { |
| 119 | return; |
| 120 | } |
| 121 | |
| 122 | TopDUContext::Features processingLevel = d->filesToParse.size() < |
| 123 | ICore::self()->languageController()->completionSettings()-> |
| 124 | minFilesForSimplifiedParsing() ? |
| 125 | TopDUContext::VisibleDeclarationsAndContexts : TopDUContext:: |
| 126 | SimplifiedVisibleDeclarationsAndContexts; |
| 127 | TopDUContext::Features openDocumentProcessingLevel{TopDUContext::AllDeclarationsContextsAndUses}; |
| 128 | |
| 129 | if (d->forceUpdate) { |
| 130 | if (processingLevel & TopDUContext::VisibleDeclarationsAndContexts) { |
| 131 | processingLevel = TopDUContext::AllDeclarationsContextsAndUses; |
| 132 | } |
| 133 | processingLevel |= TopDUContext::ForceUpdate; |
| 134 | openDocumentProcessingLevel |= TopDUContext::ForceUpdate; |
| 135 | } |
| 136 | |
| 137 | if (auto currentDocument = ICore::self()->documentController()->activeDocument()) { |
| 138 | const auto path = IndexedString(currentDocument->url()); |
| 139 | const auto fileIt = d->filesToParse.constFind(path); |
| 140 | if (fileIt != d->filesToParse.cend()) { |
| 141 | ICore::self()->languageController()->backgroundParser()->addDocument(path, |
| 142 | openDocumentProcessingLevel, BackgroundParser::BestPriority, this); |
| 143 | d->filesToParse.erase(fileIt); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | int priority{BackgroundParser::InitialParsePriority}; |
| 148 | const int openDocumentPriority{10}; |
| 149 | if (d->parseAllProjectSources) { |
| 150 | // Add all currently open files that belong to the project to the |
| 151 | // background-parser, so that they'll be parsed first of all. |
| 152 | const auto documents = ICore::self()->documentController()->openDocuments(); |
| 153 | for (auto* document : documents) { |
| 154 | const auto path = IndexedString(document->url()); |
| 155 | const auto fileIt = d->filesToParse.constFind(path); |
| 156 | if (fileIt != d->filesToParse.cend()) { |
| 157 | ICore::self()->languageController()->backgroundParser()->addDocument(path, |
| 158 | openDocumentProcessingLevel, openDocumentPriority, this); |
| 159 | d->filesToParse.erase(fileIt); |
| 160 | } |
| 161 | } |
| 162 | } else { |
nothing calls this directly
no test coverage detected