File indexing completed on 2024-04-21 04:35:50
0001 /* This file is part of KDevelop 0002 * 0003 * Copyright (C) 2012-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 #include <KTextEditor/Document> 0021 #include <KTextEditor/ConfigInterface> 0022 #include <language/duchain/ducontext.h> 0023 #include <language/duchain/declaration.h> 0024 #include <language/duchain/duchainutils.h> 0025 #include <completion/helpers.h> 0026 0027 0028 using namespace KDevelop; 0029 0030 namespace ruby 0031 { 0032 0033 const QString indentString(KTextEditor::Document *document) 0034 { 0035 KTextEditor::ConfigInterface *iface = qobject_cast<KTextEditor::ConfigInterface *>(document); 0036 if (iface->configValue("replace-tabs").toBool()) { 0037 return QString(iface->configValue("indent-width").toUInt(), ' '); 0038 } 0039 return "\t"; 0040 } 0041 0042 QString getIndendation(const QString &line) 0043 { 0044 return line.left(line.indexOf(QRegExp("\\S"), 0)); 0045 } 0046 0047 QString getArgumentList(Declaration *decl, QList<QVariant> *highlighting) 0048 { 0049 Q_UNUSED(highlighting); // TODO 0050 QString ret("("); 0051 QVector<Declaration *> params; 0052 0053 if (DUContext *ctx = DUChainUtils::argumentContext(decl)) 0054 params = ctx->localDeclarations(); 0055 0056 // TODO: this is just too simplistic 0057 0058 bool first = true; 0059 foreach (Declaration *d, params) { 0060 if (first) { 0061 first = false; 0062 } else { 0063 ret += ", "; 0064 } 0065 ret += d->identifier().toString(); 0066 } 0067 ret += ")"; 0068 return ret; 0069 } 0070 0071 }