forked from qt-creator/qt-creator
CppEditor: Fix InsertDefFromDecl::match
Now InsertDefFromDecl finds the right implementation file and the speed of match() is improved. Task-number: QTCREATORBUG-9627 Change-Id: Ibff824f52124e8cc10ccb6a97c133e11565473db Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
committed by
Nikolai Kosjar
parent
89225167fb
commit
b7ba23f92d
@@ -1126,6 +1126,58 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_notTriggeringStatement()
|
||||
data.run(&factory);
|
||||
}
|
||||
|
||||
/// Find right implementation file.
|
||||
void CppEditorPlugin::test_quickfix_InsertDefFromDecl_findRightImplementationFile()
|
||||
{
|
||||
QList<TestDocumentPtr> testFiles;
|
||||
|
||||
QByteArray original;
|
||||
QByteArray expected;
|
||||
|
||||
// Header File
|
||||
original =
|
||||
"struct Foo\n"
|
||||
"{\n"
|
||||
" Foo();\n"
|
||||
" void a();\n"
|
||||
" void b@();\n"
|
||||
"};\n"
|
||||
"}\n";
|
||||
expected = original + "\n";
|
||||
testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
|
||||
|
||||
// Source File #1
|
||||
original =
|
||||
"#include \"file.h\"\n"
|
||||
"\n"
|
||||
"Foo::Foo()\n"
|
||||
"{\n\n"
|
||||
"}\n"
|
||||
"\n";
|
||||
expected = original + "\n";
|
||||
testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
|
||||
|
||||
|
||||
// Source File #2
|
||||
original =
|
||||
"#include \"file.h\"\n"
|
||||
"\n"
|
||||
"void Foo::a()\n"
|
||||
"{\n\n"
|
||||
"}\n";
|
||||
expected = original +
|
||||
"\n"
|
||||
"void Foo::b()\n"
|
||||
"{\n\n"
|
||||
"}\n"
|
||||
"\n";
|
||||
testFiles << TestDocument::create(original, expected, QLatin1String("file2.cpp"));
|
||||
|
||||
InsertDefFromDecl factory;
|
||||
TestCase data(testFiles);
|
||||
data.run(&factory);
|
||||
}
|
||||
|
||||
// Function for one of InsertDeclDef section cases
|
||||
void insertToSectionDeclFromDef(const QByteArray §ion, int sectionIndex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user