MCPcopy Create free account
hub / github.com/KDE/kdevelop / readContents

Method readContents

kdevplatform/language/backgroundparser/parsejob.cpp:265–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263}
264
265KDevelop::ProblemPointer ParseJob::readContents()
266{
267 Q_D(ParseJob);
268
269 Q_ASSERT(!d->hasReadContents);
270 d->hasReadContents = true;
271
272 QString localFile(document().toUrl().toLocalFile());
273 QFileInfo fileInfo(localFile);
274
275 QDateTime lastModified = fileInfo.lastModified();
276
277 d->tracker = ICore::self()->languageController()->backgroundParser()->trackerForUrl(document());
278
279 //Try using an artificial code-representation, which overrides everything else
280 if (artificialCodeRepresentationExists(document())) {
281 CodeRepresentation::Ptr repr = createCodeRepresentation(document());
282 d->contents.contents = repr->text().toUtf8();
283 qCDebug(LANGUAGE) << "took contents for " << document().str() << " from artificial code-representation";
284 return KDevelop::ProblemPointer();
285 }
286
287 bool hadTracker = false;
288 if (d->tracker) {
289 ForegroundLock lock;
290 if (DocumentChangeTracker* t = d->tracker.data()) {
291 // The file is open in an editor
292 d->previousRevision = t->revisionAtLastReset();
293
294 t->reset(); // Reset the tracker to the current revision
295 Q_ASSERT(t->revisionAtLastReset());
296
297 d->contents.contents = t->document()->text().toUtf8();
298 d->contents.modification =
299 KDevelop::ModificationRevision(lastModified, t->revisionAtLastReset()->revision());
300
301 d->revision = t->acquireRevision(d->contents.modification.revision);
302 hadTracker = true;
303 }
304 }
305 if (!hadTracker) {
306 // We have to load the file from disk
307
308 if (fileInfo.size() > d->maximumFileSize) {
309 KFormat f;
310
311 KDevelop::ProblemPointer p(new Problem());
312 p->setSource(IProblem::Disk);
313 p->setDescription(i18nc("%1: filename", "Skipped file that is too large: '%1'", localFile));
314 p->setExplanation(i18nc("%1: file size, %2: limit file size",
315 "The file is %1 and exceeds the limit of %2.",
316 f.formatByteSize(fileInfo.size()),
317 f.formatByteSize(d->maximumFileSize)));
318 p->setFinalLocation(DocumentRange(document(), KTextEditor::Range::invalid()));
319 qCWarning(LANGUAGE) << p->description() << p->explanation();
320 return p;
321 }
322 QFile file(localFile);

Callers

nothing calls this directly

Calls 15

createCodeRepresentationFunction · 0.85
toLocalFileMethod · 0.80
trackerForUrlMethod · 0.80
backgroundParserMethod · 0.80
languageControllerMethod · 0.80
strMethod · 0.80
revisionAtLastResetMethod · 0.80
acquireRevisionMethod · 0.80
DocumentRangeFunction · 0.50
invalidFunction · 0.50

Tested by

no test coverage detected