1 /* 2 This file is part of KDevelop 3 SPDX-FileCopyrightText: 2008 Milian Wolff <mail@milianw.de> 4 5 SPDX-License-Identifier: LGPL-2.0-or-later 6 */ 7 8 #include "functiondeclaration.h" 9 10 #include <language/duchain/duchainregister.h> 11 #include <language/duchain/types/functiontype.h> 12 13 namespace Php { 14 REGISTER_DUCHAIN_ITEM(FunctionDeclaration); 15 FunctionDeclaration(const FunctionDeclaration & rhs)16FunctionDeclaration::FunctionDeclaration(const FunctionDeclaration& rhs) 17 : KDevelop::FunctionDeclaration(*new FunctionDeclarationData(*rhs.d_func())) 18 { 19 } 20 FunctionDeclaration(const KDevelop::RangeInRevision & range,KDevelop::DUContext * context)21FunctionDeclaration::FunctionDeclaration(const KDevelop::RangeInRevision& range, KDevelop::DUContext* context) 22 : KDevelop::FunctionDeclaration(*new FunctionDeclarationData, range) 23 { 24 d_func_dynamic()->setClassId(this); 25 if (context) { 26 setContext(context); 27 } 28 } 29 FunctionDeclaration(FunctionDeclarationData & data)30FunctionDeclaration::FunctionDeclaration(FunctionDeclarationData& data) 31 : KDevelop::FunctionDeclaration(data) 32 { 33 } 34 FunctionDeclaration(FunctionDeclarationData & data,const KDevelop::RangeInRevision & range,KDevelop::DUContext * context)35FunctionDeclaration::FunctionDeclaration(FunctionDeclarationData& data, const KDevelop::RangeInRevision& range, KDevelop::DUContext* context) 36 : KDevelop::FunctionDeclaration(data, range) 37 { 38 if (context) { 39 setContext(context); 40 } 41 } 42 ~FunctionDeclaration()43FunctionDeclaration::~FunctionDeclaration() 44 { 45 } 46 clonePrivate() const47KDevelop::Declaration* FunctionDeclaration::clonePrivate() const 48 { 49 return new FunctionDeclaration(*this); 50 } 51 prettyName() const52KDevelop::IndexedString FunctionDeclaration::prettyName() const 53 { 54 return d_func()->prettyName; 55 } 56 setPrettyName(const KDevelop::IndexedString & name)57void FunctionDeclaration::setPrettyName( const KDevelop::IndexedString& name ) 58 { 59 d_func_dynamic()->prettyName = name; 60 } 61 toString() const62QString FunctionDeclaration::toString() const 63 { 64 if( !abstractType() ) 65 return Declaration::toString(); 66 67 TypePtr<KDevelop::FunctionType> function = type<KDevelop::FunctionType>(); 68 Q_ASSERT(function); 69 70 return QString("%1 %2 %3").arg(function->partToString( KDevelop::FunctionType::SignatureReturn )) 71 .arg(prettyName().str()) 72 .arg(function->partToString( KDevelop::FunctionType::SignatureArguments )); 73 } 74 75 } 76