1 /* This 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.
19 #include "aliasdeclaration.h"
21 #include "ducontext.h"
22 #include "duchainregister.h"
23 #include "types/delayedtype.h"
28 REGISTER_DUCHAIN_ITEM(AliasDeclaration
);
30 AliasDeclaration::AliasDeclaration(const AliasDeclaration
& rhs
)
31 : Declaration(*new AliasDeclarationData(*rhs
.d_func())) {
32 setSmartRange(rhs
.smartRange(), DocumentRangeObject::DontOwn
);
35 AliasDeclaration::AliasDeclaration(const SimpleRange
& range
, DUContext
* context
)
36 : Declaration(*new AliasDeclarationData
, range
)
38 d_func_dynamic()->setClassId(this);
41 setContext( context
);
44 AliasDeclaration::AliasDeclaration(AliasDeclarationData
& data
) : Declaration(data
) {
48 AliasDeclaration::~AliasDeclaration()
52 Declaration
* AliasDeclaration::clonePrivate() const {
53 return new AliasDeclaration(*this);
56 QString
AliasDeclaration::toString() const {
57 if( aliasedDeclaration().isValid() )
58 return QString("Alias %1 as %2").arg(aliasedDeclaration().declaration()->qualifiedIdentifier().toString()).arg(identifier().toString());
60 return QString("Lost alias %1").arg(identifier().toString());
63 void AliasDeclaration::setAliasedDeclaration(const IndexedDeclaration
& decl
) {
64 d_func_dynamic()->m_aliasedDeclaration
= decl
;
65 Declaration
* aliased
= decl
.data();
67 Declaration::setAbstractType(aliased
->abstractType());
70 IndexedDeclaration
AliasDeclaration::aliasedDeclaration() const {
71 return d_func()->m_aliasedDeclaration
;
74 void AliasDeclaration::setAbstractType(AbstractType::Ptr type
) {
75 Declaration::setAbstractType(type
);
79 // kate: space-indent on; indent-width 2; tab-width 4; replace-tabs on; auto-insert-doxygen on