Add AbstractDeclarationNavigationContext, and move the html-method from
[kdevelopdvcssupport.git] / language / duchain / namespacealiasdeclaration.cpp
blob97422dadf57a601b3d78007d2b9aeaa6f9a9a3b0
1 /* This is part of KDevelop
2 Copyright 2007 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 "namespacealiasdeclaration.h"
21 #include "ducontext.h"
22 #include "duchainregister.h"
24 namespace KDevelop
27 REGISTER_DUCHAIN_ITEM(NamespaceAliasDeclaration);
29 NamespaceAliasDeclaration::NamespaceAliasDeclaration(const NamespaceAliasDeclaration& rhs)
30 : Declaration(*new NamespaceAliasDeclarationData(*rhs.d_func())) {
31 setSmartRange(rhs.smartRange(), DocumentRangeObject::DontOwn);
34 NamespaceAliasDeclaration::NamespaceAliasDeclaration(const SimpleRange& range, DUContext* context)
35 : Declaration(*new NamespaceAliasDeclarationData, range)
37 d_func_dynamic()->setClassId(this);
38 setKind(NamespaceAlias);
39 if( context )
40 setContext( context );
43 NamespaceAliasDeclaration::NamespaceAliasDeclaration(NamespaceAliasDeclarationData& data) : Declaration(data) {
47 QualifiedIdentifier NamespaceAliasDeclaration::importIdentifier() const {
48 return d_func()->m_importIdentifier.identifier();
51 void NamespaceAliasDeclaration::setImportIdentifier(const QualifiedIdentifier& id) {
52 d_func_dynamic()->m_importIdentifier = id;
55 NamespaceAliasDeclaration::~NamespaceAliasDeclaration()
59 Declaration* NamespaceAliasDeclaration::clonePrivate() const {
60 return new NamespaceAliasDeclaration(*this);
63 void NamespaceAliasDeclaration::setAbstractType(AbstractType::Ptr type) {
64 //A namespace-import does not have a type, so ignore any set type
65 Q_UNUSED(type);
68 QString NamespaceAliasDeclaration::toString() const {
69 DUCHAIN_D(NamespaceAliasDeclaration);
70 if( identifier() != globalImportIdentifier )
71 return QString("Import %1 as %2").arg(d->m_importIdentifier.identifier().toString()).arg(identifier().toString());
72 else
73 return QString("Import %1").arg(d->m_importIdentifier.identifier().toString());
77 // kate: space-indent on; indent-width 2; tab-width 4; replace-tabs on; auto-insert-doxygen on