File indexing completed on 2024-04-21 08:24:40

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_AST_H
0020 #define RUBY_AST_H
0021 
0022 #include <language/duchain/ducontext.h>
0023 
0024 #include <parser/export.h>
0025 #include <parser/node.h>
0026 
0027 namespace ruby {
0028 
0029 /**
0030  * @class RubyAst
0031  *
0032  * This class represents a Ruby AST (Abstract Syntax Tree). It contains
0033  * the code (tree) and the associated KDevelop::DUContext.
0034  */
0035 class KDEVRUBYPARSER_EXPORT Ast
0036 {
0037 public:
0038     /**
0039      * Constructor.
0040      *
0041      * @param n the code that this RubAst represents.
0042      * @param ctx the KDevelop::DUContext associated with it.
0043      */
0044     explicit Ast(Node *n, KDevelop::DUContext *ctx = nullptr);
0045 
0046 public:
0047     /// The tree of this AST.
0048     Node *tree;
0049 
0050     /// The DUContext for this AST.
0051     KDevelop::DUContext *context;
0052 
0053     /// Used when we find a problem.
0054     bool foundProblems;
0055 };
0056 
0057 /**
0058  * @class NameAst
0059  *
0060  * Extends the RubyAst class to easily obtain the identifier for
0061  * a RubyAst.
0062  */
0063 class KDEVRUBYPARSER_EXPORT NameAst : public Ast
0064 {
0065 public:
0066     /**
0067      * Constructor.
0068      *
0069      * @param ast the RubyAst this class extends.
0070      */
0071     explicit NameAst(const Ast *ast);
0072 
0073 public:
0074     /// The QString that represents this class.
0075     QString value;
0076 };
0077 
0078 }
0079 
0080 #endif // RUBY_AST_H
0081