src: Added logic and UI for excluding files and directories from analysis
bug id = 68, 47
This commit is contained in:
+3
-1
@@ -254,9 +254,11 @@ void Project::updateFileManager()
|
||||
sourcePaths = TaskParseCxx::getSourceFilesFromCDB(projSettings->getCompilationDatabasePath());
|
||||
}
|
||||
|
||||
std::vector<FilePath> excludePaths = projSettings->getAbsoluteExcludePaths();
|
||||
|
||||
std::vector<std::string> sourceExtensions = projSettings->getSourceExtensions();
|
||||
|
||||
m_fileManager.setPaths(sourcePaths, headerPaths, sourceExtensions);
|
||||
m_fileManager.setPaths(sourcePaths, headerPaths, excludePaths, sourceExtensions);
|
||||
}
|
||||
|
||||
Parser::Arguments Project::getParserArguments() const
|
||||
|
||||
@@ -44,6 +44,7 @@ bool ProjectSettings::operator==(const ProjectSettings& other) const
|
||||
utility::isPermutation<FilePath>(getSourcePaths(), other.getSourcePaths()) &&
|
||||
utility::isPermutation<FilePath>(getHeaderSearchPaths(), other.getHeaderSearchPaths()) &&
|
||||
utility::isPermutation<FilePath>(getFrameworkSearchPaths(), other.getFrameworkSearchPaths()) &&
|
||||
utility::isPermutation<FilePath>(getExcludePaths(), other.getExcludePaths()) &&
|
||||
utility::isPermutation<std::string>(getCompilerFlags(), other.getCompilerFlags()) &&
|
||||
utility::isPermutation<std::string>(getSourceExtensions(), other.getSourceExtensions());
|
||||
}
|
||||
@@ -171,6 +172,24 @@ bool ProjectSettings::setUseSourcePathsForHeaderSearch(bool useSourcePathsForHea
|
||||
return setValue<bool>("source/use_source_paths_for_header_search", useSourcePathsForHeaderSearch);
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getExcludePaths() const
|
||||
{
|
||||
return getPathValues("source/exclude_paths/exclude_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> ProjectSettings::getAbsoluteExcludePaths() const
|
||||
{
|
||||
std::vector<FilePath> paths = getExcludePaths();
|
||||
expandPaths(paths);
|
||||
makePathsAbsolute(paths);
|
||||
return paths;
|
||||
}
|
||||
|
||||
bool ProjectSettings::setExcludePaths(const std::vector<FilePath>& excludePaths)
|
||||
{
|
||||
return setPathValues("source/exclude_paths/exclude_path", excludePaths);
|
||||
}
|
||||
|
||||
FilePath ProjectSettings::getVisualStudioSolutionPath() const
|
||||
{
|
||||
return FilePath(getValue<std::string>("source/build_file_path/vs_solution_path", ""));
|
||||
|
||||
@@ -44,16 +44,17 @@ public:
|
||||
std::vector<std::string> getCompilerFlags() const;
|
||||
bool setCompilerFlags(const std::vector<std::string>& compilerFlags);
|
||||
|
||||
std::vector<std::string> getHeaderExtensions() const;
|
||||
std::vector<std::string> getSourceExtensions() const;
|
||||
|
||||
bool setHeaderExtensions(const std::vector<std::string>& headerExtensions);
|
||||
bool setSourceExtensions(const std::vector<std::string>& sourceExtensions);
|
||||
|
||||
bool isUseSourcePathsForHeaderSearchDefined() const;
|
||||
bool getUseSourcePathsForHeaderSearch() const;
|
||||
bool setUseSourcePathsForHeaderSearch(bool useSourcePathsForHeaderSearch);
|
||||
|
||||
std::vector<FilePath> getExcludePaths() const;
|
||||
std::vector<FilePath> getAbsoluteExcludePaths() const;
|
||||
bool setExcludePaths(const std::vector<FilePath>& excludePaths);
|
||||
|
||||
FilePath getVisualStudioSolutionPath() const;
|
||||
bool setVisualStudioSolutionPath(const FilePath& visualStudioSolutionPath);
|
||||
|
||||
|
||||
@@ -23,10 +23,12 @@ const std::vector<FilePath>& FileManager::getSourcePaths() const
|
||||
void FileManager::setPaths(
|
||||
std::vector<FilePath> sourcePaths,
|
||||
std::vector<FilePath> headerPaths,
|
||||
std::vector<FilePath> excludePaths,
|
||||
std::vector<std::string> sourceExtensions
|
||||
){
|
||||
m_sourcePaths = sourcePaths;
|
||||
m_headerPaths = headerPaths;
|
||||
m_excludePaths = excludePaths;
|
||||
m_sourceExtensions = sourceExtensions;
|
||||
}
|
||||
|
||||
@@ -65,6 +67,11 @@ void FileManager::fetchFilePaths(const std::vector<FileInfo>& oldFileInfos)
|
||||
for (FileInfo fileInfo: fileInfos)
|
||||
{
|
||||
const FilePath& filePath = fileInfo.path;
|
||||
if (isExcluded(filePath))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
std::map<FilePath, FileInfo>::iterator it = m_files.find(filePath);
|
||||
if (it != m_files.end())
|
||||
{
|
||||
@@ -110,6 +117,11 @@ bool FileManager::hasFilePath(const FilePath& filePath) const
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isExcluded(filePath))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (FilePath path : m_headerPaths)
|
||||
{
|
||||
if (path == filePath || path.contains(filePath))
|
||||
@@ -137,3 +149,16 @@ const FileInfo FileManager::getFileInfo(const FilePath& filePath) const
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
bool FileManager::isExcluded(const FilePath& filePath) const
|
||||
{
|
||||
for (FilePath path : m_excludePaths)
|
||||
{
|
||||
if (path == filePath || path.contains(filePath))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
void setPaths(
|
||||
std::vector<FilePath> sourcePaths,
|
||||
std::vector<FilePath> headerPaths,
|
||||
std::vector<FilePath> excludePaths,
|
||||
std::vector<std::string> sourceExtensions
|
||||
);
|
||||
|
||||
@@ -33,13 +34,15 @@ public:
|
||||
virtual const FileInfo getFileInfo(const FilePath& filePath) const;
|
||||
|
||||
private:
|
||||
bool isExcluded(const FilePath& filePath) const;
|
||||
|
||||
std::map<FilePath, FileInfo> m_files;
|
||||
|
||||
std::vector<FilePath> m_sourcePaths;
|
||||
std::vector<FilePath> m_headerPaths;
|
||||
std::vector<FilePath> m_excludePaths;
|
||||
|
||||
std::vector<std::string> m_sourceExtensions;
|
||||
std::vector<std::string> m_includeExtensions;
|
||||
|
||||
std::set<FilePath> m_addedFiles;
|
||||
std::set<FilePath> m_updatedFiles;
|
||||
|
||||
Reference in New Issue
Block a user