File indexing completed on 2024-04-28 08:25:46
0001 /* 0002 SPDX-FileCopyrightText: 2008 Niko Sams <niko.sams@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only 0005 */ 0006 0007 #include "phpducontext.h" 0008 0009 #include <language/duchain/topducontext.h> 0010 #include <language/duchain/duchainregister.h> 0011 #include <language/duchain/topducontextdata.h> 0012 0013 #include <language/util/includeitem.h> 0014 0015 #include <KIO/Global> 0016 0017 #include "navigation/navigationwidget.h" 0018 0019 namespace Php 0020 { 0021 using namespace KDevelop; 0022 0023 typedef PhpDUContext<TopDUContext> PhpTopDUContext; 0024 REGISTER_DUCHAIN_ITEM_WITH_DATA(PhpTopDUContext, TopDUContextData); 0025 0026 typedef PhpDUContext<DUContext> PhpNormalDUContext; 0027 REGISTER_DUCHAIN_ITEM_WITH_DATA(PhpNormalDUContext, DUContextData); 0028 0029 template<> 0030 KDevelop::AbstractNavigationWidget* PhpDUContext<TopDUContext>::createNavigationWidget(Declaration* decl, TopDUContext* topContext, KDevelop::AbstractNavigationWidget::DisplayHints hints) const 0031 { 0032 if (decl == nullptr) { 0033 return nullptr; 0034 } else if ( decl->kind() == Declaration::Import ) { 0035 QUrl u( decl->identifier().toString() ); 0036 IncludeItem i; 0037 i.pathNumber = -1; 0038 i.name = u.fileName(); 0039 i.isDirectory = false; 0040 i.basePath = KIO::upUrl(u); 0041 0042 return new NavigationWidget( i, TopDUContextPointer(topContext), hints ); 0043 } else { 0044 return new NavigationWidget(DeclarationPointer(decl), TopDUContextPointer(topContext ? topContext : this->topContext()), hints); 0045 } 0046 } 0047 0048 template<> 0049 KDevelop::AbstractNavigationWidget* PhpDUContext<DUContext>::createNavigationWidget(Declaration* decl, TopDUContext* topContext, KDevelop::AbstractNavigationWidget::DisplayHints hints) const 0050 { 0051 if (decl == nullptr) { 0052 if (owner()) 0053 return new NavigationWidget(DeclarationPointer(owner()), TopDUContextPointer(topContext ? topContext : this->topContext()), hints); 0054 else 0055 return nullptr; 0056 } else { 0057 return new NavigationWidget(DeclarationPointer(decl), TopDUContextPointer(topContext ? topContext : this->topContext()), hints); 0058 } 0059 } 0060 0061 0062 } 0063