File indexing completed on 2024-04-21 04:35:54
0001 /* This file is part of KDevelop 0002 * 0003 * Copyright (C) 2011-2015 Miquel Sabaté Solà <mikisabate@gmail.com> 0004 * 0005 * This program is free software: you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 3 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 */ 0018 0019 #ifndef RUBY_DUCONTEXT_H 0020 #define RUBY_DUCONTEXT_H 0021 0022 #include <language/duchain/ducontext.h> 0023 0024 namespace KDevelop { 0025 class Declaration; 0026 class TopDUContext; 0027 } 0028 0029 namespace ruby { 0030 0031 template<class BaseContext> 0032 class RubyDUContext : public BaseContext 0033 { 0034 public: 0035 template<class Data> 0036 explicit RubyDUContext(Data &data) : BaseContext(data) 0037 { 0038 }; 0039 0040 /** 0041 * Parameters will be reached to the base-class. 0042 */ 0043 template<class Param1, class Param2> 0044 RubyDUContext(const Param1 &p1, const Param2 &p2, 0045 bool isInstantiationContext) 0046 : BaseContext(p1, p2, isInstantiationContext) 0047 { 0048 static_cast<KDevelop::DUChainBase*>(this)->d_func_dynamic()->setClassId(this); 0049 } 0050 0051 /** 0052 * Both parameters will be reached to the base-class. This fits TopDUContext. 0053 */ 0054 template<class Param1, class Param2, class Param3> 0055 explicit RubyDUContext(const Param1 &p1, const Param2 &p2, const Param3 &p3) 0056 : BaseContext(p1, p2, p3) 0057 { 0058 static_cast<KDevelop::DUChainBase*>(this)->d_func_dynamic()->setClassId(this); 0059 } 0060 0061 template<class Param1, class Param2> 0062 explicit RubyDUContext(const Param1 &p1, const Param2 &p2) 0063 : BaseContext(p1, p2) 0064 { 0065 static_cast<KDevelop::DUChainBase*>(this)->d_func_dynamic()->setClassId(this); 0066 } 0067 0068 /** 0069 * Create a Navigation Widget for user-interaction within the quickopen list. 0070 * 0071 * @param decl A member-declaration of this context the navigation-widget should be created for. Zero to create a widget for this context. 0072 * @param topContext Top-context from where the navigation-widget is triggered. 0073 */ 0074 KDevelop::AbstractNavigationWidget * createNavigationWidget(KDevelop::Declaration *decl = nullptr, 0075 KDevelop::TopDUContext *topContext = nullptr, 0076 KDevelop::AbstractNavigationWidget::DisplayHints hints = KDevelop::AbstractNavigationWidget::NoHints) const override; 0077 0078 public: 0079 enum { Identity = BaseContext::Identity + 41 }; 0080 }; 0081 0082 using RubyTopDUContext = RubyDUContext<KDevelop::TopDUContext>; 0083 using RubyNormalDUContext = RubyDUContext<KDevelop::DUContext>; 0084 0085 } 0086 0087 #endif // RUBY_DUCONTEXT_H