File indexing completed on 2024-04-14 04:31:16

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_HIGHLIGHTING_H
0020 #define RUBY_HIGHLIGHTING_H
0021 
0022 #include <language/highlighting/codehighlighting.h>
0023 
0024 namespace ruby {
0025 
0026 /**
0027  * @class HighlightingInstance
0028  *
0029  * The HighlightingInstance to be applied in a Ruby file.
0030  */
0031 class HighlightingInstance : public KDevelop::CodeHighlightingInstance
0032 {
0033 public:
0034     explicit HighlightingInstance(const KDevelop::CodeHighlighting *h);
0035 
0036     /**
0037      * Return type of highlighting to be applied according
0038      * to the given declaration.
0039      *
0040      * @param decl The involved declaration.
0041      * @param ctx The context from where the declaration is used.
0042      */
0043     KDevelop::CodeHighlightingType typeForDeclaration(KDevelop::Declaration *decl,
0044                                                       KDevelop::DUContext *ctx) const override;
0045 
0046     /**
0047      * Re-implemented from CodeHighlightingInstance to decide whether to
0048      * apply auto-generated rainbow colors or not.
0049      *
0050      * @param dec The involved declaration.
0051      */
0052     bool useRainbowColor(KDevelop::Declaration *dec) const override;
0053 };
0054 
0055 /**
0056  * @class Highlighting
0057  *
0058  * This is a subclass of KDevelop::CodeHighlighting and it
0059  * represents the code highlighting for the Ruby language.
0060  */
0061 class Highlighting : public KDevelop::CodeHighlighting
0062 {
0063     Q_OBJECT
0064 
0065 public:
0066     explicit Highlighting(QObject *parent);
0067 
0068 private:
0069     /**
0070      * Extends base class CodeHighlighting's createInstance() method to use
0071      * this plugin's defined one.
0072      */
0073     KDevelop::CodeHighlightingInstance * createInstance() const override;
0074 };
0075 
0076 }
0077 
0078 #endif // RUBYHIGHLIGHTING_H
0079