File indexing completed on 2024-05-05 16:42:29

0001 /*
0002     SPDX-FileCopyrightText: 2011-2013 Sven Brauch <svenbrauch@googlemail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "pythonducontext.h"
0008 
0009 #include <language/duchain/topducontext.h>
0010 #include <language/duchain/topducontextdata.h>
0011 #include <language/duchain/duchainregister.h>
0012 #include <language/duchain/duchainpointer.h>
0013 
0014 #include "navigation/navigationwidget.h"
0015 
0016 #include <QDebug>
0017 #include "duchaindebug.h"
0018 
0019 using namespace KDevelop;
0020 
0021 namespace Python {
0022 
0023 REGISTER_DUCHAIN_ITEM_WITH_DATA(PythonTopDUContext, TopDUContextData);
0024 
0025 REGISTER_DUCHAIN_ITEM_WITH_DATA(PythonNormalDUContext, DUContextData);
0026 
0027 template<>
0028 KDevelop::AbstractNavigationWidget* PythonTopDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext,
0029                                                     KDevelop::AbstractNavigationWidget::DisplayHints hints) const {
0030     if ( ! decl ) {
0031         qCDebug(KDEV_PYTHON_DUCHAIN) << "no declaration, not returning navigationwidget";
0032         return nullptr;
0033     }
0034     return new NavigationWidget(DeclarationPointer(decl), TopDUContextPointer(topContext), hints);
0035 }
0036 
0037 template<>
0038 KDevelop::AbstractNavigationWidget* PythonNormalDUContext::createNavigationWidget(Declaration* decl, TopDUContext* topContext,
0039                                                        KDevelop::AbstractNavigationWidget::DisplayHints hints) const {
0040     if ( ! decl ) {
0041         qCDebug(KDEV_PYTHON_DUCHAIN) << "no declaration, not returning navigationwidget";
0042         return nullptr;
0043     }
0044     return new NavigationWidget(DeclarationPointer(decl), TopDUContextPointer(topContext), hints);
0045 }
0046 
0047 }