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

Method documentActivated

plugins/clang/clangsupport.cpp:364–410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

362}
363
364void ClangSupport::documentActivated(IDocument* doc)
365{
366 TopDUContext::Features features;
367 {
368 DUChainReadLocker lock;
369 auto ctx = DUChainUtils::standardContextForUrl(doc->url());
370 if (!ctx) {
371 return;
372 }
373
374 auto file = ctx->parsingEnvironmentFile();
375 if (!file) {
376 return;
377 }
378
379 if (file->type() != CppParsingEnvironment) {
380 return;
381 }
382
383 if (file->needsUpdate()) {
384 return;
385 }
386
387 features = ctx->features();
388 }
389
390 const auto indexedUrl = IndexedString(doc->url());
391
392 auto sessionData = ClangIntegration::DUChainUtils::findParseSessionData(indexedUrl, index()->translationUnitForUrl(IndexedString(doc->url())));
393 if (sessionData) {
394 return;
395 }
396
397 if ((features & TopDUContext::AllDeclarationsContextsAndUses) != TopDUContext::AllDeclarationsContextsAndUses) {
398 // the file was parsed in simplified mode, we need to reparse it to get all data
399 // now that its opened in the editor
400 features = TopDUContext::AllDeclarationsContextsAndUses;
401 } else {
402 features = static_cast<TopDUContext::Features>(ClangParseJob::AttachASTWithoutUpdating | features);
403 if (ICore::self()->languageController()->backgroundParser()->isQueued(indexedUrl)) {
404 // The document is already scheduled for parsing (happens when opening a project with an active document)
405 // The background parser will optimize the previous request out, so we need to update highlighting
406 features = static_cast<TopDUContext::Features>(ClangParseJob::UpdateHighlighting | features);
407 }
408 }
409 ICore::self()->languageController()->backgroundParser()->addDocument(indexedUrl, features);
410}
411
412static void setKeywordCompletion(KTextEditor::View* view, bool enabled)
413{

Callers

nothing calls this directly

Calls 12

translationUnitForUrlMethod · 0.80
isQueuedMethod · 0.80
backgroundParserMethod · 0.80
languageControllerMethod · 0.80
IndexedStringClass · 0.50
indexFunction · 0.50
urlMethod · 0.45
typeMethod · 0.45
needsUpdateMethod · 0.45
featuresMethod · 0.45
addDocumentMethod · 0.45

Tested by

no test coverage detected