CppEditor: Compile fix for clang after renaming

Change-Id: Iaabb45fb066afb600718d874a0461bc88fae92e5
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
hjk
2014-08-28 12:18:39 +02:00
committed by Nikolai Kosjar
parent c094592f8a
commit 02d26f9221
4 changed files with 73 additions and 56 deletions

View File

@@ -48,17 +48,19 @@
*/ */
using namespace Core; using namespace Core;
using namespace CPlusPlus; using namespace CPlusPlus;
using namespace CppEditor::Internal;
namespace { namespace { typedef QByteArray _; }
typedef QByteArray _;
/** /**
* Encapsulates the whole process of setting up an editor, * Encapsulates the whole process of setting up an editor,
* pressing ENTER and checking the result. * pressing ENTER and checking the result.
*/ */
class DoxygenTestCase : public CppEditor::Internal::Tests::TestCase
namespace CppEditor {
namespace Internal {
namespace Tests {
class DoxygenTestCase : public Internal::Tests::TestCase
{ {
public: public:
/// The '|' in the input denotes the cursor position. /// The '|' in the input denotes the cursor position.
@@ -66,7 +68,7 @@ public:
{ {
QVERIFY(succeededSoFar()); QVERIFY(succeededSoFar());
CppEditor::Internal::Tests::TestDocument testDocument("file.cpp", original, '|'); TestDocument testDocument("file.cpp", original, '|');
QVERIFY(testDocument.hasCursorMarker()); QVERIFY(testDocument.hasCursorMarker());
testDocument.m_source.remove(testDocument.m_cursorPosition, 1); testDocument.m_source.remove(testDocument.m_cursorPosition, 1);
QVERIFY(testDocument.writeToDisk()); QVERIFY(testDocument.writeToDisk());
@@ -103,7 +105,7 @@ public:
} }
}; };
} // anonymous namespace } // namespace Tests
void CppEditorPlugin::test_doxygen_comments_data() void CppEditorPlugin::test_doxygen_comments_data()
{ {
@@ -248,5 +250,8 @@ void CppEditorPlugin::test_doxygen_comments()
{ {
QFETCH(QByteArray, given); QFETCH(QByteArray, given);
QFETCH(QByteArray, expected); QFETCH(QByteArray, expected);
DoxygenTestCase(given, expected); Tests::DoxygenTestCase(given, expected);
} }
} // namespace Internal
} // namespace CppEditor

View File

@@ -57,9 +57,17 @@
#include <QTreeView> #include <QTreeView>
#include <QVBoxLayout> #include <QVBoxLayout>
#ifdef WITH_TESTS
#include "cppeditorplugin.h"
#include "cppquickfix_test.h"
#include <QtTest>
#endif
using namespace CPlusPlus; using namespace CPlusPlus;
using namespace CppEditor;
using namespace CppEditor::Internal;
using namespace CppTools; using namespace CppTools;
using namespace TextEditor; using namespace TextEditor;
@@ -124,6 +132,8 @@ public:
} // namespace Internal } // namespace Internal
} // namespace CppEditor } // namespace CppEditor
Q_DECLARE_METATYPE(CppEditor::Internal::InsertVirtualMethodsDialog::ImplementationMode)
namespace { namespace {
class InsertVirtualMethodsItem class InsertVirtualMethodsItem
@@ -419,10 +429,7 @@ private:
return static_cast<InsertVirtualMethodsItem *>(index.internalPointer()); return static_cast<InsertVirtualMethodsItem *>(index.internalPointer());
} }
}; };
}
}
namespace {
class InsertVirtualMethodsOp : public CppQuickFixOperation class InsertVirtualMethodsOp : public CppQuickFixOperation
{ {
public: public:
@@ -859,8 +866,6 @@ private:
bool m_hideReimplemented; bool m_hideReimplemented;
}; };
} // anonymous namespace
InsertVirtualMethodsDialog::InsertVirtualMethodsDialog(QWidget *parent) InsertVirtualMethodsDialog::InsertVirtualMethodsDialog(QWidget *parent)
: QDialog(parent) : QDialog(parent)
, m_view(0) , m_view(0)
@@ -1087,12 +1092,7 @@ void InsertVirtualMethods::match(const CppQuickFixInterface &interface, QuickFix
#ifdef WITH_TESTS #ifdef WITH_TESTS
#include "cppeditorplugin.h" namespace Tests {
#include "cppquickfix_test.h"
using namespace CppEditor::Internal::Tests;
#include <QtTest>
typedef QByteArray _; typedef QByteArray _;
@@ -1113,14 +1113,14 @@ public:
bool insertKeywordVirtual() const { return m_insertKeywordVirtual; } bool insertKeywordVirtual() const { return m_insertKeywordVirtual; }
}; };
} // namespace Tests
InsertVirtualMethods *InsertVirtualMethods::createTestFactory() InsertVirtualMethods *InsertVirtualMethods::createTestFactory()
{ {
return new InsertVirtualMethods(new InsertVirtualMethodsDialogTest( return new InsertVirtualMethods(new Tests::InsertVirtualMethodsDialogTest(
InsertVirtualMethodsDialog::ModeOutsideClass, true)); InsertVirtualMethodsDialog::ModeOutsideClass, true));
} }
Q_DECLARE_METATYPE(InsertVirtualMethodsDialog::ImplementationMode)
void CppEditorPlugin::test_quickfix_InsertVirtualMethods_data() void CppEditorPlugin::test_quickfix_InsertVirtualMethods_data()
{ {
QTest::addColumn<InsertVirtualMethodsDialog::ImplementationMode>("implementationMode"); QTest::addColumn<InsertVirtualMethodsDialog::ImplementationMode>("implementationMode");
@@ -1631,14 +1631,14 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods()
QFETCH(QByteArray, expected); QFETCH(QByteArray, expected);
InsertVirtualMethods factory( InsertVirtualMethods factory(
new InsertVirtualMethodsDialogTest(implementationMode, insertVirtualKeyword)); new Tests::InsertVirtualMethodsDialogTest(implementationMode, insertVirtualKeyword));
QuickFixTestCase(singleDocument(original, expected), &factory); Tests::QuickFixTestCase(Tests::singleDocument(original, expected), &factory);
} }
/// Check: Insert in implementation file /// Check: Insert in implementation file
void CppEditorPlugin::test_quickfix_InsertVirtualMethods_implementationFile() void CppEditorPlugin::test_quickfix_InsertVirtualMethods_implementationFile()
{ {
QList<QuickFixTestDocument::Ptr> testFiles; QList<Tests::QuickFixTestDocument::Ptr> testFiles;
QByteArray original; QByteArray original;
QByteArray expected; QByteArray expected;
@@ -1665,7 +1665,7 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_implementationFile()
"public:\n" "public:\n"
" virtual int a();\n" " virtual int a();\n"
"};\n"; "};\n";
testFiles << QuickFixTestDocument::create("file.h", original, expected); testFiles << Tests::QuickFixTestDocument::create("file.h", original, expected);
// Source File // Source File
original = "#include \"file.h\"\n"; original = "#include \"file.h\"\n";
@@ -1674,17 +1674,17 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_implementationFile()
"\n\n" "\n\n"
"int Derived::a()\n" "int Derived::a()\n"
"{\n}"; "{\n}";
testFiles << QuickFixTestDocument::create("file.cpp", original, expected); testFiles << Tests::QuickFixTestDocument::create("file.cpp", original, expected);
InsertVirtualMethods factory(new InsertVirtualMethodsDialogTest( InsertVirtualMethods factory(new Tests::InsertVirtualMethodsDialogTest(
InsertVirtualMethodsDialog::ModeImplementationFile, true)); InsertVirtualMethodsDialog::ModeImplementationFile, true));
QuickFixTestCase(testFiles, &factory); Tests::QuickFixTestCase(testFiles, &factory);
} }
/// Check: Qualified names. /// Check: Qualified names.
void CppEditorPlugin::test_quickfix_InsertVirtualMethods_BaseClassInNamespace() void CppEditorPlugin::test_quickfix_InsertVirtualMethods_BaseClassInNamespace()
{ {
QList<QuickFixTestDocument::Ptr> testFiles; QList<Tests::QuickFixTestDocument::Ptr> testFiles;
QByteArray original; QByteArray original;
QByteArray expected; QByteArray expected;
@@ -1717,7 +1717,7 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_BaseClassInNamespace()
"public:\n" "public:\n"
" virtual BaseNS::BaseEnum a(BaseNS::BaseEnum e);\n" " virtual BaseNS::BaseEnum a(BaseNS::BaseEnum e);\n"
"};\n"; "};\n";
testFiles << QuickFixTestDocument::create("file.h", original, expected); testFiles << Tests::QuickFixTestDocument::create("file.h", original, expected);
// Source File // Source File
original = "#include \"file.h\"\n"; original = "#include \"file.h\"\n";
@@ -1726,12 +1726,15 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_BaseClassInNamespace()
"\n\n" "\n\n"
"BaseNS::BaseEnum Derived::a(BaseNS::BaseEnum e)\n" "BaseNS::BaseEnum Derived::a(BaseNS::BaseEnum e)\n"
"{\n}"; "{\n}";
testFiles << QuickFixTestDocument::create("file.cpp", original, expected); testFiles << Tests::QuickFixTestDocument::create("file.cpp", original, expected);
InsertVirtualMethods factory(new InsertVirtualMethodsDialogTest( InsertVirtualMethods factory(new Tests::InsertVirtualMethodsDialogTest(
InsertVirtualMethodsDialog::ModeImplementationFile, true)); InsertVirtualMethodsDialog::ModeImplementationFile, true));
QuickFixTestCase(testFiles, &factory); Tests::QuickFixTestCase(testFiles, &factory);
} }
#endif #endif // WITH_TESTS
} // namespace Internal
} // namespace CppEditor
#include "cppinsertvirtualmethods.moc" #include "cppinsertvirtualmethods.moc"

