File indexing completed on 2024-04-21 04:35:56

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 <highlighting.h>
0020 
0021 #include <language/duchain/declaration.h>
0022 #include <duchain/declarations/variabledeclaration.h>
0023 
0024 using namespace ruby;
0025 
0026 using namespace KDevelop;
0027 
0028 //BEGIN RubyHighlightingInstance
0029 
0030 HighlightingInstance::HighlightingInstance(const CodeHighlighting *h)
0031     : CodeHighlightingInstance(h)
0032 {
0033 }
0034 
0035 CodeHighlightingType HighlightingInstance::typeForDeclaration(
0036     Declaration *decl, DUContext *ctx) const
0037 {
0038     VariableDeclaration *vd = dynamic_cast<VariableDeclaration *>(decl);
0039     if (decl && !decl->isFunctionDeclaration() &&
0040         decl->abstractType() && !vd) {
0041         return CodeHighlightingType::Enum;
0042     }
0043     return CodeHighlightingInstance::typeForDeclaration(decl, ctx);
0044 }
0045 
0046 bool HighlightingInstance::useRainbowColor(KDevelop::Declaration *dec) const
0047 {
0048     return dynamic_cast<VariableDeclaration *>(dec);
0049 }
0050 
0051 //END RubyHighlightingInstance
0052 
0053 //BEGIN RubyHighlighting
0054 
0055 ruby::Highlighting::Highlighting(QObject *parent)
0056     : CodeHighlighting(parent)
0057 {
0058 }
0059 
0060 KDevelop::CodeHighlightingInstance* Highlighting::createInstance() const
0061 {
0062     return new HighlightingInstance(this);
0063 }
0064 
0065 //END RubyHighlighting