1 /* 2 SPDX-FileCopyrightText: 2013 Sven Brauch <svenbrauch@googlemail.com> 3 SPDX-FileCopyrightText: 2014 Denis Steckelmacher <steckdenis@yahoo.fr> 4 5 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 6 */ 7 8 #ifndef __QMLJSDUCONTEXT_H__ 9 #define __QMLJSDUCONTEXT_H__ 10 11 #include <language/duchain/duchainregister.h> 12 #include <language/duchain/ducontext.h> 13 14 namespace KDevelop 15 { 16 class Declaration; 17 class TopDUContext; 18 } 19 20 namespace QmlJS 21 { 22 23 template<class BaseContext, int IdentityT> 24 class QmlJSDUContext : public BaseContext 25 { 26 public: 27 template<class Data> QmlJSDUContext(Data & data)28 explicit QmlJSDUContext(Data& data) : BaseContext(data) { 29 } 30 31 ///Parameters will be reached to the base-class 32 template<class Param1, class Param2> QmlJSDUContext(const Param1 & p1,const Param2 & p2,bool isInstantiationContext)33 QmlJSDUContext(const Param1& p1, const Param2& p2, bool isInstantiationContext) : BaseContext(p1, p2, isInstantiationContext) { 34 static_cast<KDevelop::DUChainBase*>(this)->d_func_dynamic()->setClassId(this); 35 } 36 37 ///Both parameters will be reached to the base-class. This fits TopDUContext. 38 template<class Param1, class Param2, class Param3> QmlJSDUContext(const Param1 & p1,const Param2 & p2,const Param3 & p3)39 QmlJSDUContext(const Param1& p1, const Param2& p2, const Param3& p3) : BaseContext(p1, p2, p3) { 40 static_cast<KDevelop::DUChainBase*>(this)->d_func_dynamic()->setClassId(this); 41 } 42 template<class Param1, class Param2> QmlJSDUContext(const Param1 & p1,const Param2 & p2)43 QmlJSDUContext(const Param1& p1, const Param2& p2) : BaseContext(p1, p2) { 44 static_cast<KDevelop::DUChainBase*>(this)->d_func_dynamic()->setClassId(this); 45 } 46 47 KDevelop::AbstractNavigationWidget* 48 createNavigationWidget(KDevelop::Declaration* decl, KDevelop::TopDUContext* topContext, 49 KDevelop::AbstractNavigationWidget::DisplayHints hints) const override; 50 51 enum { 52 Identity = IdentityT 53 }; 54 }; 55 56 using QmlJSTopDUContext = QmlJSDUContext<KDevelop::TopDUContext, 110>; 57 using QmlJSNormalDUContext = QmlJSDUContext<KDevelop::DUContext, 111>; 58 59 } 60 61 DUCHAIN_DECLARE_TYPE(QmlJS::QmlJSTopDUContext) 62 DUCHAIN_DECLARE_TYPE(QmlJS::QmlJSNormalDUContext) 63 64 #endif 65