File indexing completed on 2024-05-12 04:37:56

0001 /*
0002     SPDX-FileCopyrightText: 2008 David Nolden <david.nolden.kdevelop@art-master.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-only
0005 */
0006 
0007 #ifndef KDEVPLATFORM_ALIASDECLARATION_H
0008 #define KDEVPLATFORM_ALIASDECLARATION_H
0009 
0010 #include "classmemberdeclaration.h"
0011 #include "classmemberdeclarationdata.h"
0012 #include "duchainpointer.h"
0013 #include "declarationdata.h"
0014 
0015 namespace KDevelop {
0016 class KDEVPLATFORMLANGUAGE_EXPORT AliasDeclarationData
0017     : public ClassMemberDeclarationData
0018 {
0019 public:
0020     AliasDeclarationData() {}
0021     AliasDeclarationData(const AliasDeclarationData& rhs)
0022         : ClassMemberDeclarationData(rhs)
0023         , m_aliasedDeclaration(rhs.m_aliasedDeclaration)
0024     {
0025     }
0026     ~AliasDeclarationData() = default;
0027     AliasDeclarationData& operator=(const AliasDeclarationData& rhs) = delete;
0028 
0029     IndexedDeclaration m_aliasedDeclaration;
0030 };
0031 /**
0032  * An alias declaration maps one declaration to another.
0033  * While searching in the duchain, an AliasDeclaration is transparently
0034  * replaced by its aliased declaration.
0035  */
0036 class KDEVPLATFORMLANGUAGE_EXPORT AliasDeclaration
0037     : public ClassMemberDeclaration
0038 {
0039 public:
0040     /// Copy constructor \param rhs declaration to copy
0041     AliasDeclaration(const AliasDeclaration& rhs);
0042     /**
0043      * Constructs an AliasDeclaration. The default value for isNamespaceAlias is true.
0044      *
0045      * \param range range of the alias declaration's identifier
0046      * \param context context in which this declaration occurred
0047      */
0048     AliasDeclaration(const RangeInRevision& range, DUContext* context);
0049 
0050     explicit AliasDeclaration(AliasDeclarationData& data);
0051     /// Destructor
0052     ~AliasDeclaration() override;
0053 
0054     AliasDeclaration& operator=(const AliasDeclaration& rhs) = delete;
0055 
0056     /**
0057      * An AliasDeclaration cannot have a type, so setAbstractType does nothing here.
0058      *
0059      * \param type ignored type
0060      */
0061     void setAbstractType(AbstractType::Ptr type) override;
0062 
0063     /**
0064      * Set the declaration that is aliased by this declaration.
0065      *
0066      * \param decl the declaration that this declaration references
0067      */
0068     void setAliasedDeclaration(const IndexedDeclaration& decl);
0069 
0070     /**
0071      * Access the declaration that is aliased by this declaration.
0072      *
0073      * \returns the aliased declaration
0074      */
0075     IndexedDeclaration aliasedDeclaration() const;
0076 
0077     QString toString() const override;
0078 
0079     enum {
0080         Identity = 6
0081     };
0082 
0083 private:
0084     Declaration* clonePrivate() const override;
0085     DUCHAIN_DECLARE_DATA(AliasDeclaration)
0086 };
0087 }
0088 
0089 #endif // KDEVPLATFORM_FUNCTIONDECLARATION_H