1 /*
2     SPDX-FileCopyrightText: 2006 Hamish Rodda <rodda@kde.org>
3     SPDX-FileCopyrightText: 2007-2008 David Nolden <david.nolden.kdevelop@art-master.de>
4 
5     SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef DUCONTEXTDATA_H
9 #define DUCONTEXTDATA_H
10 
11 #include "duchainbase.h"
12 #include "ducontext.h"
13 #include "duchainpointer.h"
14 #include "declaration.h"
15 #include "use.h"
16 #include <language/languageexport.h>
17 
18 #include "localindexeddeclaration.h"
19 #include "localindexedducontext.h"
20 
21 namespace KDevelop {
22 class DUContext;
23 
DECLARE_LIST_MEMBER_HASH(DUContextData,m_childContexts,LocalIndexedDUContext)24 KDEVPLATFORMLANGUAGE_EXPORT DECLARE_LIST_MEMBER_HASH(DUContextData, m_childContexts, LocalIndexedDUContext)
25 KDEVPLATFORMLANGUAGE_EXPORT DECLARE_LIST_MEMBER_HASH(DUContextData, m_importers, IndexedDUContext)
26 KDEVPLATFORMLANGUAGE_EXPORT DECLARE_LIST_MEMBER_HASH(DUContextData, m_importedContexts, DUContext::Import)
27 KDEVPLATFORMLANGUAGE_EXPORT DECLARE_LIST_MEMBER_HASH(DUContextData, m_localDeclarations, LocalIndexedDeclaration)
28 KDEVPLATFORMLANGUAGE_EXPORT DECLARE_LIST_MEMBER_HASH(DUContextData, m_uses, Use)
29 
30 ///This class contains data that needs to be stored to disk
31 class KDEVPLATFORMLANGUAGE_EXPORT DUContextData
32     : public DUChainBaseData
33 {
34 public:
35     DUContextData();
36     ~DUContextData();
37     DUContextData(const DUContextData& rhs);
38     DUContextData& operator=(const DUContextData&) = delete;
39 
40     IndexedQualifiedIdentifier m_scopeIdentifier;
41     IndexedDeclaration m_owner;
42     using Import = DUContext::Import;
43     START_APPENDED_LISTS_BASE(DUContextData, DUChainBaseData);
44     APPENDED_LIST_FIRST(DUContextData, Import, m_importedContexts);
45     APPENDED_LIST(DUContextData, LocalIndexedDUContext, m_childContexts, m_importedContexts);
46 
47     ///@todo Create an additional structure for importing to/from "temporary" contexts and classes in a way that it persists while saving/loading,
48     ///      and doesn't require changing a top-contexts data only because a class was derived from.
49     APPENDED_LIST(DUContextData, IndexedDUContext, m_importers, m_childContexts);
50 
51     ///@warning: Whenever m_localDeclarations is read or written, the duchain must be locked
52     APPENDED_LIST(DUContextData, LocalIndexedDeclaration, m_localDeclarations, m_importers);
53     /**
54      * Vector of all uses in this context
55      * Mutable for range synchronization
56      * */
57     APPENDED_LIST(DUContextData, Use, m_uses, m_localDeclarations);
58     END_APPENDED_LISTS(DUContextData, m_uses);
59 
60     DUContext::ContextType m_contextType;
61     bool m_inSymbolTable : 1;
62     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.
63     bool m_propagateDeclarations : 1;
64 };
65 }
66 
67 #endif
68