logic: added exclude filters for cbp sourcegroups

This commit is contained in:
mlangkabel
2018-06-15 18:33:04 +02:00
parent 0a6347fa43
commit b6588cd6ba
8 changed files with 62 additions and 17 deletions
@@ -16,6 +16,7 @@ void SourceGroupSettingsCxxCodeblocks::load(std::shared_ptr<const ConfigManager>
SourceGroupSettingsWithCppStandard::load(config, key);
SourceGroupSettingsWithCStandard::load(config, key);
SourceGroupSettingsWithExcludeFilters::load(config, key);
SourceGroupSettingsWithIndexedHeaderPaths::load(config, key);
SourceGroupSettingsWithSourceExtensions::load(config, key);
@@ -30,6 +31,7 @@ void SourceGroupSettingsCxxCodeblocks::save(std::shared_ptr<ConfigManager> confi
SourceGroupSettingsWithCppStandard::save(config, key);
SourceGroupSettingsWithCStandard::save(config, key);
SourceGroupSettingsWithExcludeFilters::save(config, key);
SourceGroupSettingsWithIndexedHeaderPaths::save(config, key);
SourceGroupSettingsWithSourceExtensions::save(config, key);
@@ -45,6 +47,7 @@ bool SourceGroupSettingsCxxCodeblocks::equals(std::shared_ptr<SourceGroupSetting
SourceGroupSettingsCxx::equals(other) &&
SourceGroupSettingsWithCppStandard::equals(otherCxxCodeblocks) &&
SourceGroupSettingsWithCStandard::equals(otherCxxCodeblocks) &&
SourceGroupSettingsWithExcludeFilters::equals(otherCxxCodeblocks) &&
SourceGroupSettingsWithIndexedHeaderPaths::equals(otherCxxCodeblocks) &&
SourceGroupSettingsWithSourceExtensions::equals(otherCxxCodeblocks) &&
m_codeblocksProjectPath == otherCxxCodeblocks->m_codeblocksProjectPath
@@ -4,6 +4,7 @@
#include "settings/SourceGroupSettingsCxx.h"
#include "settings/SourceGroupSettingsWithCppStandard.h"
#include "settings/SourceGroupSettingsWithCStandard.h"
#include "settings/SourceGroupSettingsWithExcludeFilters.h"
#include "settings/SourceGroupSettingsWithIndexedHeaderPaths.h"
#include "settings/SourceGroupSettingsWithSourceExtensions.h"
@@ -11,6 +12,7 @@ class SourceGroupSettingsCxxCodeblocks
: public SourceGroupSettingsCxx
, public SourceGroupSettingsWithCppStandard
, public SourceGroupSettingsWithCStandard
, public SourceGroupSettingsWithExcludeFilters
, public SourceGroupSettingsWithIndexedHeaderPaths
, public SourceGroupSettingsWithSourceExtensions
{
@@ -44,16 +44,36 @@ std::set<FilePath> SourceGroupCxxCodeblocks::filterToContainedFilePaths(const st
utility::toSet(m_settings->getIndexedHeaderPathsExpandedAndAbsolute())
);
const std::vector<FilePathFilter> excludeFilters = m_settings->getExcludeFiltersExpandedAndAbsolute();
for (const FilePath& filePath : filePaths)
{
bool isInIndexedPaths = false;
for (const FilePath& indexedPath : indexedPaths)
{
if (indexedPath == filePath || indexedPath.contains(filePath))
{
containedFilePaths.insert(filePath);
isInIndexedPaths = true;
break;
}
}
if (isInIndexedPaths)
{
for (const FilePathFilter& excludeFilter : excludeFilters)
{
if (excludeFilter.isMatching(filePath))
{
isInIndexedPaths = false;
break;
}
}
}
if (isInIndexedPaths)
{
containedFilePaths.insert(filePath);
}
}
return containedFilePaths;
@@ -66,9 +86,21 @@ std::set<FilePath> SourceGroupCxxCodeblocks::getAllSourceFilePaths() const
m_settings->getCodeblocksProjectPathExpandedAndAbsolute()
))
{
for (const FilePath& filePath : project->getAllSourceFilePathsCanonical(m_settings))
const std::vector<FilePathFilter> excludeFilters = m_settings->getExcludeFiltersExpandedAndAbsolute();
for (const FilePath& filePath : project->getAllSourceFilePathsCanonical(m_settings->getSourceExtensions()))
{
if (filePath.exists())
bool isExcluded = false;
for (const FilePathFilter& excludeFilter : excludeFilters)
{
if (excludeFilter.isMatching(filePath))
{
isExcluded = true;
break;
}
}
if (!isExcluded && filePath.exists())
{
sourceFilePaths.insert(filePath);
}
@@ -18,8 +18,6 @@ std::set<FilePath> SourceGroupCxxEmpty::filterToContainedFilePaths(const std::se
{
std::set<FilePath> containedFilePaths;
const std::set<FilePath> allSourceFilePaths = getAllSourceFilePaths();
std::vector<FilePath> indexedPaths;
std::vector<FilePathFilter> excludeFilters;
if (std::shared_ptr<SourceGroupSettingsCEmpty> settings =
@@ -126,18 +126,18 @@ namespace Codeblocks
}
std::set<FilePath> Project::getAllSourceFilePathsCanonical(
std::shared_ptr<const SourceGroupSettingsWithSourceExtensions> sourceGroupSettings
const std::vector<std::wstring>& sourceExtensions
) const
{
return utility::convert<FilePath, FilePath>(getAllSourceFilePaths(sourceGroupSettings), [](const FilePath& path) { return path.getCanonical(); });
return utility::convert<FilePath, FilePath>(getAllSourceFilePaths(sourceExtensions), [](const FilePath& path) { return path.getCanonical(); });
}
std::set<FilePath> Project::getAllSourceFilePaths(
std::shared_ptr<const SourceGroupSettingsWithSourceExtensions> sourceGroupSettings
const std::vector<std::wstring>& sourceExtensions
) const
{
const std::set<std::wstring> sourceExtensions = utility::toSet(utility::convert<std::wstring, std::wstring>(
sourceGroupSettings->getSourceExtensions(),
const std::set<std::wstring> lowerSourceExtensions = utility::toSet(utility::convert<std::wstring, std::wstring>(
sourceExtensions,
[](const std::wstring& e) { return utility::toLowerCase(e); }
));
@@ -147,7 +147,7 @@ namespace Codeblocks
if (unit && unit->getCompile())
{
FilePath filePath(unit->getFilename());
if (sourceExtensions.find(filePath.getLowerCase().extension()) != sourceExtensions.end())
if (lowerSourceExtensions.find(filePath.getLowerCase().extension()) != lowerSourceExtensions.end())
{
filePaths.insert(filePath);
}
@@ -196,10 +196,16 @@ namespace Codeblocks
std::shared_ptr<const SourceGroupSettingsCxxCodeblocks> sourceGroupSettings,
std::shared_ptr<const ApplicationSettings> appSettings) const
{
const std::set<std::wstring> sourceExtensions = utility::toSet(sourceGroupSettings->getSourceExtensions());
const std::set<std::wstring> lowerSourceExtensions = utility::toSet(utility::convert<std::wstring, std::wstring>(
sourceGroupSettings->getSourceExtensions(),
[](const std::wstring& e) { return utility::toLowerCase(e); }
));
const std::set<FilePath> indexedHeaderPaths = utility::toSet(sourceGroupSettings->getIndexedHeaderPathsExpandedAndAbsolute());
const std::set<FilePathFilter> excludeFilters = utility::toSet(sourceGroupSettings->getExcludeFiltersExpandedAndAbsolute());
const std::vector<std::wstring> compilerFlags = sourceGroupSettings->getCompilerFlags();
const std::vector<FilePath> systemHeaderSearchPaths = utility::concat(
@@ -243,7 +249,7 @@ namespace Codeblocks
}
const FilePath filePath = FilePath(unit->getFilename()).makeCanonical();
if (sourceExtensions.find(filePath.getLowerCase().extension()) == sourceExtensions.end())
if (lowerSourceExtensions.find(filePath.getLowerCase().extension()) == lowerSourceExtensions.end())
{
continue;
}
@@ -266,7 +272,7 @@ namespace Codeblocks
indexerCommands.push_back(std::make_shared<IndexerCommandCxxEmpty>(
filePath,
utility::concat(indexedHeaderPaths, { filePath }),
std::set<FilePathFilter>(),
excludeFilters,
std::set<FilePathFilter>(),
sourceGroupSettings->getCodeblocksProjectPathExpandedAndAbsolute().getParentDirectory(),
utility::concat(systemHeaderSearchPaths, headerSearchPathsCache.getValue(targetName)),
@@ -25,10 +25,10 @@ namespace Codeblocks
static std::shared_ptr<Project> load(std::shared_ptr<TextAccess> xmlAccess);
std::set<FilePath> getAllSourceFilePathsCanonical(
std::shared_ptr<const SourceGroupSettingsWithSourceExtensions> sourceGroupSettings
const std::vector<std::wstring>& sourceExtensions
) const;
std::set<FilePath> getAllSourceFilePaths(
std::shared_ptr<const SourceGroupSettingsWithSourceExtensions> sourceGroupSettings
const std::vector<std::wstring>& sourceExtensions
) const;
std::set<FilePath> getAllCxxHeaderSearchPathsCanonical() const;
@@ -527,6 +527,8 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index)
summary->addSpace();
summary->addContent(new QtProjectWizzardContentIndexedHeaderPaths("Code::Blocks project", settingsCxxCodeblocks, this));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentPathsExclude(group, this));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentExtensions(settingsCxxCodeblocks, this));
}
else if (std::shared_ptr<SourceGroupSettingsCxxSonargraph> settingsCxxSonargraph = std::dynamic_pointer_cast<SourceGroupSettingsCxxSonargraph>(group))
@@ -909,6 +911,8 @@ void QtProjectWizzard::emptySourceGroupCxxCodeblocks()
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentIndexedHeaderPaths("Code::Blocks project", settings, window));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentPathsExclude(settings, window));
contentGroup->addSpace();
contentGroup->addContent(new QtProjectWizzardContentExtensions(settings, window));
}
}
@@ -316,7 +316,7 @@ std::vector<FilePath> QtProjectWizzardContentIndexedHeaderPaths::getIndexedPaths
return path.getCanonical();
});
for (const FilePath& path : codeblocksProject->getAllSourceFilePaths(settings))
for (const FilePath& path : codeblocksProject->getAllSourceFilePaths(settings->getSourceExtensions()))
{
indexedHeaderPaths.insert(canonicalDirectoryPathCache.getValue(path.getParentDirectory()));
}