If any parent of this context is a class, the closest class declaration is returned, nullptr otherwise
| 722 | |
| 723 | /// If any parent of this context is a class, the closest class declaration is returned, nullptr otherwise |
| 724 | Declaration* classDeclarationForContext(const DUContextPointer& context, const CursorInRevision& position) |
| 725 | { |
| 726 | auto parent = context; |
| 727 | while (parent) { |
| 728 | if (parent->type() == DUContext::Class) { |
| 729 | break; |
| 730 | } |
| 731 | |
| 732 | if (auto owner = parent->owner()) { |
| 733 | // Work-around for out-of-line methods. They have Helper context instead of Class context |
| 734 | if (owner->context() && owner->context()->type() == DUContext::Helper) { |
| 735 | auto qid = owner->qualifiedIdentifier(); |
| 736 | qid.pop(); |
| 737 | |
| 738 | QSet<Declaration*> tmp; |
| 739 | auto decl = findDeclaration(qid, context, position, tmp); |
| 740 | |
| 741 | if (decl && decl->internalContext() && decl->internalContext()->type() == DUContext::Class) { |
| 742 | parent = decl->internalContext(); |
| 743 | break; |
| 744 | } |
| 745 | } |
| 746 | } |
| 747 | parent = parent->parentContext(); |
| 748 | } |
| 749 | |
| 750 | return parent ? parent->owner() : nullptr; |
| 751 | } |
| 752 | |
| 753 | class LookAheadItemMatcher |
| 754 | { |
no test coverage detected