Warning, file /kdevelop/kdev-ruby/duchain/declarations/methoddeclaration.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 #include <duchain/declarations/methoddeclaration.h> 0020 0021 #include <duchain/helpers.h> 0022 #include <language/duchain/duchainregister.h> 0023 0024 namespace ruby { 0025 0026 REGISTER_DUCHAIN_ITEM(MethodDeclaration); 0027 DEFINE_LIST_MEMBER_HASH(MethodDeclarationData, yieldTypes, YieldType) 0028 0029 MethodDeclaration::MethodDeclaration(const KDevelop::RangeInRevision &range, 0030 KDevelop::DUContext *ctx) 0031 : KDevelop::FunctionDeclaration(*new MethodDeclarationData) 0032 { 0033 setRange(range); 0034 d_func_dynamic()->setClassId(this); 0035 if (ctx) { 0036 setContext(ctx); 0037 } 0038 } 0039 0040 MethodDeclaration::MethodDeclaration(const MethodDeclaration &rhs) 0041 : KDevelop::FunctionDeclaration(*new MethodDeclarationData(*rhs.d_func())) 0042 { 0043 } 0044 0045 MethodDeclaration::MethodDeclaration(MethodDeclarationData &data) 0046 : KDevelop::FunctionDeclaration(data) 0047 { 0048 } 0049 0050 bool MethodDeclaration::isClassMethod() const 0051 { 0052 return d_func()->classMethod; 0053 } 0054 0055 void MethodDeclaration::setClassMethod(const bool isClass) 0056 { 0057 d_func_dynamic()->classMethod = isClass; 0058 } 0059 0060 KDevelop::Declaration::AccessPolicy MethodDeclaration::accessPolicy() const 0061 { 0062 return d_func()->accessPolicy; 0063 } 0064 0065 void MethodDeclaration::setAccessPolicy(const KDevelop::Declaration::AccessPolicy &policy) 0066 { 0067 d_func_dynamic()->accessPolicy = policy; 0068 } 0069 0070 void MethodDeclaration::clearYieldTypes() 0071 { 0072 bool wasInSymbolTable = d_func()->m_inSymbolTable; 0073 setInSymbolTable(false); 0074 d_func_dynamic()->yieldTypesList().clear(); 0075 setInSymbolTable(wasInSymbolTable); 0076 } 0077 0078 void MethodDeclaration::replaceYieldTypes(YieldType yield, uint n) 0079 { 0080 bool wasInSymbolTable = d_func()->m_inSymbolTable; 0081 0082 setInSymbolTable(false); 0083 if (n < d_func()->yieldTypesSize()) { 0084 KDevelop::IndexedType old = d_func_dynamic()->yieldTypesList()[n].type; 0085 YieldType res; 0086 KDevelop::AbstractType::Ptr merged = mergeTypes(old.abstractType(), yield.type.abstractType()); 0087 res.type = merged.data()->indexed(); 0088 d_func_dynamic()->yieldTypesList()[n] = res; 0089 } else { 0090 d_func_dynamic()->yieldTypesList().append(yield); 0091 } 0092 setInSymbolTable(wasInSymbolTable); 0093 } 0094 0095 const YieldType* MethodDeclaration::yieldTypes() const 0096 { 0097 return d_func()->yieldTypes(); 0098 } 0099 0100 uint MethodDeclaration::yieldTypesSize() 0101 { 0102 return d_func()->yieldTypesSize(); 0103 } 0104 0105 KDevelop::Declaration * MethodDeclaration::clonePrivate() const 0106 { 0107 return new MethodDeclaration(*this); 0108 } 0109 0110 }