forked from qt-creator/qt-creator
CppEditor: Fix Typedef Handling with 'Remove Using Directive' QuickFix
Previously, typedefs were ignored and the new code became invalid after applying the quickfix. Change-Id: I0d4295e90d02dfacc3edac5ac3f96d9edbeaf662 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -6479,6 +6479,49 @@ void CppEditorPlugin::test_quickfix_removeUsingNamespace()
|
||||
QuickFixOperationTest(testDocuments, &factory, ProjectExplorer::HeaderPaths(), operation);
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_quickfix_removeUsingNamespace_simple_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("header");
|
||||
QTest::addColumn<QByteArray>("expected");
|
||||
|
||||
const QByteArray common = R"--(
|
||||
namespace N{
|
||||
template<typename T>
|
||||
struct vector{
|
||||
using iterator = T*;
|
||||
};
|
||||
using int_vector = vector<int>;
|
||||
}
|
||||
)--";
|
||||
const QByteArray header = common + R"--(
|
||||
using namespace N@;
|
||||
int_vector ints;
|
||||
int_vector::iterator intIter;
|
||||
using vec = vector<int>;
|
||||
vec::iterator it;
|
||||
)--";
|
||||
const QByteArray expected = common + R"--(
|
||||
N::int_vector ints;
|
||||
N::int_vector::iterator intIter;
|
||||
using vec = N::vector<int>;
|
||||
vec::iterator it;
|
||||
)--";
|
||||
|
||||
QTest::newRow("nested typedefs with Namespace") << header << expected;
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_quickfix_removeUsingNamespace_simple()
|
||||
{
|
||||
QFETCH(QByteArray, header);
|
||||
QFETCH(QByteArray, expected);
|
||||
|
||||
QList<QuickFixTestDocument::Ptr> testDocuments;
|
||||
testDocuments << QuickFixTestDocument::create("header.h", header, expected);
|
||||
|
||||
RemoveUsingNamespace factory;
|
||||
QuickFixOperationTest(testDocuments, &factory, ProjectExplorer::HeaderPaths());
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_quickfix_removeUsingNamespace_differentSymbols()
|
||||
{
|
||||
QByteArray header = "namespace test{\n"
|
||||
|
||||
Reference in New Issue
Block a user