| 362 | } |
| 363 | |
| 364 | void 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 | |
| 412 | static void setKeywordCompletion(KTextEditor::View* view, bool enabled) |
| 413 | { |
nothing calls this directly
no test coverage detected