| 341 | } |
| 342 | |
| 343 | QList<CompletionTreeItemPointer> CodeCompletionContext::completionsInContext(const DUContextPointer& context, |
| 344 | CompletionInContextFlags flags, |
| 345 | CompletionItem::Decoration decoration) |
| 346 | { |
| 347 | QList<CompletionTreeItemPointer> items; |
| 348 | DUChainReadLocker lock; |
| 349 | |
| 350 | if (context) { |
| 351 | const auto declarations = context->allDeclarations( |
| 352 | CursorInRevision::invalid(), |
| 353 | context->topContext(), |
| 354 | !flags.testFlag(CompletionOnlyLocal) |
| 355 | ); |
| 356 | |
| 357 | for (const DeclarationDepthPair& decl : declarations) { |
| 358 | DeclarationPointer declaration(decl.first); |
| 359 | CompletionItem::Decoration decorationOfThisItem = decoration; |
| 360 | |
| 361 | if (declaration->identifier() == globalImportIdentifier()) { |
| 362 | continue; |
| 363 | } if (declaration->qualifiedIdentifier().isEmpty()) { |
| 364 | continue; |
| 365 | } else if (context->owner() && ( |
| 366 | context->owner()->kind() == Declaration::Namespace || |
| 367 | context->owner()->kind() == Declaration::NamespaceAlias |
| 368 | ) && decl.second != 0 && decl.second != 1001) { |
| 369 | // Only show the local declarations of modules, or the declarations |
| 370 | // immediately in its imported parent contexts (that are global |
| 371 | // contexts, hence the distance of 1001). This prevents "String()", |
| 372 | // "QtQuick1.0" and "builtins" from being listed when the user |
| 373 | // types "PlasmaCore.". |
| 374 | continue; |
| 375 | } else if (decorationOfThisItem == CompletionItem::NoDecoration && |
| 376 | declaration->abstractType() && |
| 377 | declaration->abstractType()->whichType() == AbstractType::TypeFunction) { |
| 378 | // Decorate function calls with brackets |
| 379 | decorationOfThisItem = CompletionItem::Brackets; |
| 380 | } else if (flags.testFlag(CompletionHideWrappers)) { |
| 381 | auto* classDecl = dynamic_cast<ClassDeclaration*>(declaration.data()); |
| 382 | |
| 383 | if (classDecl && classDecl->classType() == ClassDeclarationData::Interface) { |
| 384 | continue; |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | items << CompletionTreeItemPointer(new CompletionItem(declaration, decl.second, decorationOfThisItem)); |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | return items; |
| 393 | } |
| 394 | |
| 395 | QList<CompletionTreeItemPointer> CodeCompletionContext::fieldCompletions(const QString& expression, |
| 396 | CompletionItem::Decoration decoration) |
nothing calls this directly
no test coverage detected