logic: implemented usage of FilePathFilters for excluded paths
* removed check in settings for existing paths of exclude filters
This commit is contained in:
@@ -518,6 +518,7 @@ set_property(
|
||||
PROPERTY INCLUDE_DIRECTORIES
|
||||
"${CMAKE_SOURCE_DIR}/src/app"
|
||||
"${CMAKE_SOURCE_DIR}/src/lib"
|
||||
"${CMAKE_SOURCE_DIR}/src/lib_utility"
|
||||
"${CMAKE_SOURCE_DIR}/src/lib_gui"
|
||||
"${CMAKE_SOURCE_DIR}/src/lib_license"
|
||||
"${CMAKE_SOURCE_DIR}/src/lib_cxx"
|
||||
|
||||
@@ -352,6 +352,8 @@ add_files(
|
||||
utility/file/FileManager.h
|
||||
utility/file/FilePath.cpp
|
||||
utility/file/FilePath.h
|
||||
utility/file/FilePathFilter.cpp
|
||||
utility/file/FilePathFilter.h
|
||||
utility/file/FileRegister.cpp
|
||||
utility/file/FileRegister.h
|
||||
utility/file/FileRegisterStateData.cpp
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
IndexerCommand::IndexerCommand(
|
||||
const FilePath& sourceFilePath, const std::set<FilePath>& indexedPaths, const std::set<FilePath>& excludedPaths
|
||||
const FilePath& sourceFilePath, const std::set<FilePath>& indexedPaths,
|
||||
const std::set<FilePathFilter>& excludeFilters
|
||||
)
|
||||
: m_sourceFilePath(sourceFilePath)
|
||||
, m_indexedPaths(indexedPaths)
|
||||
, m_excludedPaths(excludedPaths)
|
||||
, m_excludeFilters(excludeFilters)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -24,9 +25,9 @@ size_t IndexerCommand::getByteSize(size_t stringSize) const
|
||||
size += stringSize + utility::encodeToUtf8(path.wstr()).size();
|
||||
}
|
||||
|
||||
for (const FilePath& path : m_excludedPaths)
|
||||
for (const FilePathFilter& filter : m_excludeFilters)
|
||||
{
|
||||
size += stringSize + utility::encodeToUtf8(path.wstr()).size();
|
||||
size += stringSize + utility::encodeToUtf8(filter.wstr()).size();
|
||||
}
|
||||
|
||||
return size;
|
||||
@@ -42,7 +43,7 @@ const std::set<FilePath>& IndexerCommand::getIndexedPaths() const
|
||||
return m_indexedPaths;
|
||||
}
|
||||
|
||||
const std::set<FilePath>& IndexerCommand::getExcludedPath() const
|
||||
const std::set<FilePathFilter>& IndexerCommand::getExcludeFilters() const
|
||||
{
|
||||
return m_excludedPaths;
|
||||
return m_excludeFilters;
|
||||
}
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
|
||||
#include "data/indexer/IndexerCommandType.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/file/FilePathFilter.h"
|
||||
|
||||
class IndexerCommand
|
||||
{
|
||||
public:
|
||||
IndexerCommand(const FilePath& sourceFilePath, const std::set<FilePath>& indexedPaths, const std::set<FilePath>& excludedPaths);
|
||||
IndexerCommand(const FilePath& sourceFilePath, const std::set<FilePath>& indexedPaths, const std::set<FilePathFilter>& excludeFilters);
|
||||
virtual ~IndexerCommand();
|
||||
|
||||
virtual IndexerCommandType getIndexerCommandType() const = 0;
|
||||
@@ -19,12 +20,12 @@ public:
|
||||
|
||||
const FilePath& getSourceFilePath() const;
|
||||
const std::set<FilePath>& getIndexedPaths() const;
|
||||
const std::set<FilePath>& getExcludedPath() const;
|
||||
const std::set<FilePathFilter>& getExcludeFilters() const;
|
||||
|
||||
private:
|
||||
FilePath m_sourceFilePath;
|
||||
std::set<FilePath> m_indexedPaths;
|
||||
std::set<FilePath> m_excludedPaths;
|
||||
std::set<FilePathFilter> m_excludeFilters;
|
||||
};
|
||||
|
||||
#endif // INDEXER_COMMAND_H
|
||||
|
||||
@@ -54,7 +54,7 @@ void InterprocessIndexer::work()
|
||||
data.setIndexedFiles(m_interprocessIndexingStatusManager.getIndexedFiles());
|
||||
|
||||
std::shared_ptr<FileRegister> fileRegister = std::make_shared<FileRegister>(
|
||||
data, indexerCommand->getSourceFilePath(), indexerCommand->getIndexedPaths(), indexerCommand->getExcludedPath()
|
||||
data, indexerCommand->getSourceFilePath(), indexerCommand->getIndexedPaths(), indexerCommand->getExcludeFilters()
|
||||
);
|
||||
|
||||
LOG_INFO_STREAM(<< m_processId << " starting to index current file");
|
||||
|
||||
@@ -11,7 +11,7 @@ void SharedIndexerCommand::fromLocal(IndexerCommand* indexerCommand)
|
||||
{
|
||||
setSourceFilePath(indexerCommand->getSourceFilePath());
|
||||
setIndexedPaths(indexerCommand->getIndexedPaths());
|
||||
setExcludedPaths(indexerCommand->getExcludedPath());
|
||||
setExcludeFilters(indexerCommand->getExcludeFilters());
|
||||
|
||||
if (dynamic_cast<IndexerCommandCxxCdb*>(indexerCommand) != nullptr)
|
||||
{
|
||||
@@ -58,7 +58,7 @@ std::shared_ptr<IndexerCommand> SharedIndexerCommand::fromShared(const SharedInd
|
||||
std::shared_ptr<IndexerCommand> command = std::make_shared<IndexerCommandCxxCdb>(
|
||||
indexerCommand.getSourceFilePath(),
|
||||
indexerCommand.getIndexedPaths(),
|
||||
indexerCommand.getExcludedPaths(),
|
||||
indexerCommand.getExcludeFilters(),
|
||||
indexerCommand.getWorkingDirectory(),
|
||||
indexerCommand.getCompilerFlags(),
|
||||
indexerCommand.getSystemHeaderSearchPaths(),
|
||||
@@ -71,7 +71,7 @@ std::shared_ptr<IndexerCommand> SharedIndexerCommand::fromShared(const SharedInd
|
||||
std::shared_ptr<IndexerCommand> command = std::make_shared<IndexerCommandCxxEmpty>(
|
||||
indexerCommand.getSourceFilePath(),
|
||||
indexerCommand.getIndexedPaths(),
|
||||
indexerCommand.getExcludedPaths(),
|
||||
indexerCommand.getExcludeFilters(),
|
||||
indexerCommand.getWorkingDirectory(),
|
||||
indexerCommand.getLanguageStandard(),
|
||||
indexerCommand.getSystemHeaderSearchPaths(),
|
||||
@@ -85,7 +85,7 @@ std::shared_ptr<IndexerCommand> SharedIndexerCommand::fromShared(const SharedInd
|
||||
return std::make_shared<IndexerCommandJava>(
|
||||
indexerCommand.getSourceFilePath(),
|
||||
indexerCommand.getIndexedPaths(),
|
||||
indexerCommand.getExcludedPaths(),
|
||||
indexerCommand.getExcludeFilters(),
|
||||
indexerCommand.getLanguageStandard(),
|
||||
indexerCommand.getClassPaths()
|
||||
);
|
||||
@@ -104,7 +104,7 @@ SharedIndexerCommand::SharedIndexerCommand(SharedMemory::Allocator* allocator)
|
||||
: m_type(Type::UNKNOWN)
|
||||
, m_sourceFilePath("", allocator)
|
||||
, m_indexedPaths(allocator)
|
||||
, m_excludedPaths(allocator)
|
||||
, m_excludeFilters(allocator)
|
||||
, m_workingDirectory("", allocator)
|
||||
, m_languageStandard("", allocator)
|
||||
, m_compilerFlags(allocator)
|
||||
@@ -152,27 +152,27 @@ void SharedIndexerCommand::setIndexedPaths(const std::set<FilePath>& indexedPath
|
||||
}
|
||||
}
|
||||
|
||||
std::set<FilePath> SharedIndexerCommand::getExcludedPaths() const
|
||||
std::set<FilePathFilter> SharedIndexerCommand::getExcludeFilters() const
|
||||
{
|
||||
std::set<FilePath> result;
|
||||
std::set<FilePathFilter> result;
|
||||
|
||||
for (unsigned int i = 0; i < m_excludedPaths.size(); i++)
|
||||
for (unsigned int i = 0; i < m_excludeFilters.size(); i++)
|
||||
{
|
||||
result.insert(FilePath(utility::decodeFromUtf8(m_excludedPaths[i].c_str())));
|
||||
result.insert(FilePathFilter(utility::decodeFromUtf8(m_excludeFilters[i].c_str())));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void SharedIndexerCommand::setExcludedPaths(const std::set<FilePath>& excludedPaths)
|
||||
void SharedIndexerCommand::setExcludeFilters(const std::set<FilePathFilter>& excludeFilters)
|
||||
{
|
||||
m_excludedPaths.clear();
|
||||
m_excludeFilters.clear();
|
||||
|
||||
for (const FilePath& excludedPath : excludedPaths)
|
||||
for (const FilePathFilter& excludeFilter : excludeFilters)
|
||||
{
|
||||
SharedMemory::String path(m_excludedPaths.get_allocator());
|
||||
path = utility::encodeToUtf8(excludedPath.wstr()).c_str();
|
||||
m_excludedPaths.push_back(path);
|
||||
SharedMemory::String path(m_excludeFilters.get_allocator());
|
||||
path = utility::encodeToUtf8(excludeFilter.wstr()).c_str();
|
||||
m_excludeFilters.push_back(path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <set>
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/file/FilePathFilter.h"
|
||||
#include "utility/interprocess/SharedMemory.h"
|
||||
|
||||
class IndexerCommand;
|
||||
@@ -23,8 +24,8 @@ public:
|
||||
std::set<FilePath> getIndexedPaths() const;
|
||||
void setIndexedPaths(const std::set<FilePath>& indexedPaths);
|
||||
|
||||
std::set<FilePath> getExcludedPaths() const;
|
||||
void setExcludedPaths(const std::set<FilePath>& excludedPaths);
|
||||
std::set<FilePathFilter> getExcludeFilters() const;
|
||||
void setExcludeFilters(const std::set<FilePathFilter>& excludeFilters);
|
||||
|
||||
FilePath getWorkingDirectory() const;
|
||||
void setWorkingDirectory(const FilePath& workingDirectory);
|
||||
@@ -61,7 +62,7 @@ private:
|
||||
// indexer command
|
||||
SharedMemory::String m_sourceFilePath;
|
||||
SharedMemory::Vector<SharedMemory::String> m_indexedPaths;
|
||||
SharedMemory::Vector<SharedMemory::String> m_excludedPaths;
|
||||
SharedMemory::Vector<SharedMemory::String> m_excludeFilters;
|
||||
|
||||
// cxx
|
||||
SharedMemory::String m_workingDirectory;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "utility/file/FileManager.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
SourceGroup::~SourceGroup()
|
||||
{
|
||||
@@ -29,7 +30,7 @@ void SourceGroup::fetchAllSourceFilePaths()
|
||||
FileManager fileManager;
|
||||
fileManager.update(
|
||||
getAllSourcePaths(),
|
||||
getSourceGroupSettings()->getExcludePathsExpandedAndAbsolute(),
|
||||
getSourceGroupSettings()->getExcludeFiltersExpandedAndAbsolute(),
|
||||
getSourceGroupSettings()->getSourceExtensions()
|
||||
);
|
||||
m_allSourceFilePaths = fileManager.getAllSourceFilePaths();
|
||||
@@ -40,9 +41,9 @@ std::set<FilePath> SourceGroup::getIndexedPaths() const
|
||||
return findAndAddSymlinkedDirectories(getSourceGroupSettings()->getSourcePathsExpandedAndAbsolute());
|
||||
}
|
||||
|
||||
std::set<FilePath> SourceGroup::getExcludedPaths() const
|
||||
std::set<FilePathFilter> SourceGroup::getExcludeFilters() const
|
||||
{
|
||||
return findAndAddSymlinkedDirectories(getSourceGroupSettings()->getExcludePathsExpandedAndAbsolute());
|
||||
return utility::toSet(getSourceGroupSettings()->getExcludeFiltersExpandedAndAbsolute());
|
||||
}
|
||||
|
||||
std::set<FilePath> SourceGroup::getAllSourceFilePaths() const
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "settings/SourceGroupStatusType.h"
|
||||
#include "settings/SourceGroupType.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/file/FilePathFilter.h"
|
||||
|
||||
class IndexerCommand;
|
||||
class SourceGroupSettings;
|
||||
@@ -26,7 +27,7 @@ public:
|
||||
void fetchAllSourceFilePaths();
|
||||
|
||||
std::set<FilePath> getIndexedPaths() const;
|
||||
std::set<FilePath> getExcludedPaths() const;
|
||||
std::set<FilePathFilter> getExcludeFilters() const;
|
||||
std::set<FilePath> getAllSourceFilePaths() const;
|
||||
std::set<FilePath> getSourceFilePathsToIndex(const std::set<FilePath>& staticSourceFilePaths) const;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "utility/utilityString.h"
|
||||
#include "utility/utilityUuid.h"
|
||||
|
||||
const size_t ProjectSettings::VERSION = 4;
|
||||
const size_t ProjectSettings::VERSION = 5;
|
||||
const wchar_t PROJECT_FILE_EXTENSION[] = L".srctrlprj";
|
||||
|
||||
LanguageType ProjectSettings::getLanguageOfProject(const FilePath& filePath)
|
||||
@@ -248,71 +248,78 @@ SettingsMigrator ProjectSettings::getMigrations() const
|
||||
}
|
||||
));
|
||||
|
||||
const std::string sourceGroupKey = "source_groups/source_group_" + utility::getUuidString();
|
||||
{
|
||||
const std::string sourceGroupKey = "source_groups/source_group_" + utility::getUuidString();
|
||||
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("info/description", "description"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("language_settings/standard", sourceGroupKey + "/standard"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/source_paths/source_path", sourceGroupKey + "/source_paths/source_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/exclude_paths/exclude_path", sourceGroupKey + "/exclude_paths/exclude_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/extensions/source_extensions", sourceGroupKey + "/source_extensions/source_extension"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/header_search_paths/header_search_path", sourceGroupKey + "/header_search_paths/header_search_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/use_source_paths_for_header_search", sourceGroupKey + "/use_source_paths_for_header_search"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/framework_search_paths/framework_search_path", sourceGroupKey + "/framework_search_paths/framework_search_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/compiler_flags/compiler_flag", sourceGroupKey + "/compiler_flags/compiler_flag"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/build_file_path/compilation_db_path", sourceGroupKey + "/build_file_path/compilation_db_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/class_paths/class_path", sourceGroupKey + "/class_paths/class_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/maven/project_file_path", sourceGroupKey + "/maven/project_file_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/maven/dependencies_directory", sourceGroupKey + "/maven/dependencies_directory"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/maven/should_index_tests", sourceGroupKey + "/maven/should_index_tests"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("info/description", "description"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("language_settings/standard", sourceGroupKey + "/standard"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/source_paths/source_path", sourceGroupKey + "/source_paths/source_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/exclude_paths/exclude_path", sourceGroupKey + "/exclude_paths/exclude_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/extensions/source_extensions", sourceGroupKey + "/source_extensions/source_extension"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/header_search_paths/header_search_path", sourceGroupKey + "/header_search_paths/header_search_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/use_source_paths_for_header_search", sourceGroupKey + "/use_source_paths_for_header_search"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/framework_search_paths/framework_search_path", sourceGroupKey + "/framework_search_paths/framework_search_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/compiler_flags/compiler_flag", sourceGroupKey + "/compiler_flags/compiler_flag"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/build_file_path/compilation_db_path", sourceGroupKey + "/build_file_path/compilation_db_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/class_paths/class_path", sourceGroupKey + "/class_paths/class_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/maven/project_file_path", sourceGroupKey + "/maven/project_file_path"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/maven/dependencies_directory", sourceGroupKey + "/maven/dependencies_directory"));
|
||||
migrator.addMigration(2, std::make_shared<SettingsMigrationMoveKey>("source/maven/should_index_tests", sourceGroupKey + "/maven/should_index_tests"));
|
||||
|
||||
migrator.addMigration(3, std::make_shared<SettingsMigrationLambda>(
|
||||
[=](const SettingsMigration* migration, Settings* settings)
|
||||
{
|
||||
const std::string language = migration->getValueFromSettings<std::string>(settings, "language_settings/language", "");
|
||||
|
||||
SourceGroupType type = SOURCE_GROUP_UNKNOWN;
|
||||
if (language == "C" || language == "C++")
|
||||
migrator.addMigration(3, std::make_shared<SettingsMigrationLambda>(
|
||||
[=](const SettingsMigration* migration, Settings* settings)
|
||||
{
|
||||
const std::string cdbPath = migration->getValueFromSettings<std::string>(settings, sourceGroupKey + "/build_file_path/compilation_db_path", "");
|
||||
if (!cdbPath.empty())
|
||||
{
|
||||
type = SOURCE_GROUP_CXX_CDB;
|
||||
}
|
||||
else if (language == "C")
|
||||
{
|
||||
type = SOURCE_GROUP_C_EMPTY;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = SOURCE_GROUP_CPP_EMPTY;
|
||||
}
|
||||
}
|
||||
else if (language == "Java")
|
||||
{
|
||||
const std::string mavenProjectFilePath = migration->getValueFromSettings<std::string>(settings, sourceGroupKey + "/maven/project_file_path", "");
|
||||
if (!mavenProjectFilePath.empty())
|
||||
{
|
||||
type = SOURCE_GROUP_JAVA_MAVEN;
|
||||
}
|
||||
const std::string gradleProjectFilePath = migration->getValueFromSettings<std::string>(settings, sourceGroupKey + "/gradle/project_file_path", "");
|
||||
if (!gradleProjectFilePath.empty())
|
||||
{
|
||||
type = SOURCE_GROUP_JAVA_GRADLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = SOURCE_GROUP_JAVA_EMPTY;
|
||||
}
|
||||
}
|
||||
const std::string language = migration->getValueFromSettings<std::string>(settings, "language_settings/language", "");
|
||||
|
||||
migration->setValueInSettings(settings, sourceGroupKey + "/type", sourceGroupTypeToString(type));
|
||||
}
|
||||
));
|
||||
SourceGroupType type = SOURCE_GROUP_UNKNOWN;
|
||||
if (language == "C" || language == "C++")
|
||||
{
|
||||
const std::string cdbPath = migration->getValueFromSettings<std::string>(settings, sourceGroupKey + "/build_file_path/compilation_db_path", "");
|
||||
if (!cdbPath.empty())
|
||||
{
|
||||
type = SOURCE_GROUP_CXX_CDB;
|
||||
}
|
||||
else if (language == "C")
|
||||
{
|
||||
type = SOURCE_GROUP_C_EMPTY;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = SOURCE_GROUP_CPP_EMPTY;
|
||||
}
|
||||
}
|
||||
else if (language == "Java")
|
||||
{
|
||||
const std::string mavenProjectFilePath = migration->getValueFromSettings<std::string>(settings, sourceGroupKey + "/maven/project_file_path", "");
|
||||
if (!mavenProjectFilePath.empty())
|
||||
{
|
||||
type = SOURCE_GROUP_JAVA_MAVEN;
|
||||
}
|
||||
const std::string gradleProjectFilePath = migration->getValueFromSettings<std::string>(settings, sourceGroupKey + "/gradle/project_file_path", "");
|
||||
if (!gradleProjectFilePath.empty())
|
||||
{
|
||||
type = SOURCE_GROUP_JAVA_GRADLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = SOURCE_GROUP_JAVA_EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
migration->setValueInSettings(settings, sourceGroupKey + "/type", sourceGroupTypeToString(type));
|
||||
}
|
||||
));
|
||||
}
|
||||
migrator.addMigration(4, std::make_shared<SettingsMigrationDeleteKey>("language_settings/language"));
|
||||
migrator.addMigration(4, std::make_shared<SettingsMigrationDeleteKey>("source/build_file_path/vs_solution_path"));
|
||||
migrator.addMigration(4, std::make_shared<SettingsMigrationDeleteKey>("source/extensions/header_extensions"));
|
||||
|
||||
for (std::shared_ptr<SourceGroupSettings> sourceGroupSettings : getAllSourceGroupSettings())
|
||||
{
|
||||
const std::string key = SourceGroupSettings::s_keyPrefix + sourceGroupSettings->getId();
|
||||
migrator.addMigration(5, std::make_shared<SettingsMigrationMoveKey>(key + "/exclude_paths/exclude_path", key + "/exclude_filters/exclude_filter"));
|
||||
}
|
||||
|
||||
return migrator;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,9 +85,16 @@ void Settings::setVersion(size_t version)
|
||||
FilePath Settings::expandPath(const FilePath& path)
|
||||
{
|
||||
std::vector<FilePath> paths = path.expandEnvironmentVariables();
|
||||
if (paths.size() >= 1)
|
||||
if (!paths.empty())
|
||||
{
|
||||
return paths[0];
|
||||
if (paths.size() > 1)
|
||||
{
|
||||
LOG_WARNING(
|
||||
L"Environment variable in path \"" + path.wstr() + L"\" has been expanded to " + std::to_wstring(paths.size()) +
|
||||
L"paths, but only \"" + paths.front().wstr() + L"\" will be used."
|
||||
);
|
||||
}
|
||||
return paths.front();
|
||||
}
|
||||
return FilePath();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "settings/SourceGroupSettings.h"
|
||||
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
std::string SourceGroupSettings::s_keyPrefix = "source_groups/source_group_";
|
||||
const size_t SourceGroupSettings::s_version = 1;
|
||||
const std::string SourceGroupSettings::s_keyPrefix = "source_groups/source_group_";
|
||||
|
||||
SourceGroupSettings::SourceGroupSettings(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings)
|
||||
: m_projectSettings(projectSettings)
|
||||
@@ -12,7 +14,7 @@ SourceGroupSettings::SourceGroupSettings(const std::string& id, SourceGroupType
|
||||
, m_status(SOURCE_GROUP_STATUS_ENABLED)
|
||||
, m_standard("")
|
||||
, m_sourcePaths(std::vector<FilePath>())
|
||||
, m_excludePaths(std::vector<FilePath>())
|
||||
, m_excludeFilters(std::vector<std::wstring>())
|
||||
, m_sourceExtensions(std::vector<std::wstring>())
|
||||
{
|
||||
}
|
||||
@@ -34,7 +36,7 @@ void SourceGroupSettings::load(std::shared_ptr<const ConfigManager> config)
|
||||
setStatus(stringToSourceGroupStatusType(getValue(key + "/status", sourceGroupStatusTypeToString(SOURCE_GROUP_STATUS_ENABLED), config)));
|
||||
setStandard(getValue<std::string>(key + "/standard", "", config));
|
||||
setSourcePaths(getPathValues(key + "/source_paths/source_path", config));
|
||||
setExcludePaths(getPathValues(key + "/exclude_paths/exclude_path", config));
|
||||
setExcludeFilterStrings(getValues(key + "/exclude_filters/exclude_filter", std::vector<std::wstring>(), config));
|
||||
setSourceExtensions(getValues(key + "/source_extensions/source_extension", std::vector<std::wstring>(), config));
|
||||
}
|
||||
|
||||
@@ -46,7 +48,7 @@ void SourceGroupSettings::save(std::shared_ptr<ConfigManager> config)
|
||||
setValue(key + "/name", getName(), config);
|
||||
setValue(key + "/standard", getStandard(), config);
|
||||
setPathValues(key + "/source_paths/source_path", getSourcePaths(), config);
|
||||
setPathValues(key + "/exclude_paths/exclude_path", getExcludePaths(), config);
|
||||
setValues(key + "/exclude_filters/exclude_filter", getExcludeFilterStrings(), config);
|
||||
setValues(key + "/source_extensions/source_extension", getSourceExtensions(), config);
|
||||
}
|
||||
|
||||
@@ -59,7 +61,7 @@ bool SourceGroupSettings::equals(std::shared_ptr<SourceGroupSettings> other) con
|
||||
m_status == other->m_status &&
|
||||
m_standard == other->m_standard &&
|
||||
utility::isPermutation(m_sourcePaths, other->m_sourcePaths) &&
|
||||
utility::isPermutation(m_excludePaths, other->m_excludePaths) &&
|
||||
utility::isPermutation(m_excludeFilters, other->m_excludeFilters) &&
|
||||
utility::isPermutation(m_sourceExtensions, other->m_sourceExtensions)
|
||||
);
|
||||
}
|
||||
@@ -143,19 +145,63 @@ void SourceGroupSettings::setSourcePaths(const std::vector<FilePath>& sourcePath
|
||||
m_sourcePaths = sourcePaths;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupSettings::getExcludePaths() const
|
||||
std::vector<std::wstring> SourceGroupSettings::getExcludeFilterStrings() const
|
||||
{
|
||||
return m_excludePaths;
|
||||
return m_excludeFilters;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupSettings::getExcludePathsExpandedAndAbsolute() const
|
||||
std::vector<FilePathFilter> SourceGroupSettings::getExcludeFiltersExpandedAndAbsolute() const
|
||||
{
|
||||
return m_projectSettings->makePathsExpandedAndAbsolute(getExcludePaths());
|
||||
std::vector<FilePathFilter> result;
|
||||
|
||||
for (const FilePathFilter& filter : m_excludeFilters)
|
||||
{
|
||||
const std::wstring filterString = filter.wstr();
|
||||
const size_t wildcardPos = filterString.find(L"*");
|
||||
if (wildcardPos != filterString.npos)
|
||||
{
|
||||
std::wsmatch match;
|
||||
if (std::regex_search(filterString, match, std::wregex(L"[\\\\/]")) && !match.empty() && match.position(0) < wildcardPos)
|
||||
{
|
||||
const FilePath p = m_projectSettings->makePathExpandedAndAbsolute(FilePath(match.prefix().str()));
|
||||
std::set<FilePath> symLinkPaths = FileSystem::getSymLinkedDirectories(p);
|
||||
symLinkPaths.insert(p);
|
||||
|
||||
utility::append(result,
|
||||
utility::convert<FilePath, FilePathFilter>(
|
||||
utility::toVector(symLinkPaths),
|
||||
[match](const FilePath& filePath) { return FilePathFilter(filePath.wstr() + L"/" + match.suffix().str()); }
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.push_back(filter);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const FilePath p = m_projectSettings->makePathExpandedAndAbsolute(FilePath(filterString));
|
||||
const bool isFile = p.exists() && !p.isDirectory();
|
||||
|
||||
std::set<FilePath> symLinkPaths = FileSystem::getSymLinkedDirectories(p);
|
||||
symLinkPaths.insert(p);
|
||||
|
||||
utility::append(result,
|
||||
utility::convert<FilePath, FilePathFilter>(
|
||||
utility::toVector(symLinkPaths),
|
||||
[isFile](const FilePath& filePath) { return FilePathFilter(filePath.wstr() + (isFile ? L"" : L"**")); }
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void SourceGroupSettings::setExcludePaths(const std::vector<FilePath>& excludePaths)
|
||||
void SourceGroupSettings::setExcludeFilterStrings(const std::vector<std::wstring>& excludeFilters)
|
||||
{
|
||||
m_excludePaths = excludePaths;
|
||||
m_excludeFilters = excludeFilters;
|
||||
}
|
||||
|
||||
std::vector<std::wstring> SourceGroupSettings::getSourceExtensions() const
|
||||
|
||||
@@ -7,13 +7,15 @@
|
||||
#include "settings/ProjectSettings.h"
|
||||
#include "settings/SourceGroupStatusType.h"
|
||||
#include "settings/SourceGroupType.h"
|
||||
#include "utility/file/FilePathFilter.h"
|
||||
|
||||
class ProjectSettings;
|
||||
|
||||
class SourceGroupSettings
|
||||
{
|
||||
public:
|
||||
static std::string s_keyPrefix;
|
||||
static const size_t s_version;
|
||||
static const std::string s_keyPrefix;
|
||||
|
||||
SourceGroupSettings(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings);
|
||||
virtual ~SourceGroupSettings();
|
||||
@@ -46,9 +48,9 @@ public:
|
||||
std::vector<FilePath> getSourcePathsExpandedAndAbsolute() const;
|
||||
void setSourcePaths(const std::vector<FilePath>& sourcePaths);
|
||||
|
||||
std::vector<FilePath> getExcludePaths() const;
|
||||
std::vector<FilePath> getExcludePathsExpandedAndAbsolute() const;
|
||||
void setExcludePaths(const std::vector<FilePath>& excludePaths);
|
||||
std::vector<std::wstring> getExcludeFilterStrings() const;
|
||||
std::vector<FilePathFilter> getExcludeFiltersExpandedAndAbsolute() const;
|
||||
void setExcludeFilterStrings(const std::vector<std::wstring>& excludeFilters);
|
||||
|
||||
std::vector<std::wstring> getSourceExtensions() const;
|
||||
void setSourceExtensions(const std::vector<std::wstring>& sourceExtensions);
|
||||
@@ -83,7 +85,7 @@ private:
|
||||
|
||||
std::string m_standard;
|
||||
std::vector<FilePath> m_sourcePaths;
|
||||
std::vector<FilePath> m_excludePaths;
|
||||
std::vector<std::wstring> m_excludeFilters;
|
||||
std::vector<std::wstring> m_sourceExtensions;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/file/FilePathFilter.h"
|
||||
|
||||
FileManager::FileManager()
|
||||
{
|
||||
@@ -15,11 +16,11 @@ FileManager::~FileManager()
|
||||
|
||||
void FileManager::update(
|
||||
const std::vector<FilePath>& sourcePaths,
|
||||
const std::vector<FilePath>& excludePaths,
|
||||
const std::vector<FilePathFilter>& excludeFilters,
|
||||
const std::vector<std::wstring>& sourceExtensions
|
||||
){
|
||||
m_sourcePaths = sourcePaths;
|
||||
m_excludePaths = makeCanonical(excludePaths);
|
||||
m_excludeFilters = excludeFilters;
|
||||
m_sourceExtensions = sourceExtensions;
|
||||
|
||||
m_allSourceFilePaths.clear();
|
||||
@@ -85,9 +86,9 @@ std::vector<FilePath> FileManager::makeCanonical(const std::vector<FilePath>& fi
|
||||
|
||||
bool FileManager::isExcluded(const FilePath& filePath) const
|
||||
{
|
||||
for (const FilePath& path : m_excludePaths)
|
||||
for (const FilePathFilter& filter : m_excludeFilters)
|
||||
{
|
||||
if (path == filePath || path.contains(filePath))
|
||||
if (filter.isMatching(filePath))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <vector>
|
||||
|
||||
class FilePath;
|
||||
class FilePathFilter;
|
||||
|
||||
class FileManager
|
||||
{
|
||||
@@ -16,7 +17,7 @@ public:
|
||||
|
||||
void update(
|
||||
const std::vector<FilePath>& sourcePaths,
|
||||
const std::vector<FilePath>& excludePaths,
|
||||
const std::vector<FilePathFilter>& excludeFilters,
|
||||
const std::vector<std::wstring>& sourceExtensions
|
||||
);
|
||||
|
||||
@@ -35,7 +36,7 @@ private:
|
||||
bool isExcluded(const FilePath& filePath) const;
|
||||
|
||||
std::vector<FilePath> m_sourcePaths;
|
||||
std::vector<FilePath> m_excludePaths;
|
||||
std::vector<FilePathFilter> m_excludeFilters;
|
||||
std::vector<std::wstring> m_sourceExtensions;
|
||||
|
||||
std::set<FilePath> m_allSourceFilePaths;
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
#include "utility/file/FilePathFilter.h"
|
||||
|
||||
FilePathFilter::FilePathFilter(const std::wstring& filterString)
|
||||
: m_filterString(filterString)
|
||||
, m_filterRegex(convertFilterStringToRegex(filterString))
|
||||
{
|
||||
}
|
||||
|
||||
std::wstring FilePathFilter::wstr() const
|
||||
{
|
||||
return m_filterString;
|
||||
}
|
||||
|
||||
bool FilePathFilter::isMatching(const FilePath& filePath) const
|
||||
{
|
||||
const std::wstring s = filePath.wstr();
|
||||
std::wsmatch match;
|
||||
return std::regex_match(s, match, m_filterRegex);
|
||||
}
|
||||
|
||||
bool FilePathFilter::operator<(const FilePathFilter& other) const
|
||||
{
|
||||
return m_filterString.compare(other.m_filterString) < 0;
|
||||
}
|
||||
|
||||
std::wregex FilePathFilter::convertFilterStringToRegex(const std::wstring& filterString)
|
||||
{
|
||||
std::wstring regexFilterString = filterString;
|
||||
|
||||
{
|
||||
std::wregex regex(L"[\\\\/]");
|
||||
regexFilterString = std::regex_replace(regexFilterString, regex, L"[\\\\/]");
|
||||
}
|
||||
|
||||
{
|
||||
std::wregex regex(L"([^\\\\])([^/])([\\]])");
|
||||
regexFilterString = std::regex_replace(regexFilterString, regex, L"$1$2[\\]]");
|
||||
}
|
||||
|
||||
{
|
||||
std::wregex regex(L"([\\[])([^\\\\])");
|
||||
regexFilterString = std::regex_replace(regexFilterString, regex, L"[\\[]$2");
|
||||
}
|
||||
|
||||
{
|
||||
std::wregex regex(L"[\\(]");
|
||||
regexFilterString = std::regex_replace(regexFilterString, regex, L"[\\(]");
|
||||
}
|
||||
|
||||
{
|
||||
std::wregex regex(L"[\\)]");
|
||||
regexFilterString = std::regex_replace(regexFilterString, regex, L"[\\)]");
|
||||
}
|
||||
|
||||
{
|
||||
std::wregex regex(L"[\\{]");
|
||||
regexFilterString = std::regex_replace(regexFilterString, regex, L"[\\{]");
|
||||
}
|
||||
|
||||
{
|
||||
std::wregex regex(L"[\\}]");
|
||||
regexFilterString = std::regex_replace(regexFilterString, regex, L"[\\}]");
|
||||
}
|
||||
|
||||
{
|
||||
std::wregex regex(L"[\\+]");
|
||||
regexFilterString = std::regex_replace(regexFilterString, regex, L"[\\+]");
|
||||
}
|
||||
|
||||
{
|
||||
std::wregex regex(L"[\\-]");
|
||||
regexFilterString = std::regex_replace(regexFilterString, regex, L"[\\-]");
|
||||
}
|
||||
|
||||
{
|
||||
std::wregex regex(L"[\\$]");
|
||||
regexFilterString = std::regex_replace(regexFilterString, regex, L"[\\$]");
|
||||
}
|
||||
|
||||
{
|
||||
std::wregex regex(L"[\\.]");
|
||||
regexFilterString = std::regex_replace(regexFilterString, regex, L"[\\.]");
|
||||
}
|
||||
|
||||
{
|
||||
std::wregex regex(L"[\\^]");
|
||||
regexFilterString = std::regex_replace(regexFilterString, regex, L"[\\^]");
|
||||
}
|
||||
|
||||
{
|
||||
std::wregex regex(L"[\\*][\\*]");
|
||||
regexFilterString = std::regex_replace(regexFilterString, regex, L".{0,}");
|
||||
}
|
||||
|
||||
{
|
||||
std::wregex regex(L"[\\*]");
|
||||
regexFilterString = std::regex_replace(regexFilterString, regex, L"[^\\\\/]*");
|
||||
}
|
||||
|
||||
return std::wregex(regexFilterString);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef FILE_PATH_FILTER_H
|
||||
#define FILE_PATH_FILTER_H
|
||||
|
||||
#include <regex>
|
||||
#include <string>
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
|
||||
class FilePathFilter
|
||||
{
|
||||
public:
|
||||
FilePathFilter(const std::wstring& filterString);
|
||||
|
||||
std::wstring wstr() const;
|
||||
|
||||
bool isMatching(const FilePath& filePath) const;
|
||||
|
||||
bool operator<(const FilePathFilter& other) const;
|
||||
|
||||
private:
|
||||
static std::wregex convertFilterStringToRegex(const std::wstring& filterString);
|
||||
|
||||
std::wstring m_filterString;
|
||||
std::wregex m_filterRegex;
|
||||
};
|
||||
|
||||
#endif // FILE_PATH_FILTER_H
|
||||
@@ -1,17 +1,18 @@
|
||||
#include "utility/file/FileRegister.h"
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/file/FilePathFilter.h"
|
||||
|
||||
FileRegister::FileRegister(
|
||||
const FileRegisterStateData& stateData,
|
||||
const FilePath& currentPath,
|
||||
const std::set<FilePath>& indexedPaths,
|
||||
const std::set<FilePath>& excludedPaths
|
||||
const std::set<FilePathFilter>& excludeFilters
|
||||
)
|
||||
: m_stateData(stateData)
|
||||
, m_currentPath(currentPath)
|
||||
, m_indexedPaths(indexedPaths)
|
||||
, m_excludedPaths(excludedPaths)
|
||||
, m_excludeFilters(excludeFilters)
|
||||
, m_hasFilePathCache(
|
||||
[&](const std::wstring& f)
|
||||
{
|
||||
@@ -48,23 +49,12 @@ FileRegister::FileRegister(
|
||||
|
||||
if (ret)
|
||||
{
|
||||
for (const FilePath& excluded: m_excludedPaths)
|
||||
for (const FilePathFilter& excludeFilter: m_excludeFilters)
|
||||
{
|
||||
if (excluded.isDirectory())
|
||||
if (excludeFilter.isMatching(filePath))
|
||||
{
|
||||
if (excluded.contains(filePath))
|
||||
{
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (excluded == filePath)
|
||||
{
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "utility/file/FileRegisterStateData.h"
|
||||
#include "utility/UnorderedCache.h"
|
||||
|
||||
class FilePathFilter;
|
||||
|
||||
class FileRegister
|
||||
{
|
||||
public:
|
||||
@@ -13,7 +15,7 @@ public:
|
||||
const FileRegisterStateData& stateData,
|
||||
const FilePath& currentPath,
|
||||
const std::set<FilePath>& indexedPaths,
|
||||
const std::set<FilePath>& excludedPaths
|
||||
const std::set<FilePathFilter>& excludeFilters
|
||||
);
|
||||
virtual ~FileRegister();
|
||||
|
||||
@@ -28,7 +30,7 @@ private:
|
||||
FileRegisterStateData m_stateData;
|
||||
const FilePath& m_currentPath;
|
||||
const std::set<FilePath> m_indexedPaths;
|
||||
const std::set<FilePath> m_excludedPaths;
|
||||
const std::set<FilePathFilter> m_excludeFilters;
|
||||
mutable UnorderedCache<std::wstring, bool> m_hasFilePathCache;
|
||||
};
|
||||
|
||||
|
||||
@@ -132,10 +132,14 @@ std::vector<FileInfo> FileSystem::getFileInfosFromPaths(
|
||||
return files;
|
||||
}
|
||||
|
||||
std::set<FilePath> FileSystem::getSymLinkedDirectories(const FilePath& path)
|
||||
{
|
||||
return getSymLinkedDirectories(std::vector<FilePath>{path});
|
||||
}
|
||||
|
||||
std::set<FilePath> FileSystem::getSymLinkedDirectories(const std::vector<FilePath>& paths)
|
||||
{
|
||||
std::set<boost::filesystem::path> symlinkDirs;
|
||||
std::set<boost::filesystem::path> filePaths;
|
||||
|
||||
for (const FilePath& path: paths)
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
static std::vector<FileInfo> getFileInfosFromPaths(
|
||||
const std::vector<FilePath>& paths, const std::vector<std::wstring>& fileExtensions, bool followSymLinks = true);
|
||||
|
||||
static std::set<FilePath> getSymLinkedDirectories(const FilePath& path);
|
||||
static std::set<FilePath> getSymLinkedDirectories(const std::vector<FilePath>& paths);
|
||||
|
||||
static unsigned long long getFileByteSize(const FilePath& filePath);
|
||||
|
||||
@@ -67,6 +67,9 @@ namespace utility
|
||||
template<typename SourceType, typename TargetType>
|
||||
std::vector<TargetType> convert(const std::vector<SourceType>& sourceContainer, std::function<TargetType(const SourceType&)> conversion);
|
||||
|
||||
template<typename SourceType, typename TargetType>
|
||||
std::vector<TargetType> convert(const std::vector<SourceType>& sourceContainer);
|
||||
|
||||
template<typename T>
|
||||
std::vector<std::string> toStrings(const std::vector<T>& d);
|
||||
template<>
|
||||
@@ -239,6 +242,17 @@ std::vector<TargetType> utility::convert(const std::vector<SourceType>& sourceCo
|
||||
return targetContainer;
|
||||
}
|
||||
|
||||
template<typename SourceType, typename TargetType>
|
||||
std::vector<TargetType> utility::convert(const std::vector<SourceType>& sourceContainer)
|
||||
{
|
||||
std::vector<TargetType> targetContainer;
|
||||
for (const SourceType& sourceElement : sourceContainer)
|
||||
{
|
||||
targetContainer.push_back(TargetType(sourceElement));
|
||||
}
|
||||
return targetContainer;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::vector<std::string> utility::toStrings(const std::vector<T>& d)
|
||||
{
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
|
||||
IndexerCommandCxx::IndexerCommandCxx(
|
||||
const FilePath& sourceFilePath,
|
||||
const std::set<FilePath>& indexedPaths,
|
||||
const std::set<FilePath>& excludedPaths,
|
||||
const std::set<FilePath>& indexedPaths,
|
||||
const std::set<FilePathFilter>& excludeFilters,
|
||||
const FilePath& workingDirectory,
|
||||
const std::vector<FilePath>& systemHeaderSearchPaths,
|
||||
const std::vector<FilePath>& frameworkSearchPaths,
|
||||
const std::vector<std::wstring>& compilerFlags
|
||||
)
|
||||
: IndexerCommand(sourceFilePath, indexedPaths, excludedPaths)
|
||||
: IndexerCommand(sourceFilePath, indexedPaths, excludeFilters)
|
||||
, m_workingDirectory(workingDirectory)
|
||||
, m_systemHeaderSearchPaths(systemHeaderSearchPaths)
|
||||
, m_frameworkSearchPaths(frameworkSearchPaths)
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
IndexerCommandCxx(
|
||||
const FilePath& sourceFilePath,
|
||||
const std::set<FilePath>& indexedPaths,
|
||||
const std::set<FilePath>& excludedPaths,
|
||||
const std::set<FilePathFilter>& excludeFilters,
|
||||
const FilePath& workingDirectory,
|
||||
const std::vector<FilePath>& systemHeaderSearchPaths,
|
||||
const std::vector<FilePath>& frameworkSearchPaths,
|
||||
|
||||
@@ -42,13 +42,13 @@ IndexerCommandType IndexerCommandCxxCdb::getStaticIndexerCommandType()
|
||||
IndexerCommandCxxCdb::IndexerCommandCxxCdb(
|
||||
const FilePath& sourceFilePath,
|
||||
const std::set<FilePath>& indexedPaths,
|
||||
const std::set<FilePath>& excludedPaths,
|
||||
const std::set<FilePathFilter>& excludeFilters,
|
||||
const FilePath& workingDirectory,
|
||||
const std::vector<std::wstring>& compilerFlags,
|
||||
const std::vector<FilePath>& systemHeaderSearchPaths,
|
||||
const std::vector<FilePath>& frameworkSearchPaths
|
||||
)
|
||||
: IndexerCommandCxx(sourceFilePath, indexedPaths, excludedPaths, workingDirectory, systemHeaderSearchPaths, frameworkSearchPaths, compilerFlags)
|
||||
: IndexerCommandCxx(sourceFilePath, indexedPaths, excludeFilters, workingDirectory, systemHeaderSearchPaths, frameworkSearchPaths, compilerFlags)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "data/indexer/IndexerCommandCxx.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/file/FilePathFilter.h"
|
||||
|
||||
namespace clang
|
||||
{
|
||||
@@ -23,7 +24,7 @@ public:
|
||||
IndexerCommandCxxCdb(
|
||||
const FilePath& sourceFilePath,
|
||||
const std::set<FilePath>& indexedPaths,
|
||||
const std::set<FilePath>& excludedPaths,
|
||||
const std::set<FilePathFilter>& excludeFilters,
|
||||
const FilePath& workingDirectory,
|
||||
const std::vector<std::wstring>& compilerFlags,
|
||||
const std::vector<FilePath>& systemHeaderSearchPaths,
|
||||
|
||||
@@ -8,14 +8,14 @@ IndexerCommandType IndexerCommandCxxEmpty::getStaticIndexerCommandType()
|
||||
IndexerCommandCxxEmpty::IndexerCommandCxxEmpty(
|
||||
const FilePath& sourceFilePath,
|
||||
const std::set<FilePath>& indexedPaths,
|
||||
const std::set<FilePath>& excludedPaths,
|
||||
const std::set<FilePathFilter>& excludeFilters,
|
||||
const FilePath& workingDirectory,
|
||||
const std::string& languageStandard,
|
||||
const std::vector<FilePath>& systemHeaderSearchPaths,
|
||||
const std::vector<FilePath>& frameworkSearchPaths,
|
||||
const std::vector<std::wstring>& compilerFlags
|
||||
)
|
||||
: IndexerCommandCxx(sourceFilePath, indexedPaths, excludedPaths, workingDirectory, systemHeaderSearchPaths, frameworkSearchPaths, compilerFlags)
|
||||
: IndexerCommandCxx(sourceFilePath, indexedPaths, excludeFilters, workingDirectory, systemHeaderSearchPaths, frameworkSearchPaths, compilerFlags)
|
||||
, m_languageStandard(languageStandard)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
IndexerCommandCxxEmpty(
|
||||
const FilePath& sourceFilePath,
|
||||
const std::set<FilePath>& indexedPaths,
|
||||
const std::set<FilePath>& excludedPaths,
|
||||
const std::set<FilePathFilter>& excludeFilters,
|
||||
const FilePath& workingDirectory,
|
||||
const std::string& languageStandard,
|
||||
const std::vector<FilePath>& systemHeaderSearchPaths,
|
||||
|
||||
@@ -69,7 +69,7 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxCdb::getIndexerComman
|
||||
const std::vector<std::wstring> compilerFlags = m_settings->getCompilerFlags();
|
||||
|
||||
std::set<FilePath> indexedPaths = getIndexedPaths();
|
||||
std::set<FilePath> excludedPaths = getExcludedPaths();
|
||||
std::set<FilePathFilter> excludeFilters = getExcludeFilters();
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
|
||||
|
||||
@@ -108,7 +108,7 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxCdb::getIndexerComman
|
||||
indexerCommands.push_back(std::make_shared<IndexerCommandCxxCdb>(
|
||||
sourcePath,
|
||||
indexedPaths,
|
||||
excludedPaths,
|
||||
getExcludeFilters(),
|
||||
FilePath(utility::decodeFromUtf8(command.Directory)),
|
||||
utility::concat(
|
||||
utility::convert<std::string, std::wstring>(command.CommandLine, [](const std::string& arg) { return utility::decodeFromUtf8(arg); }),
|
||||
|
||||
@@ -52,7 +52,7 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxEmpty::getIndexerComm
|
||||
utility::append(compilerFlags, m_settings->getCompilerFlags());
|
||||
|
||||
std::set<FilePath> indexedPaths = getIndexedPaths();
|
||||
std::set<FilePath> excludedPaths = getExcludedPaths();
|
||||
std::set<FilePathFilter> excludeFilters = getExcludeFilters();
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
|
||||
for (const FilePath& sourcePath: getAllSourceFilePaths())
|
||||
@@ -62,7 +62,7 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxEmpty::getIndexerComm
|
||||
indexerCommands.push_back(std::make_shared<IndexerCommandCxxEmpty>(
|
||||
sourcePath,
|
||||
indexedPaths,
|
||||
excludedPaths,
|
||||
excludeFilters,
|
||||
m_settings->getProjectDirectoryPath(),
|
||||
m_settings->getStandard(),
|
||||
systemHeaderSearchPaths,
|
||||
|
||||
@@ -33,7 +33,7 @@ void QtProjectWizzardContentCDBSource::load()
|
||||
m_filePaths.clear();
|
||||
|
||||
const FilePath projectPath = m_settings->getProjectDirectoryPath();
|
||||
std::vector<FilePath> excludePaths = m_settings->getExcludePathsExpandedAndAbsolute();
|
||||
const std::vector<FilePathFilter> excludeFilters = m_settings->getExcludeFiltersExpandedAndAbsolute();
|
||||
|
||||
if (std::shared_ptr<SourceGroupSettingsCxxCdb> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxxCdb>(m_settings))
|
||||
{
|
||||
@@ -44,19 +44,21 @@ void QtProjectWizzardContentCDBSource::load()
|
||||
|
||||
for (FilePath& path : filePaths)
|
||||
{
|
||||
bool excluded = false;
|
||||
for (const FilePath& p : excludePaths)
|
||||
{
|
||||
if (p == path || p.contains(path))
|
||||
bool excluded = false;
|
||||
for (const FilePathFilter& filter : excludeFilters)
|
||||
{
|
||||
excluded = true;
|
||||
break;
|
||||
if (filter.isMatching(path))
|
||||
{
|
||||
excluded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (excluded)
|
||||
{
|
||||
continue;
|
||||
if (excluded)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (projectPath.exists())
|
||||
|
||||
@@ -260,7 +260,7 @@ std::vector<FilePath> QtProjectWizzardContentPathSourceMaven::getFilePaths() con
|
||||
FileManager fileManager;
|
||||
fileManager.update(
|
||||
sourceDirectories,
|
||||
m_settings->getExcludePathsExpandedAndAbsolute(),
|
||||
m_settings->getExcludeFiltersExpandedAndAbsolute(),
|
||||
m_settings->getSourceExtensions()
|
||||
);
|
||||
|
||||
@@ -391,7 +391,7 @@ std::vector<FilePath> QtProjectWizzardContentPathSourceGradle::getFilePaths() co
|
||||
FileManager fileManager;
|
||||
fileManager.update(
|
||||
sourceDirectories,
|
||||
m_settings->getExcludePathsExpandedAndAbsolute(),
|
||||
m_settings->getExcludeFiltersExpandedAndAbsolute(),
|
||||
m_settings->getSourceExtensions()
|
||||
);
|
||||
|
||||
|
||||
@@ -27,11 +27,12 @@
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
QtProjectWizzardContentPaths::QtProjectWizzardContentPaths(
|
||||
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window
|
||||
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window, bool checkMissingPaths
|
||||
)
|
||||
: QtProjectWizzardContent(window)
|
||||
, m_settings(settings)
|
||||
, m_makePathsRelativeToProjectFileLocation(true)
|
||||
, m_checkMissingPaths(checkMissingPaths)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -70,56 +71,61 @@ void QtProjectWizzardContentPaths::populate(QGridLayout* layout, int& row)
|
||||
|
||||
bool QtProjectWizzardContentPaths::check()
|
||||
{
|
||||
QString missingPaths;
|
||||
std::vector<FilePath> existingPaths;
|
||||
|
||||
for (const FilePath& path : m_list->getList())
|
||||
if (m_checkMissingPaths)
|
||||
{
|
||||
std::vector<FilePath> expandedPaths(1, path);
|
||||
if (m_settings)
|
||||
{
|
||||
expandedPaths = m_settings->makePathsExpandedAndAbsolute(expandedPaths);
|
||||
}
|
||||
QString missingPaths;
|
||||
std::vector<FilePath> existingPaths;
|
||||
|
||||
size_t existingCount = 0;
|
||||
for (const FilePath& expandedPath : expandedPaths)
|
||||
for (const FilePath& path : m_list->getList())
|
||||
{
|
||||
if (!expandedPath.exists())
|
||||
std::vector<FilePath> expandedPaths(1, path);
|
||||
if (m_settings)
|
||||
{
|
||||
missingPaths.append(QString::fromStdWString(expandedPath.wstr() + L"\n"));
|
||||
expandedPaths = m_settings->makePathsExpandedAndAbsolute(expandedPaths);
|
||||
}
|
||||
else
|
||||
|
||||
size_t existingCount = 0;
|
||||
for (const FilePath& expandedPath : expandedPaths)
|
||||
{
|
||||
existingCount++;
|
||||
if (!expandedPath.exists())
|
||||
{
|
||||
missingPaths.append(QString::fromStdWString(expandedPath.wstr() + L"\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
existingCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!expandedPaths.empty() && expandedPaths.size() == existingCount)
|
||||
{
|
||||
existingPaths.push_back(path);
|
||||
}
|
||||
}
|
||||
|
||||
if (!expandedPaths.empty() && expandedPaths.size() == existingCount)
|
||||
if (!missingPaths.isEmpty())
|
||||
{
|
||||
existingPaths.push_back(path);
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(
|
||||
QString(
|
||||
"Some provided paths do not exist at \"%1\". Do you want to remove them before continuing?"
|
||||
).arg(m_titleString)
|
||||
);
|
||||
msgBox.setDetailedText(missingPaths);
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
|
||||
int ret = msgBox.exec();
|
||||
|
||||
if (ret == QMessageBox::Yes)
|
||||
{
|
||||
m_list->setList(existingPaths);
|
||||
save();
|
||||
}
|
||||
else if (ret == QMessageBox::Cancel)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!missingPaths.isEmpty())
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString("Some provided paths do not exist at \"%1\". Do you want to remove them "
|
||||
"before continuing?").arg(m_titleString));
|
||||
msgBox.setDetailedText(missingPaths);
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
|
||||
int ret = msgBox.exec();
|
||||
|
||||
if (ret == QMessageBox::Yes)
|
||||
{
|
||||
m_list->setList(existingPaths);
|
||||
save();
|
||||
}
|
||||
else if (ret == QMessageBox::Cancel)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -217,7 +223,7 @@ std::vector<FilePath> QtProjectWizzardContentPathsSource::getFilePaths() const
|
||||
FileManager fileManager;
|
||||
fileManager.update(
|
||||
m_settings->getSourcePathsExpandedAndAbsolute(),
|
||||
m_settings->getExcludePathsExpandedAndAbsolute(),
|
||||
m_settings->getExcludeFiltersExpandedAndAbsolute(),
|
||||
m_settings->getSourceExtensions()
|
||||
);
|
||||
|
||||
@@ -400,7 +406,7 @@ void QtProjectWizzardContentPathsCDBHeader::savedFilesDialog()
|
||||
QtProjectWizzardContentPathsExclude::QtProjectWizzardContentPathsExclude(
|
||||
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContentPaths(settings, window)
|
||||
: QtProjectWizzardContentPaths(settings, window, false)
|
||||
{
|
||||
setTitleString("Excluded Files & Directories");
|
||||
setHelpString(
|
||||
@@ -412,12 +418,12 @@ QtProjectWizzardContentPathsExclude::QtProjectWizzardContentPathsExclude(
|
||||
|
||||
void QtProjectWizzardContentPathsExclude::load()
|
||||
{
|
||||
m_list->setList(m_settings->getExcludePaths());
|
||||
m_list->setStringList(m_settings->getExcludeFilterStrings());
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPathsExclude::save()
|
||||
{
|
||||
m_settings->setExcludePaths(m_list->getList());
|
||||
m_settings->setExcludeFilterStrings(m_list->getStringList());
|
||||
}
|
||||
|
||||
|
||||
@@ -542,7 +548,7 @@ void QtProjectWizzardContentPathsHeaderSearch::validateIncludesButtonClicked()
|
||||
FileManager fileManager;
|
||||
fileManager.update(
|
||||
m_settings->getSourcePathsExpandedAndAbsolute(),
|
||||
m_settings->getExcludePathsExpandedAndAbsolute(),
|
||||
m_settings->getExcludeFiltersExpandedAndAbsolute(),
|
||||
m_settings->getSourceExtensions()
|
||||
);
|
||||
sourceFilePaths = fileManager.getAllSourceFilePaths();
|
||||
@@ -605,7 +611,7 @@ void QtProjectWizzardContentPathsHeaderSearch::finishedSelectDetectIncludesRootP
|
||||
FileManager fileManager;
|
||||
fileManager.update(
|
||||
m_settings->getSourcePathsExpandedAndAbsolute(),
|
||||
m_settings->getExcludePathsExpandedAndAbsolute(),
|
||||
m_settings->getExcludeFiltersExpandedAndAbsolute(),
|
||||
m_settings->getSourceExtensions()
|
||||
);
|
||||
sourceFilePaths = fileManager.getAllSourceFilePaths();
|
||||
|
||||
@@ -24,7 +24,7 @@ signals:
|
||||
void showSourceFiles();
|
||||
|
||||
public:
|
||||
QtProjectWizzardContentPaths(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window);
|
||||
QtProjectWizzardContentPaths(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window, bool checkMissingPaths = true);
|
||||
|
||||
// QtSettingsWindow implementation
|
||||
virtual void populate(QGridLayout* layout, int& row) override;
|
||||
@@ -50,6 +50,7 @@ private slots:
|
||||
void detectionClicked();
|
||||
|
||||
private:
|
||||
const bool m_checkMissingPaths;
|
||||
QString m_titleString;
|
||||
QString m_helpString;
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ IndexerCommandType IndexerCommandJava::getStaticIndexerCommandType()
|
||||
IndexerCommandJava::IndexerCommandJava(
|
||||
const FilePath& sourceFilePath,
|
||||
const std::set<FilePath>& indexedPaths,
|
||||
const std::set<FilePath>& excludedPaths,
|
||||
const std::set<FilePathFilter>& excludeFilters,
|
||||
const std::string& languageStandard,
|
||||
const std::vector<FilePath>& classPath
|
||||
)
|
||||
: IndexerCommand(sourceFilePath, indexedPaths, excludedPaths)
|
||||
: IndexerCommand(sourceFilePath, indexedPaths, excludeFilters)
|
||||
, m_languageStandard(languageStandard)
|
||||
, m_classPath(classPath)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
IndexerCommandJava(
|
||||
const FilePath& sourceFilePath,
|
||||
const std::set<FilePath>& indexedPaths,
|
||||
const std::set<FilePath>& excludedPaths,
|
||||
const std::set<FilePathFilter>& excludeFilters,
|
||||
const std::string& languageStandard,
|
||||
const std::vector<FilePath>& classPath);
|
||||
virtual ~IndexerCommandJava();
|
||||
|
||||
@@ -37,7 +37,7 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupJava::getIndexerCommands
|
||||
|
||||
std::vector<FilePath> classPath = getClassPath();
|
||||
std::set<FilePath> indexedPaths = getIndexedPaths();
|
||||
std::set<FilePath> excludedPaths = getExcludedPaths();
|
||||
std::set<FilePathFilter> excludeFilters = getExcludeFilters();
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
|
||||
for (const FilePath& sourcePath: getAllSourceFilePaths())
|
||||
@@ -45,7 +45,7 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupJava::getIndexerCommands
|
||||
if (filesToIndex.find(sourcePath) != filesToIndex.end())
|
||||
{
|
||||
indexerCommands.push_back(
|
||||
std::make_shared<IndexerCommandJava>(sourcePath, indexedPaths, excludedPaths, languageStandard, classPath));
|
||||
std::make_shared<IndexerCommandJava>(sourcePath, indexedPaths, excludeFilters, languageStandard, classPath));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ add_files(
|
||||
CxxParserTestSuite.h
|
||||
CxxTypeNameTestSuite.h
|
||||
FileManagerTestSuite.h
|
||||
FilePathFilterTestSuite.h
|
||||
FilePathTestSuite.h
|
||||
FileSystemTestSuite.h
|
||||
GeneratorTestSuite.h
|
||||
|
||||
@@ -123,14 +123,14 @@ private:
|
||||
std::shared_ptr<TextAccess> parseCode(const FilePath& sourceFilePath, const FilePath& projectDataSrcRoot)
|
||||
{
|
||||
const std::set<FilePath> indexedPaths = { projectDataSrcRoot };
|
||||
const std::set<FilePath> excludedPaths = {};
|
||||
const std::set<FilePathFilter> excludedFilters = {};
|
||||
const FilePath workingDirectory(L".");
|
||||
|
||||
std::shared_ptr<FileRegister> fileRegister = std::make_shared<FileRegister>(
|
||||
FileRegisterStateData(),
|
||||
sourceFilePath,
|
||||
indexedPaths,
|
||||
excludedPaths
|
||||
excludedFilters
|
||||
);
|
||||
|
||||
std::shared_ptr<DumpParserClient> parserClient = std::make_shared<DumpParserClient>();
|
||||
@@ -140,7 +140,7 @@ private:
|
||||
std::shared_ptr<IndexerCommandCxxEmpty> command = std::make_shared<IndexerCommandCxxEmpty>(
|
||||
sourceFilePath,
|
||||
indexedPaths,
|
||||
excludedPaths,
|
||||
excludedFilters,
|
||||
workingDirectory,
|
||||
"c++1z",
|
||||
utility::concat(std::vector<FilePath> { projectDataSrcRoot }, ApplicationSettings::getInstance()->getHeaderSearchPathsExpanded()),
|
||||
|
||||
@@ -3991,13 +3991,13 @@ public:
|
||||
void test_cxx_parser_parses_multiple_files()
|
||||
{
|
||||
const std::set<FilePath> indexedPaths = { FilePath(L"data/CxxParserTestSuite/") };
|
||||
const std::set<FilePath> excludedPaths;
|
||||
const std::set<FilePathFilter> excludeFilters;
|
||||
const FilePath workingDirectory(L".");
|
||||
|
||||
std::shared_ptr<IndexerCommandCxxEmpty> indexerCommand = std::make_shared<IndexerCommandCxxEmpty>(
|
||||
FilePath(L"data/CxxParserTestSuite/code.cpp"),
|
||||
indexedPaths,
|
||||
excludedPaths,
|
||||
excludeFilters,
|
||||
workingDirectory,
|
||||
"c++1z",
|
||||
std::vector<FilePath>(),
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
sourcePaths.push_back(FilePath(L"./data/FileManagerTestSuite/src/"));
|
||||
sourcePaths.push_back(FilePath(L"./data/FileManagerTestSuite/include/"));
|
||||
std::vector<FilePath> headerPaths;
|
||||
std::vector<FilePath> excludePaths;
|
||||
std::vector<FilePathFilter> excludeFilters;
|
||||
|
||||
std::vector<FilePath> filePaths = FileSystem::getFilePathsFromDirectory(FilePath(L"./data/FileManagerTestSuite/src/"));
|
||||
TS_ASSERT_EQUALS(filePaths.size(), 3);
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
TS_ASSERT_EQUALS(sourceExtensions.size(), 3);
|
||||
|
||||
FileManager fm;
|
||||
fm.update(sourcePaths, excludePaths, sourceExtensions);
|
||||
fm.update(sourcePaths, excludeFilters, sourceExtensions);
|
||||
std::vector<FilePath> foundSourcePaths = utility::toVector(fm.getAllSourceFilePaths());
|
||||
|
||||
TS_ASSERT_EQUALS(foundSourcePaths.size(), 3);
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
#include "cxxtest/TestSuite.h"
|
||||
|
||||
#include "utility/file/FilePathFilter.h"
|
||||
|
||||
class FilePathFilterTestSuite: public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
void test_file_path_filter_finds_exact_match()
|
||||
{
|
||||
FilePathFilter filter(L"test.h");
|
||||
|
||||
TS_ASSERT(filter.isMatching(FilePath(L"test.h")));
|
||||
}
|
||||
|
||||
void test_file_path_filter_finds_match_with_single_asterisk_in_same_level()
|
||||
{
|
||||
FilePathFilter filter(L"*test.*");
|
||||
|
||||
TS_ASSERT(filter.isMatching(FilePath(L"this_is_a_test.h")));
|
||||
}
|
||||
|
||||
void test_file_path_filter_finds_match_with_single_asterisk_in_different_level()
|
||||
{
|
||||
FilePathFilter filter(L"*/this_is_a_test.h");
|
||||
|
||||
TS_ASSERT(filter.isMatching(FilePath(L"folder/this_is_a_test.h")));
|
||||
}
|
||||
|
||||
void test_file_path_filter_does_not_find_match_with_single_asterisk_in_different_level()
|
||||
{
|
||||
FilePathFilter filter(L"*/test.h");
|
||||
|
||||
TS_ASSERT(!filter.isMatching(FilePath(L"test.h")));
|
||||
}
|
||||
|
||||
void test_file_path_filter_finds_match_with_multiple_asterisk_in_same_level()
|
||||
{
|
||||
FilePathFilter filter(L"**test.h");
|
||||
|
||||
TS_ASSERT(filter.isMatching(FilePath(L"folder/this_is_a_test.h")));
|
||||
}
|
||||
|
||||
void test_file_path_filter_finds_match_with_multiple_asterisk_in_different_level()
|
||||
{
|
||||
FilePathFilter filter(L"root/**/test.h");
|
||||
|
||||
TS_ASSERT(filter.isMatching(FilePath(L"root/folder1/folder2/test.h")));
|
||||
}
|
||||
|
||||
void test_file_path_filter_does_not_find_match_with_multiple_asterisk_in_different_level()
|
||||
{
|
||||
FilePathFilter filter(L"**/test.h");
|
||||
|
||||
TS_ASSERT(!filter.isMatching(FilePath(L"folder/this_is_a_test.h")));
|
||||
}
|
||||
|
||||
void test_file_path_filter_escapes_dot_character()
|
||||
{
|
||||
FilePathFilter filter(L"test.h");
|
||||
|
||||
TS_ASSERT(!filter.isMatching(FilePath(L"testyh")));
|
||||
}
|
||||
|
||||
void test_file_path_filter_escapes_plus_character()
|
||||
{
|
||||
TS_ASSERT(FilePathFilter(L"folder/test+.h").isMatching(FilePath(L"folder/test+.h")));
|
||||
}
|
||||
|
||||
void test_file_path_filter_escapes_minus_character()
|
||||
{
|
||||
TS_ASSERT(FilePathFilter(L"folder/test[-].h").isMatching(FilePath(L"folder/test[-].h")));
|
||||
}
|
||||
|
||||
void test_file_path_filter_escapes_dollar_character()
|
||||
{
|
||||
TS_ASSERT(FilePathFilter(L"folder/test$.h").isMatching(FilePath(L"folder/test$.h")));
|
||||
}
|
||||
|
||||
void test_file_path_filter_escapes_circumflex_character()
|
||||
{
|
||||
TS_ASSERT(FilePathFilter(L"folder/test^.h").isMatching(FilePath(L"folder/test^.h")));
|
||||
}
|
||||
|
||||
void test_file_path_filter_escapes_open_round_brace_character()
|
||||
{
|
||||
TS_ASSERT(FilePathFilter(L"folder/test(.h").isMatching(FilePath(L"folder/test(.h")));
|
||||
}
|
||||
|
||||
void test_file_path_filter_escapes_close_round_brace_character()
|
||||
{
|
||||
TS_ASSERT(FilePathFilter(L"folder\\test).h").isMatching(FilePath(L"folder/test).h")));
|
||||
}
|
||||
|
||||
void test_file_path_filter_escapes_open_curly_brace_character()
|
||||
{
|
||||
TS_ASSERT(FilePathFilter(L"folder/test{.h").isMatching(FilePath(L"folder/test{.h")));
|
||||
}
|
||||
|
||||
void test_file_path_filter_escapes_close_curly_brace_character()
|
||||
{
|
||||
TS_ASSERT(FilePathFilter(L"folder/test}.h").isMatching(FilePath(L"folder/test}.h")));
|
||||
}
|
||||
|
||||
void test_file_path_filter_escapes_open_squared_brace_character()
|
||||
{
|
||||
TS_ASSERT(FilePathFilter(L"folder/test[.h").isMatching(FilePath(L"folder/test[.h")));
|
||||
}
|
||||
|
||||
void test_file_path_filter_escapes_close_squared_brace_character()
|
||||
{
|
||||
TS_ASSERT(FilePathFilter(L"folder\\test].h").isMatching(FilePath(L"folder/test].h")));
|
||||
}
|
||||
|
||||
void test_file_path_filter_finds_backslash_if_slash_was_provided()
|
||||
{
|
||||
FilePathFilter filter(L"folder/test.h");
|
||||
|
||||
TS_ASSERT(filter.isMatching(FilePath(L"folder\\test.h")));
|
||||
}
|
||||
|
||||
void test_file_path_filter_finds_slash_if_backslash_was_provided()
|
||||
{
|
||||
FilePathFilter filter(L"folder\\test.h");
|
||||
|
||||
TS_ASSERT(filter.isMatching(FilePath(L"folder/test.h")));
|
||||
}
|
||||
};
|
||||
@@ -248,19 +248,19 @@ private:
|
||||
std::shared_ptr<TextAccess> parseCode(const FilePath& sourceFilePath, const FilePath& projectDataSrcRoot, const std::vector<FilePath>& classpath)
|
||||
{
|
||||
std::set<FilePath> indexedPaths = { projectDataSrcRoot };
|
||||
std::set<FilePath> excludedPaths = { };
|
||||
std::set<FilePathFilter> excludeFilters = { };
|
||||
|
||||
std::shared_ptr<FileRegister> fileRegister = std::make_shared<FileRegister>(
|
||||
FileRegisterStateData(),
|
||||
sourceFilePath,
|
||||
indexedPaths,
|
||||
excludedPaths
|
||||
excludeFilters
|
||||
);
|
||||
|
||||
std::shared_ptr<DumpParserClient> parserClient = std::make_shared<DumpParserClient>();
|
||||
|
||||
JavaParser parser(parserClient, fileRegister);
|
||||
std::shared_ptr<IndexerCommandJava> command = std::make_shared<IndexerCommandJava>(sourceFilePath, indexedPaths, excludedPaths, "8", classpath);
|
||||
std::shared_ptr<IndexerCommandJava> command = std::make_shared<IndexerCommandJava>(sourceFilePath, indexedPaths, excludeFilters, "8", classpath);
|
||||
|
||||
parser.buildIndex(command);
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "TestFileRegister.h"
|
||||
|
||||
#include "utility/file/FilePathFilter.h"
|
||||
|
||||
TestFileRegister::TestFileRegister()
|
||||
: FileRegister(FileRegisterStateData(), FilePath(), std::set<FilePath>(), std::set<FilePath>())
|
||||
: FileRegister(FileRegisterStateData(), FilePath(), std::set<FilePath>(), { FilePathFilter(L"") })
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user