diff --git a/src/plugins/cppeditor/cppmodelmanager_test.cpp b/src/plugins/cppeditor/cppmodelmanager_test.cpp index c2a9189fd63..9e72a224b9f 100644 --- a/src/plugins/cppeditor/cppmodelmanager_test.cpp +++ b/src/plugins/cppeditor/cppmodelmanager_test.cpp @@ -1000,9 +1000,7 @@ void ModelManagerTest::testRenameIncludes() } // Renaming the header - QVERIFY(Core::FileUtils::renameFile(oldHeader, - newHeader, - Core::HandleIncludeGuards::Yes)); + QVERIFY(ProjectExplorerPlugin::renameFile(oldHeader, newHeader)); // Update the c++ model manager again and check for the new includes CppModelManager::updateSourceFiles(sourceFiles).waitForFinished(); @@ -1070,15 +1068,12 @@ void ModelManagerTest::testRenameIncludesInEditor() QVERIFY(CppModelManager::workingCopy().get(mainFile)); // Test the renaming of a header file where a pragma once guard is present - QVERIFY(Core::FileUtils::renameFile(headerWithPragmaOnce, - renamedHeaderWithPragmaOnce, - Core::HandleIncludeGuards::Yes)); + QVERIFY(ProjectExplorerPlugin::renameFile(headerWithPragmaOnce, renamedHeaderWithPragmaOnce)); // Test the renaming the header with include guard: // The contents should match the foobar2000.h in the testdata_project2 project - QVERIFY(Core::FileUtils::renameFile(Utils::FilePath::fromString(headerWithNormalGuard), - Utils::FilePath::fromString(renamedHeaderWithNormalGuard), - Core::HandleIncludeGuards::Yes)); + QVERIFY(ProjectExplorerPlugin::renameFile(FilePath::fromString(headerWithNormalGuard), + FilePath::fromString(renamedHeaderWithNormalGuard))); const MyTestDataDir testDir2(_("testdata_project2")); QFile foobar2000Header(testDir2.file("foobar2000.h")); diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 4cf5c55e79d..27390bf884c 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -2484,6 +2484,16 @@ QList> ProjectExplorerPlugin::renameFiles( return renamedFiles; } +#ifdef WITH_TESTS +bool ProjectExplorerPlugin::renameFile(const Utils::FilePath &source, const Utils::FilePath &target) +{ + const bool success = Core::FileUtils::renameFile(source, target, HandleIncludeGuards::Yes); + if (success) + emit instance()->filesRenamed({std::make_pair(source, target)}); + return success; +} +#endif // WITH_TESTS + void ProjectExplorerPluginPrivate::startRunControl(RunControl *runControl) { m_outputPane.createNewOutputWindow(runControl); diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index 12432cafafa..d7e04f3fd1b 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -129,6 +129,10 @@ public: static QList> renameFiles(const QList> &nodesAndNewFilePaths); +#ifdef WITH_TESTS + static bool renameFile(const Utils::FilePath &source, const Utils::FilePath &target); +#endif + static QStringList projectFilePatterns(); static bool isProjectFile(const Utils::FilePath &filePath); static RecentProjectsEntries recentProjects();