View File

@@ -49,10 +49,7 @@
*/ */
using namespace Core; using namespace Core;
using namespace CPlusPlus; using namespace CPlusPlus;
using namespace CppEditor;
using namespace CppEditor::Internal;
using namespace CppEditor::Internal::Tests; using namespace CppEditor::Internal::Tests;
using namespace CppTools;
using namespace TextEditor; using namespace TextEditor;
using CppTools::Tests::TestIncludePaths; using CppTools::Tests::TestIncludePaths;
@@ -115,10 +112,6 @@ static QString &removeTrailingWhitespace(QString &input)
return input; return input;
} }
} // namespace Tests
} // namespace Internal
} // namespace CppEditor
/// The '@' in the originalSource is the position from where the quick-fix discovery is triggered. /// The '@' in the originalSource is the position from where the quick-fix discovery is triggered.
/// Exactly one TestFile must contain the cursor position marker '@' in the originalSource. /// Exactly one TestFile must contain the cursor position marker '@' in the originalSource.
QuickFixTestCase::QuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &theTestFiles, QuickFixTestCase::QuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &theTestFiles,
@@ -259,9 +252,17 @@ QSharedPointer<TextEditor::QuickFixOperation> QuickFixTestCase::getFix(
return results.isEmpty() ? QuickFixOperation::Ptr() : results.at(resultIndex); return results.isEmpty() ? QuickFixOperation::Ptr() : results.at(resultIndex);
} }
} // namespace Tests
} // namespace Internal
typedef QSharedPointer<CppQuickFixFactory> CppQuickFixFactoryPtr; typedef QSharedPointer<CppQuickFixFactory> CppQuickFixFactoryPtr;
Q_DECLARE_METATYPE(CppQuickFixFactoryPtr) } // namespace CppEditor
Q_DECLARE_METATYPE(CppEditor::CppQuickFixFactoryPtr)
namespace CppEditor {
namespace Internal {
void CppEditorPlugin::test_quickfix_data() void CppEditorPlugin::test_quickfix_data()
{ {
@@ -1775,8 +1776,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_notTriggeringWhenDefinitio
const QByteArray expected = original; const QByteArray expected = original;
InsertDefFromDecl factory; InsertDefFromDecl factory;
QuickFixTestCase test(singleDocument(original, expected), &factory, ProjectPart::HeaderPaths(), QuickFixTestCase(singleDocument(original, expected), &factory, ProjectPart::HeaderPaths(), 1);
1);
} }
/// Find right implementation file. /// Find right implementation file.
@@ -3827,3 +3827,6 @@ void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_notTriggeringForIn
ExtractLiteralAsParameter factory; ExtractLiteralAsParameter factory;
QuickFixTestCase(testFiles, &factory); QuickFixTestCase(testFiles, &factory);
} }
} // namespace Internal
} // namespace CppEditor

