1 /* This file is part of KDevelop
2 Copyright 2008 David Nolden <david.nolden.kdevelop@art-master.de>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
18 #ifndef CLASSFUNCTIONDEFINITION_H
19 #define CLASSFUNCTIONDEFINITION_H
21 #include "functiondeclaration.h"
22 #include "../languageexport.h"
24 using namespace KDevelop
;
27 struct KDEVPLATFORMLANGUAGE_EXPORT FunctionDefinitionData
: public FunctionDeclarationData
{
28 //Holds the declaration id for this definition, if this is a definition with separate declaration
29 DeclarationId m_declaration
;
31 ///A FunctionDefinition represents a function-definition that is assigned to a separate function-declaration.
32 ///It allows mapping from definition to declaration and from declaration to definition.
33 class KDEVPLATFORMLANGUAGE_EXPORT FunctionDefinition
: public FunctionDeclaration
{
35 FunctionDefinition(const SimpleRange
& range
, DUContext
* context
);
36 FunctionDefinition(FunctionDefinitionData
& data
);
37 ~FunctionDefinition();
40 * Find the declaration for this definition, if one exists.
42 * @param topContext the top-context from which to search
43 * \returns the declaration matching this definition, otherwise null if no matching declaration has been found.
45 Declaration
* declaration(TopDUContext
* topContext
= 0) const;
47 ///Returns true if a Declaration has been assigned to this Definition
48 bool hasDeclaration() const;
50 ///Attaches this definition to the given declaration persistently.
51 void setDeclaration(Declaration
* declaration
);
58 * Find the definition for the given declaration, if one exists.
60 * \returns the definition matching this declaration, otherwise null if no matching definition has been found.
62 static FunctionDefinition
* definition(const Declaration
* decl
);
65 FunctionDefinition (const FunctionDefinition
& rhs
);
67 virtual Declaration
* clonePrivate() const;
68 DUCHAIN_DECLARE_DATA(FunctionDefinition
)