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 #ifndef KDEVPLATFORM_LOCALINDEXEDDECLARATION_H 0008 #define KDEVPLATFORM_LOCALINDEXEDDECLARATION_H 0009 0010 #include <language/languageexport.h> 0011 #include <QtGlobal> 0012 0013 namespace KDevelop { 0014 class TopDUContext; 0015 class Declaration; 0016 0017 /** 0018 * Represents a declaration only by its index within the top-context 0019 */ 0020 class KDEVPLATFORMLANGUAGE_EXPORT LocalIndexedDeclaration 0021 { 0022 public: 0023 LocalIndexedDeclaration(Declaration* decl = nullptr); 0024 LocalIndexedDeclaration(uint declarationIndex); 0025 0026 /** 0027 * \note Duchain must be read locked 0028 */ 0029 Declaration* data(TopDUContext* top) const; 0030 0031 bool operator==(const LocalIndexedDeclaration& rhs) const 0032 { 0033 return m_declarationIndex == rhs.m_declarationIndex; 0034 } 0035 uint hash() const 0036 { 0037 return m_declarationIndex * 23; 0038 } 0039 0040 bool isValid() const 0041 { 0042 return m_declarationIndex != 0; 0043 } 0044 0045 bool operator<(const LocalIndexedDeclaration& rhs) const 0046 { 0047 return m_declarationIndex < rhs.m_declarationIndex; 0048 } 0049 0050 /** 0051 * Index of the Declaration within the top context 0052 */ 0053 uint localIndex() const 0054 { 0055 return m_declarationIndex; 0056 } 0057 0058 bool isLoaded(TopDUContext* top) const; 0059 0060 private: 0061 uint m_declarationIndex; 0062 }; 0063 } 0064 0065 Q_DECLARE_TYPEINFO(KDevelop::LocalIndexedDeclaration, Q_MOVABLE_TYPE); 0066 0067 #endif // KDEVPLATFORM_LOCALINDEXEDDECLARATION_H