1 /*
2     SPDX-FileCopyrightText: 2008 Niko Sams <niko.sams@gmail.com>
3 
4     SPDX-License-Identifier: LGPL-2.0-only
5 */
6 
7 #ifndef PHPDUCONTEXT_H
8 #define PHPDUCONTEXT_H
9 
10 #include <QString>
11 #include <language/duchain/ducontext.h>
12 class QWidget;
13 
14 namespace KDevelop
15 {
16 class Declaration;
17 class TopDUContext;
18 }
19 namespace Php
20 {
21 
22 /**
23  * This is a du-context template that wraps the Php-specific logic around existing DUContext-derived classes.
24  * In practice this means DUContext and TopDUContext.
25  * */
26 template<class BaseContext>
27 class PhpDUContext : public BaseContext
28 {
29 public:
30     template<class Data>
PhpDUContext(Data & data)31     PhpDUContext(Data& data) : BaseContext(data) {
32     }
33 
34     ///Parameters will be reached to the base-class
35     template<class Param1, class Param2>
PhpDUContext(const Param1 & p1,const Param2 & p2,bool isInstantiationContext)36     PhpDUContext(const Param1& p1, const Param2& p2, bool isInstantiationContext) : BaseContext(p1, p2, isInstantiationContext) {
37         static_cast<KDevelop::DUChainBase*>(this)->d_func_dynamic()->setClassId(this);
38     }
39 
40     ///Both parameters will be reached to the base-class. This fits TopDUContext.
41     template<class Param1, class Param2, class Param3>
PhpDUContext(const Param1 & p1,const Param2 & p2,const Param3 & p3)42     PhpDUContext(const Param1& p1, const Param2& p2, const Param3& p3) : BaseContext(p1, p2, p3) {
43         static_cast<KDevelop::DUChainBase*>(this)->d_func_dynamic()->setClassId(this);
44     }
45     template<class Param1, class Param2>
PhpDUContext(const Param1 & p1,const Param2 & p2)46     PhpDUContext(const Param1& p1, const Param2& p2) : BaseContext(p1, p2) {
47         static_cast<KDevelop::DUChainBase*>(this)->d_func_dynamic()->setClassId(this);
48     }
49 
50     virtual QWidget* createNavigationWidget(KDevelop::Declaration* decl, KDevelop::TopDUContext* topContext,
51                                             const QString& htmlPrefix, const QString& htmlSuffix,
52                                             KDevelop::AbstractNavigationWidget::DisplayHints hints) const override;
53 
54     enum {
55         Identity = BaseContext::Identity + 51
56     };
57 };
58 
59 }
60 #endif
61