1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
|
/* This file is part of KDevelop
Copyright 2006 Hamish Rodda <rodda@kde.org>
Copyright 2007-2009 David Nolden <david.nolden.kdevelop@art-master.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef TestCppCodeCompletion_H
#define TestCppCodeCompletion_H
#include <QObject>
#include <QByteArray>
#include <QMap>
#include <kurl.h>
#include <language/editor/cursorinrevision.h>
#include <language/duchain/identifier.h>
#include "contextbuilder.h"
#include "parser.h"
#include "control.h"
#include "dumpchain.h"
#include "rpp/chartools.h"
namespace KDevelop
{
class Declaration;
class TopDUContext;
class DUContext;
}
namespace rpp {
class pp;
class LocationTable;
}
using namespace KDevelop;
class TestPreprocessor;
class TestCppCodeCompletion : public QObject
{
Q_OBJECT
public:
TestCppCodeCompletion();
KDevelop::Declaration* findDeclaration(KDevelop::DUContext* context, const KDevelop::Identifier& id, const KDevelop::CursorInRevision& position = KDevelop::CursorInRevision::invalid());
KDevelop::Declaration* findDeclaration(KDevelop::DUContext* context, const KDevelop::QualifiedIdentifier& id, const KDevelop::CursorInRevision& position = KDevelop::CursorInRevision::invalid());
private slots:
void initTestCase();
void testCommentClearing();
void testExpressionBefore();
void testSpecialItems();
void testOnlyShow();
void testFriends();
void testInvalidContexts();
void testMemberAccess();
void testParentContexts();
void testCaseContext();
void testUnaryOperators();
void testBinaryOperators();
void testDeclarationIsInitialization();
void testNoMemberAccess();
void testFunctionImplementation();
void testAliasDeclarationAccessPolicy();
void testKeywords();
void testInclude();
void testTypeConversion();
void testTypeConversion2();
void testCompletionContext();
void testPrivateVariableCompletion();
void testUnnamedNamespace();
void testIndirectImports();
void testSameNamespace();
void testUpdateChain();
void testHeaderSections();
void testCompletionPrefix();
void cleanupTestCase();
void testForwardDeclaration();
void testArgumentMatching();
void testAcrossHeaderReferences();
void testMacroIncludeDirectives();
void testAcrossHeaderTemplateReferences();
void testAcrossHeaderTemplateResolution();
void testHeaderGuards();
void testEnvironmentMatching();
void testUsesThroughMacros();
void testMacroExpansionRanges();
void testEmptyMacroArguments();
void testMacrosInCodeCompletion();
void testTimeMacro();
void testDateMacro();
void testFileMacro();
void testPreprocessor();
void testNaiveMatching();
void testFriendVisibility();
void testLocalUsingNamespace();
void testInheritanceVisibility();
void testConstVisibility();
void testConstOverloadVisibility();
void testNamespaceCompletion();
void testNamespaceAliasCompletion();
void testNamespaceAliasCycleCompletion();
void testTemplateMemberAccess();
void testTemplateArguments();
void testTemplateFunction();
void testImportTypedef();
void testConstructorCompletion();
void testAssistant();
void testCompletionInExternalClassDefinition();
void testCompletionBehindTypedeffedConstructor();
void testSubClassVisibility();
void testSignalSlotCompletion();
void testStringProblem();
void testArgumentList();
void testStaticMethods();
void testStringInComment_data();
void testStringInComment();
void testProperties();
void testAnonStruct();
void testOverrideCtor();
void testFilterVoid();
void testCompletedIncludeFilePath();
void testMultipleIncludeCompletionItems();
void testParentConstructor_data();
void testParentConstructor();
void testOverride_data();
void testOverride();
void testExecuteKeepWord_data();
void testExecuteKeepWord();
void testAfterVisibility_data();
void testAfterVisibility();
public:
enum DumpArea {
DumpNone = 0,
DumpAST = 1,
DumpDUChain = 2,
DumpType = 4,
DumpAll = 1+2+4
};
Q_DECLARE_FLAGS(DumpAreas, DumpArea)
private:
friend class TestPreprocessor;
//Preprocesses the text, and parses all included strings within the correct context. Only strings that were added using addInclude(..) can be parsed. The url is only neede for the EnvironmentFile.
QString preprocess( const IndexedString& url, const QString& text, IncludeFileList& included, rpp::pp* parent = 0, bool stopAfterHeaders = false, KSharedPtr<Cpp::EnvironmentFile>* = 0, rpp::LocationTable** returnLocationTable = 0L, PreprocessedContents* contents = 0L );
KDevelop::TopDUContext* parse(const QByteArray& unit, DumpAreas dump = static_cast<DumpAreas>(DumpAST | DumpDUChain | DumpType), rpp::pp* parent = 0, KUrl identity = KUrl(), TopDUContext* update = 0);
void release(KDevelop::DUContext* top);
//Add the text for a fake include-file
void addInclude( const QString& identity, const QString& text );
// Parser
Control control;
Cpp::DumpChain cppDumper;
KDevelop::AbstractType::Ptr typeVoid;
KDevelop::AbstractType::Ptr typeInt;
QMap<QString, QString> fakeIncludes;
bool testFileParseOnly;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(TestCppCodeCompletion::DumpAreas)
#endif
|