File indexing completed on 2024-05-12 04:38:02
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_CLASSFUNCTIONDEFINITION_H 0008 #define KDEVPLATFORM_CLASSFUNCTIONDEFINITION_H 0009 0010 #include "functiondeclaration.h" 0011 #include <language/languageexport.h> 0012 0013 namespace KDevelop { 0014 class KDEVPLATFORMLANGUAGE_EXPORT FunctionDefinitionData 0015 : public FunctionDeclarationData 0016 { 0017 public: 0018 0019 //Holds the declaration id for this definition, if this is a definition with separate declaration 0020 DeclarationId m_declaration; 0021 }; 0022 ///A FunctionDefinition represents a function-definition that is assigned to a separate function-declaration. 0023 ///It allows mapping from definition to declaration and from declaration to definition. 0024 class KDEVPLATFORMLANGUAGE_EXPORT FunctionDefinition 0025 : public FunctionDeclaration 0026 { 0027 public: 0028 FunctionDefinition(const RangeInRevision& range, DUContext* context); 0029 explicit FunctionDefinition(FunctionDefinitionData& data); 0030 ~FunctionDefinition() override; 0031 0032 FunctionDefinition& operator=(const FunctionDefinition& rhs) = delete; 0033 0034 /** 0035 * Find the declaration for this definition, if one exists. 0036 * 0037 * @param topContext the top-context from which to search 0038 * \returns the declaration matching this definition, otherwise null if no matching declaration has been found. 0039 * */ 0040 Declaration* declaration(const TopDUContext* topContext = nullptr) const; 0041 0042 ///Returns true if a Declaration has been assigned to this Definition 0043 bool hasDeclaration() const; 0044 0045 ///Attaches this definition to the given declaration persistently. 0046 void setDeclaration(Declaration* declaration); 0047 0048 enum { 0049 Identity = 21 0050 }; 0051 0052 /** 0053 * Find the definition for the given declaration, if one exists. 0054 * 0055 * \returns the definition matching this declaration, otherwise null if no matching definition has been found. 0056 * */ 0057 static Declaration* definition(const Declaration* decl); 0058 0059 protected: 0060 FunctionDefinition (const FunctionDefinition& rhs); 0061 0062 private: 0063 Declaration* clonePrivate() const override; 0064 DUCHAIN_DECLARE_DATA(FunctionDefinition) 0065 }; 0066 } 0067 0068 #endif