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

0001 /*
0002     SPDX-FileCopyrightText: 2006 Hamish Rodda <rodda@kde.org>
0003     SPDX-FileCopyrightText: 2007-2009 David Nolden <david.nolden.kdevelop@art-master.de>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only
0006 */
0007 
0008 #include "localindexedducontext.h"
0009 
0010 #include "ducontextdata.h"
0011 #include "ducontext.h"
0012 #include "topducontextdynamicdata.h"
0013 #include "ducontextdynamicdata.h"
0014 #include "topducontext.h"
0015 
0016 using namespace KDevelop;
0017 
0018 LocalIndexedDUContext::LocalIndexedDUContext(uint contextIndex)
0019     : m_contextIndex(contextIndex)
0020 {
0021 }
0022 
0023 LocalIndexedDUContext::LocalIndexedDUContext(DUContext* ctx)
0024 {
0025     if (ctx) {
0026         m_contextIndex = ctx->m_dynamicData->m_indexInTopContext;
0027     } else {
0028         m_contextIndex = 0;
0029     }
0030 }
0031 
0032 bool LocalIndexedDUContext::isLoaded(TopDUContext* top) const
0033 {
0034     if (!m_contextIndex)
0035         return false;
0036     else
0037         return top->m_dynamicData->isContextForIndexLoaded(m_contextIndex);
0038 }
0039 
0040 DUContext* LocalIndexedDUContext::data(TopDUContext* top) const
0041 {
0042     if (!m_contextIndex)
0043         return nullptr;
0044     else
0045         return top->m_dynamicData->contextForIndex(m_contextIndex);
0046 }