• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDevelop Platform Libraries
  • Sitemap
  • Contact Us
 

language/duchain

functiondeclaration.cpp

00001 /* This  is part of KDevelop
00002     Copyright 2002-2005 Roberto Raggi <roberto@kdevelop.org>
00003     Copyright 2006 Adam Treat <treat@kde.org>
00004     Copyright 2006-2007 Hamish Rodda <rodda@kde.org>
00005     Copyright 2007-2008 David Nolden <david.nolden.kdevelop@art-master.de>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License version 2 as published by the Free Software Foundation.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019    Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include "functiondeclaration.h"
00023 #include "ducontext.h"
00024 #include "duchainregister.h"
00025 #include "types/functiontype.h"
00026 
00027 namespace KDevelop
00028 {
00029 
00030 REGISTER_DUCHAIN_ITEM(FunctionDeclaration);
00031 
00032 DEFINE_LIST_MEMBER_HASH(FunctionDeclarationData, m_defaultParameters, IndexedString)
00033 
00034 FunctionDeclaration::FunctionDeclaration(FunctionDeclarationData& data) : FunctionDeclarationBase(data) {
00035 }
00036 
00037 FunctionDeclaration::FunctionDeclaration(FunctionDeclarationData& data, const SimpleRange& range) : FunctionDeclarationBase(data, range) {
00038 }
00039 
00040 FunctionDeclaration::FunctionDeclaration(const FunctionDeclaration& rhs) : FunctionDeclarationBase(*new FunctionDeclarationData( *rhs.d_func() )) {
00041   setSmartRange(rhs.smartRange(), DocumentRangeObject::DontOwn);
00042 }
00043 
00044 FunctionDeclaration::FunctionDeclaration(const SimpleRange& range, DUContext* context)
00045   : FunctionDeclarationBase(*new FunctionDeclarationData, range)
00046 {
00047   d_func_dynamic()->setClassId(this);
00048   if( context )
00049     setContext( context );
00050 }
00051 
00052 FunctionDeclaration::~FunctionDeclaration()
00053 {
00054 }
00055 
00056 Declaration* FunctionDeclaration::clonePrivate() const {
00057   return new FunctionDeclaration(*this);
00058 }
00059 
00060 bool FunctionDeclaration::isFunctionDeclaration() const
00061 {
00062   return true;
00063 }
00064 
00065 void FunctionDeclaration::setAbstractType(AbstractType::Ptr type) {
00066   if( type && !type.cast<FunctionType>() ) {
00067     kDebug() << "wrong type attached to function declaration:" << type->toString();
00068   }
00069   Declaration::setAbstractType(type);
00070 }
00071 
00072 QString FunctionDeclaration::toString() const {
00073   AbstractType::Ptr type = abstractType();
00074   if( !type )
00075     return Declaration::toString();
00076 
00077   TypePtr<FunctionType> function = type.cast<FunctionType>();
00078   if(function) {
00079     return QString("%1 %2 %3").arg(function->partToString( FunctionType::SignatureReturn )).arg(identifier().toString()).arg(function->partToString( FunctionType::SignatureArguments ));
00080   }else{
00081     return Declaration::toString();
00082   }
00083 }
00084 
00085 uint FunctionDeclaration::additionalIdentity() const
00086 {
00087   if(abstractType())
00088     return abstractType()->hash();
00089   else
00090     return 0;
00091 }
00092 
00093 const IndexedString* FunctionDeclaration::defaultParameters() const
00094 {
00095   return d_func()->m_defaultParameters();
00096 }
00097 
00098 unsigned int FunctionDeclaration::defaultParametersSize() const
00099 {
00100   return d_func()->m_defaultParametersSize();
00101 }
00102 
00103 void FunctionDeclaration::addDefaultParameter(const IndexedString& str)
00104 {
00105   d_func_dynamic()->m_defaultParametersList().append(str);
00106 }
00107 
00108 void FunctionDeclaration::clearDefaultParameters()
00109 {
00110   d_func_dynamic()->m_defaultParametersList().clear();
00111 }
00112 
00113 }
00114 // kate: space-indent on; indent-width 2; tab-width 4; replace-tabs on; auto-insert-doxygen on

language/duchain

Skip menu "language/duchain"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDevelop Platform Libraries

Skip menu "KDevelop Platform Libraries"
  • interfaces
  • language
  •   codegen
  •   duchain
  •   editor
  • outputview
  • project
  • shell
  • sublime
  • util
  • vcs
Generated for KDevelop Platform Libraries by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal