File indexing completed on 2024-05-19 04:42:01

0001 /*
0002     SPDX-FileCopyrightText: 2013 Sven Brauch <svenbrauch@googlemail.com>
0003     SPDX-FileCopyrightText: 2014 Denis Steckelmacher <steckdenis@yahoo.fr>
0004 
0005     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006 */
0007 
0008 #ifndef __QMLJSDUCONTEXT_H__
0009 #define __QMLJSDUCONTEXT_H__
0010 
0011 #include <language/duchain/duchainregister.h>
0012 #include <language/duchain/ducontext.h>
0013 
0014 namespace KDevelop
0015 {
0016     class Declaration;
0017     class TopDUContext;
0018 }
0019 
0020 namespace QmlJS
0021 {
0022 
0023 template<class BaseContext, int IdentityT>
0024 class QmlJSDUContext : public BaseContext
0025 {
0026 public:
0027     template<class Data>
0028     explicit QmlJSDUContext(Data& data) : BaseContext(data) {
0029     }
0030 
0031     ///Parameters will be reached to the base-class
0032     template<class Param1, class Param2>
0033     QmlJSDUContext(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     QmlJSDUContext(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     QmlJSDUContext(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*
0048     createNavigationWidget(KDevelop::Declaration* decl, KDevelop::TopDUContext* topContext,
0049                            KDevelop::AbstractNavigationWidget::DisplayHints hints) const override;
0050 
0051     enum {
0052         Identity = IdentityT
0053     };
0054 };
0055 
0056 using QmlJSTopDUContext = QmlJSDUContext<KDevelop::TopDUContext, 110>;
0057 using QmlJSNormalDUContext = QmlJSDUContext<KDevelop::DUContext, 111>;
0058 
0059 }
0060 
0061 DUCHAIN_DECLARE_TYPE(QmlJS::QmlJSTopDUContext)
0062 DUCHAIN_DECLARE_TYPE(QmlJS::QmlJSNormalDUContext)
0063 
0064 #endif