forked from qt-creator/qt-creator
CppEditor: Check <include path>/QSomething
For the quick fix AddIncludeForUndefinedIdentifier, if no class is found via the locator, check the "Qt include paths" for a header file with the same name as the class name. Task-number: QTCREATORBUG-9538 Change-Id: I13c86844c2ff653fa479dc91eb109af2a6d76fae Reviewed-by: Lorenz Haas <lykurg@gmail.com> Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -344,18 +344,25 @@ private:
|
||||
const QString m_include;
|
||||
};
|
||||
|
||||
QString includeBaseDirectory()
|
||||
{
|
||||
return QLatin1String(SRCDIR)
|
||||
+ QLatin1String("/../../../tests/auto/cplusplus/preprocessor/data/include-data");
|
||||
}
|
||||
|
||||
QString globalQtCoreIncludePath()
|
||||
{
|
||||
return QDir::cleanPath(includeBaseDirectory() + QLatin1String("/QtCore"));
|
||||
}
|
||||
|
||||
QString globalIncludePath()
|
||||
{
|
||||
const QString path = QLatin1String(SRCDIR)
|
||||
+ QLatin1String("/../../../tests/auto/cplusplus/preprocessor/data/include-data/global");
|
||||
return QDir::cleanPath(path);
|
||||
return QDir::cleanPath(includeBaseDirectory() + QLatin1String("/global"));
|
||||
}
|
||||
|
||||
QString directoryOfTestFile()
|
||||
{
|
||||
const QString path = QLatin1String(SRCDIR)
|
||||
+ QLatin1String("/../../../tests/auto/cplusplus/preprocessor/data/include-data/local");
|
||||
return QDir::cleanPath(path);
|
||||
return QDir::cleanPath(includeBaseDirectory() + QLatin1String("/local"));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
@@ -1741,6 +1748,32 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_veryFirstIn
|
||||
data.run(&factory);
|
||||
}
|
||||
|
||||
/// Check: If a "Qt Class" was not found by the locator, check the header files in the Qt
|
||||
/// include paths
|
||||
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_checkQSomethingInQtIncludePaths()
|
||||
{
|
||||
QList<TestDocumentPtr> testFiles;
|
||||
|
||||
QByteArray original;
|
||||
QByteArray expected;
|
||||
|
||||
original =
|
||||
"@QDir dir;\n"
|
||||
;
|
||||
expected =
|
||||
"#include <QDir>\n"
|
||||
"\n"
|
||||
"QDir dir;\n"
|
||||
"\n"
|
||||
;
|
||||
testFiles << TestDocument::create(original, expected, directoryOfTestFile() + QLatin1Char('/')
|
||||
+ QLatin1String("file.cpp"));
|
||||
|
||||
AddIncludeForUndefinedIdentifier factory;
|
||||
TestCase data(testFiles, QStringList(globalQtCoreIncludePath()));
|
||||
data.run(&factory);
|
||||
}
|
||||
|
||||
/// Check: Move definition from header to cpp.
|
||||
void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCpp()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user