Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/language/backgroundparser/parseprojectjob.cpp
Show First 20 Lines • Show All 144 Lines • ▼ Show 20 Line(s) | 142 | if (d->forceUpdate) { | |||
---|---|---|---|---|---|
145 | } | 145 | } | ||
146 | processingLevel = ( TopDUContext::Features )(TopDUContext::ForceUpdate | processingLevel); | 146 | processingLevel = ( TopDUContext::Features )(TopDUContext::ForceUpdate | processingLevel); | ||
147 | } | 147 | } | ||
148 | 148 | | |||
149 | if (auto currentDocument = ICore::self()->documentController()->activeDocument()) { | 149 | if (auto currentDocument = ICore::self()->documentController()->activeDocument()) { | ||
150 | const auto path = IndexedString(currentDocument->url()); | 150 | const auto path = IndexedString(currentDocument->url()); | ||
151 | auto fileIt = d->filesToParse.find(path); | 151 | auto fileIt = d->filesToParse.find(path); | ||
152 | if (fileIt != d->filesToParse.end()) { | 152 | if (fileIt != d->filesToParse.end()) { | ||
153 | ICore::self()->languageController()->backgroundParser()->addDocument(path, | 153 | ICore::self()->languageController()->backgroundParser()->addControlledDocument(path, this, | ||
154 | TopDUContext::AllDeclarationsContextsAndUses, BackgroundParser::BestPriority, | 154 | TopDUContext::AllDeclarationsContextsAndUses, BackgroundParser::BestPriority, | ||
155 | this); | 155 | this); | ||
156 | d->filesToParse.erase(fileIt); | 156 | d->filesToParse.erase(fileIt); | ||
157 | } | 157 | } | ||
158 | } | 158 | } | ||
159 | 159 | | |||
160 | // Add all currently open files that belong to the project to the background-parser, so that they'll be parsed first of all | 160 | // Add all currently open files that belong to the project to the background-parser, so that they'll be parsed first of all | ||
161 | const auto documents = ICore::self()->documentController()->openDocuments(); | 161 | const auto documents = ICore::self()->documentController()->openDocuments(); | ||
162 | for (auto* document : documents) { | 162 | for (auto* document : documents) { | ||
163 | const auto path = IndexedString(document->url()); | 163 | const auto path = IndexedString(document->url()); | ||
164 | auto fileIt = d->filesToParse.find(path); | 164 | auto fileIt = d->filesToParse.find(path); | ||
165 | if (fileIt != d->filesToParse.end()) { | 165 | if (fileIt != d->filesToParse.end()) { | ||
166 | ICore::self()->languageController()->backgroundParser()->addDocument(path, | 166 | ICore::self()->languageController()->backgroundParser()->addControlledDocument(path, this, | ||
167 | TopDUContext::AllDeclarationsContextsAndUses, 10, | 167 | TopDUContext::AllDeclarationsContextsAndUses, 10, | ||
168 | this); | 168 | this); | ||
169 | d->filesToParse.erase(fileIt); | 169 | d->filesToParse.erase(fileIt); | ||
170 | } | 170 | } | ||
171 | } | 171 | } | ||
172 | 172 | | |||
173 | if (!d->forceAll && !ICore::self()->projectController()->parseAllProjectSources()) { | 173 | if (!d->forceAll && !ICore::self()->projectController()->parseAllProjectSources()) { | ||
174 | return; | 174 | return; | ||
175 | } | 175 | } | ||
176 | 176 | | |||
177 | // prevent UI-lockup by processing events after some files | 177 | // prevent UI-lockup by processing events after some files | ||
178 | // esp. noticeable when dealing with huge projects | 178 | // esp. noticeable when dealing with huge projects | ||
179 | const int processAfter = 1000; | 179 | const int processAfter = 1000; | ||
180 | int processed = 0; | 180 | int processed = 0; | ||
181 | // guard against reentrancy issues, see also bug 345480 | 181 | // guard against reentrancy issues, see also bug 345480 | ||
182 | auto crashGuard = QPointer<ParseProjectJob> {this}; | 182 | auto crashGuard = QPointer<ParseProjectJob> {this}; | ||
183 | for (const IndexedString& url : qAsConst(d->filesToParse)) { | 183 | for (const IndexedString& url : qAsConst(d->filesToParse)) { | ||
184 | ICore::self()->languageController()->backgroundParser()->addDocument(url, processingLevel, | 184 | ICore::self()->languageController()->backgroundParser()->addControlledDocument(url, this, processingLevel, | ||
185 | BackgroundParser::InitialParsePriority, | 185 | BackgroundParser::InitialParsePriority, | ||
186 | this); | 186 | this); | ||
187 | ++processed; | 187 | ++processed; | ||
188 | if (processed == processAfter) { | 188 | if (processed == processAfter) { | ||
189 | QApplication::processEvents(); | 189 | QApplication::processEvents(); | ||
190 | if (!crashGuard) { | 190 | if (!crashGuard) { | ||
191 | return; | 191 | return; | ||
192 | } | 192 | } | ||
193 | processed = 0; | 193 | processed = 0; | ||
194 | } | 194 | } | ||
195 | } | 195 | } | ||
196 | } | 196 | } |