Add AbstractDeclarationNavigationContext, and move the html-method from
[kdevelopdvcssupport.git] / language / duchain / types / typeutils.cpp
bloba18d06b45d2e96232961109c4b3eac82154bf603
1 /*
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 "typeutils.h"
20 #include "referencetype.h"
21 #include "pointertype.h"
23 namespace TypeUtils {
24 using namespace KDevelop;
26 AbstractType::Ptr targetType(const AbstractType::Ptr& _base, const TopDUContext* /*topContext*/, bool* constant) {
28 AbstractType::Ptr base(_base);
30 ReferenceType::Ptr ref = base.cast<ReferenceType>();
31 PointerType::Ptr pnt = base.cast<PointerType>();
33 while( ref || pnt ) {
34 if( ref ) {
35 if( constant )
36 (*constant) |= static_cast<bool>(ref->modifiers() & AbstractType::ConstModifier);
37 base = ref->baseType();
38 } else {
39 if( constant )
40 (*constant) |= static_cast<bool>(pnt->modifiers() & AbstractType::ConstModifier);
41 base = pnt->baseType();
43 ref = base.cast<ReferenceType>();
44 pnt = base.cast<PointerType>();
47 return base;