File indexing completed on 2024-05-12 04:38:01
0001 /* 0002 SPDX-FileCopyrightText: 2006-2008 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-only 0006 */ 0007 0008 #ifndef KDEVPLATFORM_FORWARDDECLARATION_H 0009 #define KDEVPLATFORM_FORWARDDECLARATION_H 0010 0011 #include "declaration.h" 0012 #include "declarationdata.h" 0013 0014 namespace KDevelop { 0015 class KDEVPLATFORMLANGUAGE_EXPORT ForwardDeclarationData 0016 : public DeclarationData 0017 { 0018 public: 0019 ForwardDeclarationData() 0020 { 0021 } 0022 ForwardDeclarationData(const ForwardDeclarationData& rhs) 0023 : DeclarationData(rhs) 0024 { 0025 } 0026 ~ForwardDeclarationData() = default; 0027 ForwardDeclarationData& operator=(const ForwardDeclarationData& rhs) = delete; 0028 }; 0029 /** 0030 * Represents a forward declaration 0031 */ 0032 class KDEVPLATFORMLANGUAGE_EXPORT ForwardDeclaration 0033 : public Declaration 0034 { 0035 public: 0036 /** 0037 * Constructor. 0038 * 0039 * If \a context is in the symbol table, the declaration will automatically be added into the symbol table. 0040 * 0041 * \param range range of the alias declaration's identifier 0042 * \param context context in which this declaration occurred 0043 * */ 0044 ForwardDeclaration(const RangeInRevision& range, DUContext* context); 0045 explicit ForwardDeclaration(ForwardDeclarationData& data); 0046 0047 ///Copy-constructor for cloning 0048 ForwardDeclaration(const ForwardDeclaration& rhs); 0049 0050 /// Destructor. 0051 ~ForwardDeclaration() override; 0052 0053 ForwardDeclaration& operator=(const ForwardDeclaration& rhs) = delete; 0054 0055 bool isForwardDeclaration() const override; 0056 0057 /** 0058 * Resolved the forward-declaration using the given import-trace. 0059 * The topcontext is needed for correct functionality, and may only be 0060 * zero when the declaration is resolved starting from the top-context 0061 * the forward-declaration is contained in. 0062 * 0063 * If this forward-declaration has a type assigned that is not derived from ForwardDeclarationType, 0064 * and that is derived from IdentifiedType, the declaration of that type is returned here. 0065 * */ 0066 virtual Declaration* resolve(const TopDUContext* topContext) const; 0067 0068 DUContext* logicalInternalContext(const TopDUContext* topContext) const override; 0069 0070 QString toString() const override; 0071 0072 enum { 0073 Identity = 10 0074 }; 0075 0076 using BaseClass = Declaration; 0077 0078 private: 0079 Declaration* clonePrivate() const override; 0080 DUCHAIN_DECLARE_DATA(ForwardDeclaration) 0081 }; 0082 } 0083 0084 #endif // KDEVPLATFORM_DECLARATION_H