| 1669 | } |
| 1670 | |
| 1671 | DUContext* DUContext::Import::context(const TopDUContext* topContext, bool instantiateIfRequired) const |
| 1672 | { |
| 1673 | if (m_declaration.isValid()) { |
| 1674 | Declaration* decl = m_declaration.declaration(topContext, instantiateIfRequired); |
| 1675 | //This first case rests on the assumption that no context will ever import a function's expression context |
| 1676 | //More accurately, that no specialized or cross-topContext imports will, but if the former assumption fails the latter will too |
| 1677 | if (auto* functionDecl = dynamic_cast<AbstractFunctionDeclaration*>(decl)) { |
| 1678 | if (functionDecl->internalFunctionContext()) { |
| 1679 | return functionDecl->internalFunctionContext(); |
| 1680 | } else { |
| 1681 | qCWarning(LANGUAGE) << "Import of function declaration without internal function context encountered!"; |
| 1682 | } |
| 1683 | } |
| 1684 | if (decl) |
| 1685 | return decl->logicalInternalContext(topContext); |
| 1686 | else |
| 1687 | return nullptr; |
| 1688 | } else { |
| 1689 | return m_context.data(); |
| 1690 | } |
| 1691 | } |
| 1692 | |
| 1693 | bool DUContext::Import::isDirect() const |
| 1694 | { |