diff --git a/src/plugins/cmakeprojectmanager/CMakeLists.txt b/src/plugins/cmakeprojectmanager/CMakeLists.txt index 0aaae8f77fe..32c800941ed 100644 --- a/src/plugins/cmakeprojectmanager/CMakeLists.txt +++ b/src/plugins/cmakeprojectmanager/CMakeLists.txt @@ -5,7 +5,6 @@ add_qtc_plugin(CMakeProjectManager SOURCES builddirmanager.cpp builddirmanager.h builddirparameters.cpp builddirparameters.h - builddirreader.cpp builddirreader.h cmake_global.h cmakeautocompleter.cpp cmakeautocompleter.h cmakebuildconfiguration.cpp cmakebuildconfiguration.h diff --git a/src/plugins/cmakeprojectmanager/builddirmanager.cpp b/src/plugins/cmakeprojectmanager/builddirmanager.cpp index 2e99326d944..67068b9f621 100644 --- a/src/plugins/cmakeprojectmanager/builddirmanager.cpp +++ b/src/plugins/cmakeprojectmanager/builddirmanager.cpp @@ -131,46 +131,6 @@ void BuildDirManager::emitReparseRequest() const } } -void BuildDirManager::updateReaderType(const BuildDirParameters &p, - std::function todo) -{ - if (!m_reader || !m_reader->isCompatible(p)) { - if (m_reader) { - stopParsingAndClearState(); - qCDebug(cmakeBuildDirManagerLog) << "Creating new reader do to incompatible parameters"; - } else { - qCDebug(cmakeBuildDirManagerLog) << "Creating first reader"; - } - m_reader = BuildDirReader::createReader(p); - - if (!m_reader) { - TaskHub::addTask(BuildSystemTask( - Task::Error, - tr("The kit does not define a valid CMake tool to parse this project with."))); - return; - } - - connect(m_reader.get(), - &BuildDirReader::configurationStarted, - this, - &BuildDirManager::parsingStarted); - connect(m_reader.get(), - &BuildDirReader::dataAvailable, - this, - &BuildDirManager::emitDataAvailable); - connect(m_reader.get(), - &BuildDirReader::errorOccurred, - this, - &BuildDirManager::emitErrorOccurred); - connect(m_reader.get(), &BuildDirReader::dirty, this, &BuildDirManager::becameDirty); - connect(m_reader.get(), &BuildDirReader::isReadyNow, this, todo); - } - - QTC_ASSERT(m_reader, return ); - - m_reader->setParameters(p); -} - bool BuildDirManager::hasConfigChanged() { checkConfiguration(); @@ -265,14 +225,7 @@ bool BuildDirManager::isParsing() const void BuildDirManager::stopParsingAndClearState() { qCDebug(cmakeBuildDirManagerLog) << "stopping parsing run!"; - if (m_reader) { - if (m_reader->isParsing()) - m_reader->errorOccurred(tr("Parsing has been canceled.")); - disconnect(m_reader.get(), nullptr, this, nullptr); - m_reader->stop(); - } m_reader.reset(); - resetData(); } void BuildDirManager::setParametersAndRequestParse(const BuildDirParameters ¶meters, @@ -290,7 +243,25 @@ void BuildDirManager::setParametersAndRequestParse(const BuildDirParameters &par m_parameters.workDirectory = workDirectory(parameters); updateReparseParameters(reparseParameters); - updateReaderType(m_parameters, [this]() { emitReparseRequest(); }); + QTC_CHECK(!m_reader); // The parsing should have stopped at this time already! + m_reader = std::make_unique(); + + connect(m_reader.get(), + &FileApiReader::configurationStarted, + this, + &BuildDirManager::parsingStarted); + connect(m_reader.get(), + &FileApiReader::dataAvailable, + this, + &BuildDirManager::emitDataAvailable); + connect(m_reader.get(), + &FileApiReader::errorOccurred, + this, + &BuildDirManager::emitErrorOccurred); + connect(m_reader.get(), &FileApiReader::dirty, this, &BuildDirManager::becameDirty); + + m_reader->setParameters(m_parameters); + emitReparseRequest(); } CMakeBuildSystem *BuildDirManager::buildSystem() const @@ -319,8 +290,7 @@ void BuildDirManager::becameDirty() void BuildDirManager::resetData() { - if (m_reader) - m_reader->resetData(); + m_reader.reset(); } bool BuildDirManager::persistCMakeState() diff --git a/src/plugins/cmakeprojectmanager/builddirmanager.h b/src/plugins/cmakeprojectmanager/builddirmanager.h index 2815d5aec77..8ed72f091ca 100644 --- a/src/plugins/cmakeprojectmanager/builddirmanager.h +++ b/src/plugins/cmakeprojectmanager/builddirmanager.h @@ -26,8 +26,8 @@ #pragma once #include "builddirparameters.h" -#include "builddirreader.h" #include "cmakebuildtarget.h" +#include "fileapireader.h" #include @@ -116,8 +116,6 @@ private: Utils::FilePath workDirectory(const BuildDirParameters ¶meters) const; - void updateReaderType(const BuildDirParameters &p, std::function todo); - bool hasConfigChanged(); void writeConfigurationIntoBuildDirectory(const Utils::MacroExpander *expander); @@ -128,7 +126,7 @@ private: int m_reparseParameters; CMakeBuildSystem *m_buildSystem = nullptr; mutable std::unordered_map> m_buildDirToTempDir; - mutable std::unique_ptr m_reader; + mutable std::unique_ptr m_reader; mutable bool m_isHandlingError = false; }; diff --git a/src/plugins/cmakeprojectmanager/builddirreader.cpp b/src/plugins/cmakeprojectmanager/builddirreader.cpp deleted file mode 100644 index 2b0c1ecb355..00000000000 --- a/src/plugins/cmakeprojectmanager/builddirreader.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "builddirreader.h" - -#include "fileapireader.h" - -#include - -using namespace ProjectExplorer; - -namespace CMakeProjectManager { -namespace Internal { - -// -------------------------------------------------------------------- -// BuildDirReader: -// -------------------------------------------------------------------- - -std::unique_ptr BuildDirReader::createReader(const BuildDirParameters &p) -{ - CMakeTool *cmake = p.cmakeTool(); - QTC_ASSERT(p.isValid() && cmake, return {}); - - auto type = cmake->readerType(); - if (!type) - return {}; - switch (type.value()) { - case CMakeTool::FileApi: - return std::make_unique(); - } -} - -} // namespace Internal -} // namespace CMakeProjectManager diff --git a/src/plugins/cmakeprojectmanager/builddirreader.h b/src/plugins/cmakeprojectmanager/builddirreader.h deleted file mode 100644 index 7448fca09a5..00000000000 --- a/src/plugins/cmakeprojectmanager/builddirreader.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "builddirparameters.h" -#include "cmakebuildtarget.h" - -#include - -#include - -#include - -namespace ProjectExplorer { class FileNode; } - -namespace CMakeProjectManager { -namespace Internal { - -class CMakeBuildConfiguration; -class CMakeProjectNode; - -class BuildDirReader : public QObject -{ - Q_OBJECT - -public: - static std::unique_ptr createReader(const BuildDirParameters &p); - virtual void setParameters(const BuildDirParameters &p) = 0; - - virtual bool isCompatible(const BuildDirParameters &p) = 0; - virtual void resetData() = 0; - virtual void parse(bool forceCMakeRun, bool forceConfiguration) = 0; - virtual void stop() = 0; - - virtual bool isParsing() const = 0; - - virtual QSet projectFilesToWatch() const = 0; - virtual QList takeBuildTargets(QString &errorMessage) = 0; - virtual CMakeConfig takeParsedConfiguration(QString &errorMessage) = 0; - virtual std::unique_ptr generateProjectTree( - const QList &allFiles, QString &errorMessage) - = 0; - virtual ProjectExplorer::RawProjectParts createRawProjectParts(QString &errorMessage) = 0; - -signals: - void isReadyNow() const; - void configurationStarted() const; - void dataAvailable() const; - void dirty() const; - void errorOccurred(const QString &message) const; - -protected: - BuildDirParameters m_parameters; -}; - -} // namespace Internal -} // namespace CMakeProjectManager diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro index a363b395bd0..09414efefb0 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro @@ -3,7 +3,6 @@ include(../../qtcreatorplugin.pri) HEADERS = builddirmanager.h \ builddirparameters.h \ - builddirreader.h \ cmakebuildstep.h \ cmakebuildsystem.h \ cmakebuildtarget.h \ @@ -40,7 +39,6 @@ HEADERS = builddirmanager.h \ SOURCES = builddirmanager.cpp \ builddirparameters.cpp \ - builddirreader.cpp \ cmakebuildstep.cpp \ cmakebuildsystem.cpp \ cmakeconfigitem.cpp \ diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs index 916324ce7ae..9cddc1d5ee7 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs @@ -23,8 +23,6 @@ QtcPlugin { "builddirparameters.h", "builddirmanager.cpp", "builddirmanager.h", - "builddirreader.cpp", - "builddirreader.h", "cmake_global.h", "cmakebuildconfiguration.cpp", "cmakebuildconfiguration.h", diff --git a/src/plugins/cmakeprojectmanager/fileapireader.cpp b/src/plugins/cmakeprojectmanager/fileapireader.cpp index 9ea5690cbff..b87455f8604 100644 --- a/src/plugins/cmakeprojectmanager/fileapireader.cpp +++ b/src/plugins/cmakeprojectmanager/fileapireader.cpp @@ -54,6 +54,8 @@ FileApiReader::FileApiReader() {} FileApiReader::~FileApiReader() { + if (isParsing()) + emit errorOccurred(tr("Parsing has been canceled.")); stop(); resetData(); } @@ -74,15 +76,6 @@ void FileApiReader::setParameters(const BuildDirParameters &p) if (!m_isParsing) emit dirty(); }); - - qCDebug(cmakeFileApiMode) << "FileApiReader: IS READY NOW SIGNAL"; - emit isReadyNow(); -} - -bool FileApiReader::isCompatible(const BuildDirParameters &p) -{ - const CMakeTool *cmakeTool = p.cmakeTool(); - return cmakeTool && cmakeTool->readerType() == CMakeTool::FileApi; } void FileApiReader::resetData() diff --git a/src/plugins/cmakeprojectmanager/fileapireader.h b/src/plugins/cmakeprojectmanager/fileapireader.h index 2be34a7c2c6..c760411ccf7 100644 --- a/src/plugins/cmakeprojectmanager/fileapireader.h +++ b/src/plugins/cmakeprojectmanager/fileapireader.h @@ -25,13 +25,17 @@ #pragma once -#include "builddirreader.h" -#include "fileapiparser.h" +#include "cmakebuildtarget.h" #include "cmakeprocess.h" +#include "cmakeprojectnodes.h" +#include "fileapiparser.h" + +#include #include #include +#include #include @@ -44,29 +48,34 @@ namespace Internal { class FileApiQtcData; -class FileApiReader final : public BuildDirReader +class FileApiReader final : public QObject { Q_OBJECT public: FileApiReader(); - ~FileApiReader() final; + ~FileApiReader(); - void setParameters(const BuildDirParameters &p) final; + void setParameters(const BuildDirParameters &p); - bool isCompatible(const BuildDirParameters &p) final; - void resetData() final; - void parse(bool forceCMakeRun, bool forceConfiguration) final; - void stop() final; + void resetData(); + void parse(bool forceCMakeRun, bool forceConfiguration); + void stop(); - bool isParsing() const final; + bool isParsing() const; - QSet projectFilesToWatch() const final; - QList takeBuildTargets(QString &errorMessage) final; - CMakeConfig takeParsedConfiguration(QString &errorMessage) final; + QSet projectFilesToWatch() const; + QList takeBuildTargets(QString &errorMessage); + CMakeConfig takeParsedConfiguration(QString &errorMessage); std::unique_ptr generateProjectTree( - const QList &allFiles, QString &errorMessage) final; - ProjectExplorer::RawProjectParts createRawProjectParts(QString &errorMessage) final; + const QList &allFiles, QString &errorMessage); + ProjectExplorer::RawProjectParts createRawProjectParts(QString &errorMessage); + +signals: + void configurationStarted() const; + void dataAvailable() const; + void dirty() const; + void errorOccurred(const QString &message) const; private: void startState(); @@ -90,6 +99,8 @@ private: bool m_isParsing = false; std::unique_ptr m_fileApi; + + BuildDirParameters m_parameters; }; } // namespace Internal