From 963fbdc5642821b219cc4fdaf8c8e2d9df20502e Mon Sep 17 00:00:00 2001 From: mlangkabel Date: Mon, 11 Jun 2018 20:45:15 +0200 Subject: [PATCH] logic: fixed exclude filters partly not working for CDB SourceGroup * fixed logic for fetching all source file paths of CDB Sourcegroup to respect exclude filters * reused this logic in wizzard ui --- src/lib_cxx/project/SourceGroupCxxCdb.cpp | 27 ++++++++++++-- .../QtProjectWizzardContentPath.cpp | 36 ++++--------------- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/src/lib_cxx/project/SourceGroupCxxCdb.cpp b/src/lib_cxx/project/SourceGroupCxxCdb.cpp index 4a655b98..daa3c314 100644 --- a/src/lib_cxx/project/SourceGroupCxxCdb.cpp +++ b/src/lib_cxx/project/SourceGroupCxxCdb.cpp @@ -78,12 +78,33 @@ std::set SourceGroupCxxCdb::filterToContainedFilePaths(const std::set< std::set SourceGroupCxxCdb::getAllSourceFilePaths() const { + std::set sourceFilePaths; + + const std::vector excludeFilters = m_settings->getExcludeFiltersExpandedAndAbsolute(); const FilePath cdbPath = m_settings->getCompilationDatabasePathExpandedAndAbsolute(); - if (cdbPath.exists()) + + if (!cdbPath.empty() && cdbPath.exists()) { - return utility::toSet(IndexerCommandCxxCdb::getSourceFilesFromCDB(cdbPath)); + for (const FilePath& path : IndexerCommandCxxCdb::getSourceFilesFromCDB(cdbPath)) + { + bool excluded = false; + for (const FilePathFilter& filter : excludeFilters) + { + if (filter.isMatching(path)) + { + excluded = true; + break; + } + } + + if (!excluded && path.exists()) + { + sourceFilePaths.insert(path); + } + } } - return std::set(); + + return sourceFilePaths; } std::vector> SourceGroupCxxCdb::getIndexerCommands(const std::set& filesToIndex) const diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp index 93adaee2..9cc38ff2 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp @@ -7,6 +7,7 @@ #include #include "data/indexer/IndexerCommandCxxCdb.h" +#include "project/SourceGroupCxxCdb.h" #include "qt/element/QtLocationPicker.h" #include "qt/view/QtDialogView.h" #include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h" @@ -171,39 +172,14 @@ void QtProjectWizzardContentPathCDB::load() { m_picker->setText(QString::fromStdWString(cxxSettings->getCompilationDatabasePath().wstr())); - const std::vector excludeFilters = cxxSettings->getExcludeFiltersExpandedAndAbsolute(); - const FilePath cdbPath = cxxSettings->getCompilationDatabasePathExpandedAndAbsolute(); - - if (!cdbPath.empty() && cdbPath.exists()) + for (FilePath path : SourceGroupCxxCdb(cxxSettings).getAllSourceFilePaths()) { - std::vector filePaths = IndexerCommandCxxCdb::getSourceFilesFromCDB(cdbPath); - - for (FilePath& path : filePaths) + if (projectPath.exists()) { - { - bool excluded = false; - for (const FilePathFilter& filter : excludeFilters) - { - if (filter.isMatching(path)) - { - excluded = true; - break; - } - } - - if (excluded) - { - continue; - } - } - - if (projectPath.exists()) - { - path.makeRelativeTo(projectPath); - } - - m_filePaths.push_back(path); + path.makeRelativeTo(projectPath); } + + m_filePaths.push_back(path); } if (m_fileCountLabel)