View File

@@ -69,8 +69,6 @@
*/ */
using namespace CPlusPlus; using namespace CPlusPlus;
using namespace CppEditor;
using namespace CppEditor::Internal;
using namespace CppTools; using namespace CppTools;
using namespace TextEditor; using namespace TextEditor;
using namespace Core; using namespace Core;
@@ -105,10 +103,11 @@ template<> char *toString(const OverrideItem &data)
} }
QT_END_NAMESPACE QT_END_NAMESPACE
namespace {
typedef QByteArray _; typedef QByteArray _;
namespace CppEditor {
namespace Internal {
/// A fake virtual functions assist provider that runs processor->perform() already in configure() /// A fake virtual functions assist provider that runs processor->perform() already in configure()
class VirtualFunctionTestAssistProvider : public VirtualFunctionAssistProvider class VirtualFunctionTestAssistProvider : public VirtualFunctionAssistProvider
{ {
@@ -183,11 +182,11 @@ typedef QSharedPointer<TestDocument> TestDocumentPtr;
* - a '@' character denotes the initial text cursor position * - a '@' character denotes the initial text cursor position
* - a '$' character denotes the target text cursor position * - a '$' character denotes the target text cursor position
*/ */
class TestDocument : public CppEditor::Internal::Tests::TestDocument class TestDocument : public Tests::TestDocument
{ {
public: public:
TestDocument(const QByteArray &source, const QByteArray &fileName) TestDocument(const QByteArray &source, const QByteArray &fileName)
: CppEditor::Internal::Tests::TestDocument(fileName, source) : Tests::TestDocument(fileName, source)
, m_targetCursorPosition(m_source.indexOf(QLatin1Char('$'))) , m_targetCursorPosition(m_source.indexOf(QLatin1Char('$')))
{ {
if (m_cursorPosition != -1 || m_targetCursorPosition != -1) if (m_cursorPosition != -1 || m_targetCursorPosition != -1)
@@ -229,7 +228,7 @@ QList<TestDocumentPtr> singleDocument(const QByteArray &source)
* executing Follow Symbol Under Cursor or Switch Between Function Declaration/Definition * executing Follow Symbol Under Cursor or Switch Between Function Declaration/Definition
* and checking the result. * and checking the result.
*/ */
class F2TestCase : public CppEditor::Internal::Tests::TestCase class F2TestCase : public Tests::TestCase
{ {
public: public:
enum CppEditorAction { enum CppEditorAction {
@@ -380,9 +379,13 @@ TestDocumentPtr F2TestCase::testFileWithTargetCursorMarker(const QList<TestDocum
return TestDocumentPtr(); return TestDocumentPtr();
} }
} // anonymous namespace } // namespace Internal
} // namespace CppEditor
Q_DECLARE_METATYPE(QList<TestDocumentPtr>) Q_DECLARE_METATYPE(QList<CppEditor::Internal::TestDocumentPtr>)
namespace CppEditor {
namespace Internal {
void CppEditorPlugin::test_SwitchMethodDeclarationDefinition_data() void CppEditorPlugin::test_SwitchMethodDeclarationDefinition_data()
{ {
@@ -1472,6 +1475,9 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_multipleD
F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, testFiles, finalResults); F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, testFiles, finalResults);
} }
} // namespace Internal
} // namespace CppEditor
/* /*
Potential test cases improving name lookup. Potential test cases improving name lookup.