File indexing completed on 2024-05-12 04:38:03

0001 /*
0002     SPDX-FileCopyrightText: 2007 David Nolden <david.nolden.kdevelop@art-master.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-only
0005 */
0006 
0007 #include "localindexeddeclaration.h"
0008 
0009 #include "declaration.h"
0010 #include "topducontextdynamicdata.h"
0011 #include "topducontext.h"
0012 
0013 using namespace KDevelop;
0014 
0015 LocalIndexedDeclaration::LocalIndexedDeclaration(Declaration* decl)
0016     : m_declarationIndex(decl ? decl->m_indexInTopContext : 0)
0017 {
0018 }
0019 
0020 LocalIndexedDeclaration::LocalIndexedDeclaration(uint declarationIndex)
0021     : m_declarationIndex(declarationIndex)
0022 {
0023 }
0024 
0025 Declaration* LocalIndexedDeclaration::data(TopDUContext* top) const
0026 {
0027     if (!m_declarationIndex)
0028         return nullptr;
0029     Q_ASSERT(top);
0030     return top->m_dynamicData->declarationForIndex(m_declarationIndex);
0031 }
0032 
0033 bool LocalIndexedDeclaration::isLoaded(TopDUContext* top) const
0034 {
0035     if (!m_declarationIndex)
0036         return false;
0037 
0038     Q_ASSERT(top);
0039     return top->m_dynamicData->isDeclarationForIndexLoaded(m_declarationIndex);
0040 }