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

0001 /*
0002     SPDX-FileCopyrightText: 2013 Sven Brauch <svenbrauch@googlemail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef PYTHONDUCONTEXT_H
0008 #define PYTHONDUCONTEXT_H
0009 
0010 #include <QString>
0011 #include <language/duchain/ducontext.h>
0012 #include <language/editor/modificationrevision.h>
0013 
0014 namespace KDevelop
0015 {
0016     class Declaration;
0017     class TopDUContext;
0018 }
0019 
0020 namespace Python
0021 {
0022 
0023 template<class BaseContext, int IdentityT>
0024 class PythonDUContext : public BaseContext
0025 {
0026 public:
0027     template<class Data>
0028     PythonDUContext(Data& data) : BaseContext(data) {
0029     }
0030 
0031     ///Parameters will be reached to the base-class
0032     template<class Param1, class Param2>
0033     PythonDUContext(const Param1& p1, const Param2& p2, bool isInstantiationContext) : BaseContext(p1, p2, isInstantiationContext) {
0034         static_cast<KDevelop::DUChainBase*>(this)->d_func_dynamic()->setClassId(this);
0035     }
0036 
0037     ///Both parameters will be reached to the base-class. This fits TopDUContext.
0038     template<class Param1, class Param2, class Param3>
0039     PythonDUContext(const Param1& p1, const Param2& p2, const Param3& p3) : BaseContext(p1, p2, p3) {
0040         static_cast<KDevelop::DUChainBase*>(this)->d_func_dynamic()->setClassId(this);
0041     }
0042     template<class Param1, class Param2>
0043     PythonDUContext(const Param1& p1, const Param2& p2) : BaseContext(p1, p2) {
0044         static_cast<KDevelop::DUChainBase*>(this)->d_func_dynamic()->setClassId(this);
0045     }
0046 
0047     KDevelop::AbstractNavigationWidget* createNavigationWidget(KDevelop::Declaration* decl, KDevelop::TopDUContext* topContext,
0048                                             KDevelop::AbstractNavigationWidget::DisplayHints hints) const override;
0049 
0050     enum {
0051         Identity = IdentityT
0052     };
0053 };
0054 
0055 typedef PythonDUContext<KDevelop::TopDUContext, 100> PythonTopDUContext;
0056 typedef PythonDUContext<KDevelop::DUContext, 101> PythonNormalDUContext;
0057 
0058 }
0059 
0060 
0061 #endif // PYTHONDUCONTEXT_H