diff options
author | Marco Bubke <marco.bubke@qt.io> | 2018-08-07 19:01:01 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2018-08-14 12:47:03 +0000 |
commit | 4195fce68f06a1b0ed86cd1f36cddab160f3bf29 (patch) | |
tree | 087e3ce65d82c184097beea14d6bf0d72bab0122 /src/plugins | |
parent | f6b228842c7d605d59f08e31bcdc090524d53ccf (diff) | |
download | qt-creator-4195fce68f06a1b0ed86cd1f36cddab160f3bf29.tar.gz |
ClangRefactoring: Integrate generated files
This is an intermediate step to handle the indexing of the project parts
completely. The generated files are now independently handled from the
project parts. We still not handle the case the a file is indexed but the
generated file is not provided. This will be done in a different patch.
All provided data is now sorted too to improve merging.
Change-Id: I09712b99217a881ec0a233d09aea8659fb787324
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/clangpchmanager/projectupdater.cpp | 58 | ||||
-rw-r--r-- | src/plugins/clangpchmanager/projectupdater.h | 17 | ||||
-rw-r--r-- | src/plugins/clangpchmanager/qtcreatorprojectupdater.cpp | 2 | ||||
-rw-r--r-- | src/plugins/clangpchmanager/qtcreatorprojectupdater.h | 23 |
4 files changed, 81 insertions, 19 deletions
diff --git a/src/plugins/clangpchmanager/projectupdater.cpp b/src/plugins/clangpchmanager/projectupdater.cpp index 10fd98771f..66c63d1387 100644 --- a/src/plugins/clangpchmanager/projectupdater.cpp +++ b/src/plugins/clangpchmanager/projectupdater.cpp @@ -29,6 +29,7 @@ #include <filepathid.h> #include <pchmanagerserverinterface.h> +#include <removegeneratedfilesmessage.h> #include <removeprojectpartsmessage.h> #include <updategeneratedfilesmessage.h> #include <updateprojectpartsmessage.h> @@ -63,14 +64,8 @@ ProjectUpdater::ProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &s { } -void ProjectUpdater::updateProjectParts(const std::vector<CppTools::ProjectPart *> &projectParts, - ClangBackEnd::V2::FileContainers &&generatedFiles) +void ProjectUpdater::updateProjectParts(const std::vector<CppTools::ProjectPart *> &projectParts) { - m_excludedPaths = createExcludedPaths(generatedFiles); - - m_server.updateGeneratedFiles( // TODO move to an other code path - ClangBackEnd::UpdateGeneratedFilesMessage{std::move(generatedFiles)}); - m_server.updateProjectParts( ClangBackEnd::UpdateProjectPartsMessage{toProjectPartContainers(projectParts)}); } @@ -82,9 +77,41 @@ void ProjectUpdater::removeProjectParts(const QStringList &projectPartIds) m_server.removeProjectParts(std::move(message)); } -void ProjectUpdater::setExcludedPaths(Utils::PathStringVector &&excludedPaths) +void ProjectUpdater::updateGeneratedFiles(ClangBackEnd::V2::FileContainers &&generatedFiles) +{ + std::sort(generatedFiles.begin(), generatedFiles.end()); + + m_generatedFiles.update(generatedFiles); + + m_excludedPaths = createExcludedPaths(m_generatedFiles.fileContainers()); + + m_server.updateGeneratedFiles( + ClangBackEnd::UpdateGeneratedFilesMessage{std::move(generatedFiles)}); +} + +void ProjectUpdater::removeGeneratedFiles(ClangBackEnd::FilePaths &&filePaths) +{ + m_generatedFiles.remove(filePaths); + + m_excludedPaths = createExcludedPaths(m_generatedFiles.fileContainers()); + + m_server.removeGeneratedFiles( + ClangBackEnd::RemoveGeneratedFilesMessage{std::move(filePaths)}); +} + +void ProjectUpdater::setExcludedPaths(ClangBackEnd::FilePaths &&excludedPaths) +{ + m_excludedPaths = std::move(excludedPaths); +} + +const ClangBackEnd::FilePaths &ProjectUpdater::excludedPaths() const { - m_excludedPaths = excludedPaths; + return m_excludedPaths; +} + +const ClangBackEnd::GeneratedFiles &ProjectUpdater::generatedFiles() const +{ + return m_generatedFiles; } void ProjectUpdater::addToHeaderAndSources(HeaderAndSources &headerAndSources, @@ -113,6 +140,9 @@ HeaderAndSources ProjectUpdater::headerAndSourcesFromProjectPart( for (const CppTools::ProjectFile &projectFile : projectPart->files) addToHeaderAndSources(headerAndSources, projectFile); + std::sort(headerAndSources.sources.begin(), headerAndSources.sources.end()); + std::sort(headerAndSources.headers.begin(), headerAndSources.headers.end()); + return headerAndSources; } @@ -145,6 +175,8 @@ Utils::SmallStringVector ProjectUpdater::createIncludeSearchPaths( includePaths.emplace_back(projectPartHeaderPath.path); } + std::sort(includePaths.begin(), includePaths.end()); + return includePaths; } @@ -177,17 +209,19 @@ std::vector<ClangBackEnd::V2::ProjectPartContainer> ProjectUpdater::toProjectPar std::back_inserter(projectPartContainers), std::bind(&ProjectUpdater::toProjectPartContainer, this, _1)); + std::sort(projectPartContainers.begin(), projectPartContainers.end()); + return projectPartContainers; } -Utils::PathStringVector ProjectUpdater::createExcludedPaths( +ClangBackEnd::FilePaths ProjectUpdater::createExcludedPaths( const ClangBackEnd::V2::FileContainers &generatedFiles) { - Utils::PathStringVector excludedPaths; + ClangBackEnd::FilePaths excludedPaths; excludedPaths.reserve(generatedFiles.size()); auto convertToPath = [] (const ClangBackEnd::V2::FileContainer &fileContainer) { - return fileContainer.filePath.path(); + return fileContainer.filePath; }; std::transform(generatedFiles.begin(), diff --git a/src/plugins/clangpchmanager/projectupdater.h b/src/plugins/clangpchmanager/projectupdater.h index e4066cd0d1..c0040863a9 100644 --- a/src/plugins/clangpchmanager/projectupdater.h +++ b/src/plugins/clangpchmanager/projectupdater.h @@ -30,6 +30,7 @@ #include <compilermacro.h> #include <filecontainerv2.h> #include <filepathcachinginterface.h> +#include <generatedfiles.h> namespace ProjectExplorer { class Macro; @@ -66,12 +67,17 @@ public: ProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server, ClangBackEnd::FilePathCachingInterface &filePathCache); - void updateProjectParts(const std::vector<CppTools::ProjectPart *> &projectParts, - ClangBackEnd::V2::FileContainers &&generatedFiles); + void updateProjectParts(const std::vector<CppTools::ProjectPart *> &projectParts); void removeProjectParts(const QStringList &projectPartIds); + void updateGeneratedFiles(ClangBackEnd::V2::FileContainers &&generatedFiles); + void removeGeneratedFiles(ClangBackEnd::FilePaths &&filePaths); + unittest_public: - void setExcludedPaths(Utils::PathStringVector &&excludedPaths); + void setExcludedPaths(ClangBackEnd::FilePaths &&excludedPaths); + const ClangBackEnd::FilePaths &excludedPaths() const; + + const ClangBackEnd::GeneratedFiles &generatedFiles() const; HeaderAndSources headerAndSourcesFromProjectPart(CppTools::ProjectPart *projectPart) const; ClangBackEnd::V2::ProjectPartContainer toProjectPartContainer( @@ -85,11 +91,12 @@ unittest_public: const ProjectExplorer::Macros &projectMacros); static Utils::SmallStringVector createIncludeSearchPaths( const CppTools::ProjectPartHeaderPaths &projectPartHeaderPaths); - static Utils::PathStringVector createExcludedPaths( + static ClangBackEnd::FilePaths createExcludedPaths( const ClangBackEnd::V2::FileContainers &generatedFiles); private: - Utils::PathStringVector m_excludedPaths; + ClangBackEnd::GeneratedFiles m_generatedFiles; + ClangBackEnd::FilePaths m_excludedPaths; ClangBackEnd::ProjectManagementServerInterface &m_server; ClangBackEnd::FilePathCachingInterface &m_filePathCache; }; diff --git a/src/plugins/clangpchmanager/qtcreatorprojectupdater.cpp b/src/plugins/clangpchmanager/qtcreatorprojectupdater.cpp index 53b37ee2b5..5331e2ef05 100644 --- a/src/plugins/clangpchmanager/qtcreatorprojectupdater.cpp +++ b/src/plugins/clangpchmanager/qtcreatorprojectupdater.cpp @@ -55,6 +55,8 @@ std::vector<ClangBackEnd::V2::FileContainer> createGeneratedFiles() std::back_inserter(generatedFiles), toFileContainer); + std::sort(generatedFiles.begin(), generatedFiles.end()); + return generatedFiles; } diff --git a/src/plugins/clangpchmanager/qtcreatorprojectupdater.h b/src/plugins/clangpchmanager/qtcreatorprojectupdater.h index 387e4573ad..9be66f1444 100644 --- a/src/plugins/clangpchmanager/qtcreatorprojectupdater.h +++ b/src/plugins/clangpchmanager/qtcreatorprojectupdater.h @@ -71,8 +71,7 @@ public: void projectPartsUpdated(ProjectExplorer::Project *project) { - ProjectUpdaterType::updateProjectParts(Internal::createProjectParts(project), - Internal::createGeneratedFiles()); + ProjectUpdaterType::updateProjectParts(Internal::createProjectParts(project)); } void projectPartsRemoved(const QStringList &projectPartIds) @@ -80,15 +79,35 @@ public: ProjectUpdaterType::removeProjectParts(projectPartIds); } + void abstractEditorUpdated(const QString &filePath, const QByteArray &contents) + { + ProjectUpdaterType::updateGeneratedFiles({{ClangBackEnd::FilePath{filePath}, contents}}); + } + + void abstractEditorRemoved(const QString &filePath) + { + ProjectUpdaterType::removeGeneratedFiles({ClangBackEnd::FilePath{filePath}}); + } + private: void connectToCppModelManager() { + ProjectUpdaterType::updateGeneratedFiles(Internal::createGeneratedFiles()); + QObject::connect(Internal::cppModelManager(), &CppTools::CppModelManager::projectPartsUpdated, [&] (ProjectExplorer::Project *project) { projectPartsUpdated(project); }); QObject::connect(Internal::cppModelManager(), &CppTools::CppModelManager::projectPartsRemoved, [&] (const QStringList &projectPartIds) { projectPartsRemoved(projectPartIds); }); + QObject::connect(Internal::cppModelManager(), + &CppTools::CppModelManager::abstractEditorSupportContentsUpdated, + [&] (const QString &filePath, const QByteArray &contents) { + abstractEditorUpdated(filePath, contents); + }); + QObject::connect(Internal::cppModelManager(), + &CppTools::CppModelManager::abstractEditorSupportRemoved, + [&] (const QString &filePath) { abstractEditorRemoved(filePath); }); } }; |