File indexing completed on 2024-04-28 04:35:54

0001 /*
0002  * This file is part of KDevelop
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 #ifndef RUBY_USES_H
0021 #define RUBY_USES_H
0022 
0023 
0024 #include <duchain/tests/duchaintestbase.h>
0025 
0026 
0027 namespace ruby {
0028 
0029 /**
0030  * @class TestUseBuilder
0031  * Test the UseBuilder class from the DUChain.
0032  */
0033 class TestUseBuilder : public DUChainTestBase
0034 {
0035     Q_OBJECT
0036 
0037 public:
0038     TestUseBuilder();
0039 
0040 protected:
0041     /// Re-implemented from DUChainTestBase.
0042     KDevelop::TopDUContext * parse(const QByteArray &code, const QString &id) override;
0043 
0044 private:
0045     /// Compare the uses of the given declaration @p dec with the given @p range.
0046     void compareUses(KDevelop::Declaration *dec, const KDevelop::RangeInRevision &range);
0047 
0048     /**
0049      * Let's compare the uses of the given declaration @p dec with the given
0050      * @p ranges that we expect these uses are enclosed to.
0051      */
0052     void compareUses(KDevelop::Declaration *dec, QList<KDevelop::RangeInRevision> ranges);
0053 
0054 private slots:
0055     // Basic stuff
0056     void stringInterpolation();
0057     void alias();
0058     void assignment();
0059     void checkSubClassing();
0060     void instanceVariable();
0061     void classVariable();
0062     void exceptions();
0063 
0064     // Contexts
0065     void block();
0066     void checkMethodArgumentsContext();
0067     void checkMethodLocalDeclarations();
0068     void instanceClassMethods();
0069     void globals1();
0070     void globals2();
0071     void globals3();
0072     void defaultGlobals();
0073     void classModulesScopes();
0074 
0075     // Method calls
0076     void builtinUses();
0077     void chained();
0078     void fromClassAndAbove();
0079     void super();
0080     void moduleMixins1();
0081     void moduleMixins2();
0082     void exprIsCalling();
0083     void stringCalling();
0084 
0085     // Others
0086     void nestedIdentifier();
0087 };
0088 
0089 }
0090 
0091 #endif /* RUBY_USES_H */