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

0001 /*
0002     SPDX-FileCopyrightText: 2006 Hamish Rodda <rodda@kde.org>
0003     SPDX-FileCopyrightText: 2007-2008 David Nolden <david.nolden.kdevelop@art-master.de>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef DUCONTEXTDATA_H
0009 #define DUCONTEXTDATA_H
0010 
0011 #include "duchainbase.h"
0012 #include "ducontext.h"
0013 #include "duchainpointer.h"
0014 #include "declaration.h"
0015 #include "use.h"
0016 #include <language/languageexport.h>
0017 
0018 #include "localindexeddeclaration.h"
0019 #include "localindexedducontext.h"
0020 
0021 namespace KDevelop {
0022 class DUContext;
0023 
0024 KDEVPLATFORMLANGUAGE_EXPORT DECLARE_LIST_MEMBER_HASH(DUContextData, m_childContexts, LocalIndexedDUContext)
0025 KDEVPLATFORMLANGUAGE_EXPORT DECLARE_LIST_MEMBER_HASH(DUContextData, m_importers, IndexedDUContext)
0026 KDEVPLATFORMLANGUAGE_EXPORT DECLARE_LIST_MEMBER_HASH(DUContextData, m_importedContexts, DUContext::Import)
0027 KDEVPLATFORMLANGUAGE_EXPORT DECLARE_LIST_MEMBER_HASH(DUContextData, m_localDeclarations, LocalIndexedDeclaration)
0028 KDEVPLATFORMLANGUAGE_EXPORT DECLARE_LIST_MEMBER_HASH(DUContextData, m_uses, Use)
0029 
0030 ///This class contains data that needs to be stored to disk
0031 class KDEVPLATFORMLANGUAGE_EXPORT DUContextData
0032     : public DUChainBaseData
0033 {
0034 public:
0035     DUContextData();
0036     ~DUContextData();
0037     DUContextData(const DUContextData& rhs);
0038     DUContextData& operator=(const DUContextData&) = delete;
0039 
0040     IndexedQualifiedIdentifier m_scopeIdentifier;
0041     IndexedDeclaration m_owner;
0042     using Import = DUContext::Import;
0043     START_APPENDED_LISTS_BASE(DUContextData, DUChainBaseData);
0044     APPENDED_LIST_FIRST(DUContextData, Import, m_importedContexts);
0045     APPENDED_LIST(DUContextData, LocalIndexedDUContext, m_childContexts, m_importedContexts);
0046 
0047     ///@todo Create an additional structure for importing to/from "temporary" contexts and classes in a way that it persists while saving/loading,
0048     ///      and doesn't require changing a top-contexts data only because a class was derived from.
0049     APPENDED_LIST(DUContextData, IndexedDUContext, m_importers, m_childContexts);
0050 
0051     ///@warning: Whenever m_localDeclarations is read or written, the duchain must be locked
0052     APPENDED_LIST(DUContextData, LocalIndexedDeclaration, m_localDeclarations, m_importers);
0053     /**
0054      * Vector of all uses in this context
0055      * Mutable for range synchronization
0056      * */
0057     APPENDED_LIST(DUContextData, Use, m_uses, m_localDeclarations);
0058     END_APPENDED_LISTS(DUContextData, m_uses);
0059 
0060     DUContext::ContextType m_contextType;
0061     bool m_inSymbolTable : 1;
0062     bool m_anonymousInParent : 1; //Whether this context was added anonymously into the parent. This means that it cannot be found as child-context in the parent.
0063     bool m_propagateDeclarations : 1;
0064 };
0065 }
0066 
0067 #endif