File indexing completed on 2024-04-28 04:35:52
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 0020 // Ruby 0021 #include <duchain/navigation/includenavigationcontext.h> 0022 #include <duchain/declarations/moduledeclaration.h> 0023 #include <duchain/declarations/methoddeclaration.h> 0024 #include <duchain/declarations/variabledeclaration.h> 0025 0026 0027 namespace ruby 0028 { 0029 0030 IncludeNavigationContext::IncludeNavigationContext(const KDevelop::IncludeItem &item, 0031 KDevelop::TopDUContextPointer topContext) 0032 : AbstractIncludeNavigationContext(item, topContext, KDevelop::RubyParsingEnvironment) 0033 { 0034 /* There's nothing to do here! */ 0035 } 0036 0037 void IncludeNavigationContext::getFileInfo(KDevelop::TopDUContext* duchain) 0038 { 0039 modifyHtml() += QString("%1: %2") 0040 .arg(labelHighlight(i18nc("Count of files this header was included into", "Required by"))) 0041 .arg(duchain->importers().count()); 0042 modifyHtml() += "<br />"; 0043 } 0044 0045 bool IncludeNavigationContext::filterDeclaration(KDevelop::Declaration *decl) 0046 { 0047 VariableDeclaration *vd = dynamic_cast<VariableDeclaration *>(decl); 0048 return !vd; 0049 } 0050 0051 QString IncludeNavigationContext::declarationKind(const KDevelop::DeclarationPointer& decl) 0052 { 0053 const MethodDeclaration *md = dynamic_cast<const MethodDeclaration *>(decl.data()); 0054 if (md) 0055 return (md->isClassMethod()) ? "Class method" : "Instance method"; 0056 0057 const ModuleDeclaration *mDecl = dynamic_cast<ModuleDeclaration *>(decl.data()); 0058 if (mDecl) 0059 return (mDecl->isModule()) ? "Module": "Class"; 0060 return KDevelop::AbstractNavigationContext::declarationKind(decl); 0061 } 0062 0063 } 0064