File indexing completed on 2024-05-12 04:38:05
0001 /* 0002 SPDX-FileCopyrightText: 2008 David Nolden <david.nolden.kdevelop@art-master.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KDEVPLATFORM_TOPDUCONTEXTDATA_H 0008 #define KDEVPLATFORM_TOPDUCONTEXTDATA_H 0009 0010 #include "ducontextdata.h" 0011 #include "topducontext.h" 0012 #include "declarationid.h" 0013 #include "problem.h" 0014 0015 #include <serialization/indexedstring.h> 0016 0017 namespace KDevelop { 0018 KDEVPLATFORMLANGUAGE_EXPORT DECLARE_LIST_MEMBER_HASH(TopDUContextData, m_usedDeclarationIds, DeclarationId) 0019 KDEVPLATFORMLANGUAGE_EXPORT DECLARE_LIST_MEMBER_HASH(TopDUContextData, m_problems, LocalIndexedProblem) 0020 0021 class KDEVPLATFORMLANGUAGE_EXPORT TopDUContextData 0022 : public DUContextData 0023 { 0024 public: 0025 explicit TopDUContextData(const IndexedString& url) 0026 : DUContextData() 0027 , m_url(url) 0028 , m_ownIndex(0) 0029 , m_currentUsedDeclarationIndex(0) 0030 { 0031 initializeAppendedLists(); 0032 } 0033 0034 TopDUContextData(const TopDUContextData& rhs) 0035 : DUContextData(rhs) 0036 { 0037 initializeAppendedLists(); 0038 copyListsFrom(rhs); 0039 m_features = rhs.m_features; 0040 m_url = rhs.m_url; 0041 m_currentUsedDeclarationIndex = rhs.m_currentUsedDeclarationIndex; 0042 m_ownIndex = rhs.m_ownIndex; 0043 m_importsCache = rhs.m_importsCache; 0044 } 0045 0046 ~TopDUContextData() 0047 { 0048 freeAppendedLists(); 0049 } 0050 0051 TopDUContextData& operator=(const TopDUContextData& rhs) = delete; 0052 0053 TopDUContext::Features m_features; 0054 0055 IndexedString m_url; 0056 uint m_ownIndex; 0057 0058 ///If this is not empty, it means that the cache is used instead of the implicit structure. 0059 TopDUContext::IndexedRecursiveImports m_importsCache; 0060 0061 ///Is used to count up the used declarations while building uses 0062 uint m_currentUsedDeclarationIndex; 0063 0064 START_APPENDED_LISTS_BASE(TopDUContextData, DUContextData); 0065 ///Maps a declarationIndex to a DeclarationId, which is used when the entry in m_usedDeclaration is zero. 0066 APPENDED_LIST_FIRST(TopDUContextData, DeclarationId, m_usedDeclarationIds); 0067 APPENDED_LIST(TopDUContextData, LocalIndexedProblem, m_problems, m_usedDeclarationIds); 0068 END_APPENDED_LISTS(TopDUContextData, m_problems); 0069 0070 private: 0071 static void updateImportCacheRecursion(IndexedTopDUContext currentContext, std::set<uint>& visited); 0072 static void updateImportCacheRecursion(uint baseIndex, IndexedTopDUContext currentContext, 0073 TopDUContext::IndexedRecursiveImports& imports); 0074 friend class TopDUContext; 0075 }; 0076 } 0077 #endif