logic: Changed include files being analyzed solely by path
* removed header extensions * added source extensions to source path setup screen * added caching to hasFilePath check * don't show header list in CDB setup * removed TestSettings.xml
This commit is contained in:
@@ -35,7 +35,6 @@
|
||||
</framework_search_paths>
|
||||
|
||||
<extensions>
|
||||
<header_extensions><!-- STRING: extension for header/include e.g. .h --></header_extensions>
|
||||
<source_extensions><!-- STRING: extension for source e.g. .cpp --></source_extensions>
|
||||
</extensions>
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- INTEGER: int e.g 123 -->
|
||||
<!-- DECIMAL: float e.g 123.456 -->
|
||||
<!-- STRING: string e.g hello -->
|
||||
<!-- COLOR: int int int int - rgba e.g. 125 125 125 255 -->
|
||||
|
||||
<config>
|
||||
<source>
|
||||
<HeaderSearchPaths>
|
||||
<HeaderSearchPath><!-- STRING: header search path for each path a HeaderSearchPaht element--></HeaderSearchPath>
|
||||
</HeaderSearchPaths>
|
||||
</source>
|
||||
</config>
|
||||
@@ -1,174 +1,3 @@
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
|
||||
Token.cpp ERROR: Location Id was not referenced by this Token.
|
||||
Node.cpp WARNING: Cannot change NodeType after it was already set from namespace to class
|
||||
Edge.cpp ERROR: Nodes are not plain copies.
|
||||
|
||||
+2
-4
@@ -247,18 +247,16 @@ void Project::updateFileManager()
|
||||
std::shared_ptr<ProjectSettings> projSettings = ProjectSettings::getInstance();
|
||||
|
||||
std::vector<FilePath> sourcePaths = projSettings->getAbsoluteSourcePaths();
|
||||
std::vector<FilePath> headerPaths;
|
||||
std::vector<FilePath> headerPaths = sourcePaths;
|
||||
|
||||
if (projSettings->getCompilationDatabasePath().exists())
|
||||
{
|
||||
headerPaths = sourcePaths;
|
||||
sourcePaths = TaskParseCxx::getSourceFilesFromCDB(projSettings->getCompilationDatabasePath());
|
||||
}
|
||||
|
||||
std::vector<std::string> sourceExtensions = projSettings->getSourceExtensions();
|
||||
std::vector<std::string> includeExtensions = projSettings->getHeaderExtensions();
|
||||
|
||||
m_fileManager.setPaths(sourcePaths, headerPaths, sourceExtensions, includeExtensions);
|
||||
m_fileManager.setPaths(sourcePaths, headerPaths, sourceExtensions);
|
||||
}
|
||||
|
||||
Parser::Arguments Project::getParserArguments() const
|
||||
|
||||
@@ -2,14 +2,6 @@
|
||||
|
||||
#include "utility/utility.h"
|
||||
|
||||
std::vector<std::string> ProjectSettings::getDefaultHeaderExtensions()
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
defaultValues.push_back(".h");
|
||||
defaultValues.push_back(".hpp");
|
||||
return defaultValues;
|
||||
}
|
||||
|
||||
std::vector<std::string> ProjectSettings::getDefaultSourceExtensions()
|
||||
{
|
||||
std::vector<std::string> defaultValues;
|
||||
@@ -53,7 +45,6 @@ bool ProjectSettings::operator==(const ProjectSettings& other) const
|
||||
utility::isPermutation<FilePath>(getHeaderSearchPaths(), other.getHeaderSearchPaths()) &&
|
||||
utility::isPermutation<FilePath>(getFrameworkSearchPaths(), other.getFrameworkSearchPaths()) &&
|
||||
utility::isPermutation<std::string>(getCompilerFlags(), other.getCompilerFlags()) &&
|
||||
utility::isPermutation<std::string>(getHeaderExtensions(), other.getHeaderExtensions()) &&
|
||||
utility::isPermutation<std::string>(getSourceExtensions(), other.getSourceExtensions());
|
||||
}
|
||||
|
||||
@@ -155,21 +146,11 @@ bool ProjectSettings::setCompilerFlags(const std::vector<std::string>& compilerF
|
||||
return setValues("source/compiler_flags/compiler_flag", compilerFlags);
|
||||
}
|
||||
|
||||
std::vector<std::string> ProjectSettings::getHeaderExtensions() const
|
||||
{
|
||||
return getValues("source/extensions/header_extensions", getDefaultHeaderExtensions());
|
||||
}
|
||||
|
||||
std::vector<std::string> ProjectSettings::getSourceExtensions() const
|
||||
{
|
||||
return getValues("source/extensions/source_extensions", getDefaultSourceExtensions());
|
||||
}
|
||||
|
||||
bool ProjectSettings::setHeaderExtensions(const std::vector<std::string> &headerExtensions)
|
||||
{
|
||||
return setValues("source/extensions/header_extensions", headerExtensions);
|
||||
}
|
||||
|
||||
bool ProjectSettings::setSourceExtensions(const std::vector<std::string> &sourceExtensions)
|
||||
{
|
||||
return setValues("source/extensions/source_extensions", sourceExtensions);
|
||||
|
||||
@@ -10,7 +10,6 @@ class ProjectSettings
|
||||
: public Settings
|
||||
{
|
||||
public:
|
||||
static std::vector<std::string> getDefaultHeaderExtensions();
|
||||
static std::vector<std::string> getDefaultSourceExtensions();
|
||||
|
||||
static std::shared_ptr<ProjectSettings> getInstance();
|
||||
|
||||
@@ -23,13 +23,11 @@ const std::vector<FilePath>& FileManager::getSourcePaths() const
|
||||
void FileManager::setPaths(
|
||||
std::vector<FilePath> sourcePaths,
|
||||
std::vector<FilePath> headerPaths,
|
||||
std::vector<std::string> sourceExtensions,
|
||||
std::vector<std::string> includeExtensions
|
||||
std::vector<std::string> sourceExtensions
|
||||
){
|
||||
m_sourcePaths = sourcePaths;
|
||||
m_headerPaths = headerPaths;
|
||||
m_sourceExtensions = sourceExtensions;
|
||||
m_includeExtensions = includeExtensions;
|
||||
}
|
||||
|
||||
void FileManager::fetchFilePaths(const std::vector<FileInfo>& oldFileInfos)
|
||||
@@ -46,10 +44,24 @@ void FileManager::fetchFilePaths(const std::vector<FileInfo>& oldFileInfos)
|
||||
|
||||
for (std::map<FilePath, FileInfo>::iterator it = m_files.begin(); it != m_files.end(); it++)
|
||||
{
|
||||
m_removedFiles.insert(it->first);
|
||||
const FilePath& filePath = it->first;
|
||||
if (filePath.exists() && !hasSourceExtension(filePath))
|
||||
{
|
||||
FileInfo fileInfo = FileSystem::getFileInfoForPath(filePath);
|
||||
|
||||
if (fileInfo.lastWriteTime > it->second.lastWriteTime)
|
||||
{
|
||||
it->second.lastWriteTime = fileInfo.lastWriteTime;
|
||||
m_updatedFiles.insert(filePath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_removedFiles.insert(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<FileInfo> fileInfos = getFileInfosInProject();
|
||||
std::vector<FileInfo> fileInfos = FileSystem::getFileInfosFromPaths(m_sourcePaths, m_sourceExtensions);
|
||||
for (FileInfo fileInfo: fileInfos)
|
||||
{
|
||||
const FilePath& filePath = fileInfo.path;
|
||||
@@ -60,7 +72,7 @@ void FileManager::fetchFilePaths(const std::vector<FileInfo>& oldFileInfos)
|
||||
if (fileInfo.lastWriteTime > it->second.lastWriteTime)
|
||||
{
|
||||
it->second.lastWriteTime = fileInfo.lastWriteTime;
|
||||
m_updatedFiles.insert(fileInfo.path);
|
||||
m_updatedFiles.insert(filePath);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -93,7 +105,20 @@ std::set<FilePath> FileManager::getRemovedFilePaths() const
|
||||
|
||||
bool FileManager::hasFilePath(const FilePath& filePath) const
|
||||
{
|
||||
return (m_files.find(filePath) != m_files.end());
|
||||
if (m_files.find(filePath) != m_files.end())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
for (FilePath path : m_headerPaths)
|
||||
{
|
||||
if (path == filePath || path.contains(filePath))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FileManager::hasSourceExtension(const FilePath& filePath) const
|
||||
@@ -101,39 +126,14 @@ bool FileManager::hasSourceExtension(const FilePath& filePath) const
|
||||
return filePath.hasExtension(m_sourceExtensions);
|
||||
}
|
||||
|
||||
bool FileManager::hasIncludeExtension(const FilePath& filePath) const
|
||||
{
|
||||
return filePath.hasExtension(m_includeExtensions);
|
||||
}
|
||||
|
||||
const FileInfo FileManager::getFileInfo(const FilePath& filePath) const
|
||||
{
|
||||
std::map<FilePath, FileInfo>::const_iterator it = m_files.find(filePath);
|
||||
|
||||
if (it == m_files.end())
|
||||
{
|
||||
LOG_ERROR("No FileInfo found for file: " + filePath.str());
|
||||
return FileSystem::getFileInfoForPath(filePath);
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
std::vector<FileInfo> FileManager::getFileInfosInProject() const
|
||||
{
|
||||
std::vector<FileInfo> fileInfos;
|
||||
|
||||
std::vector<std::pair<std::vector<FilePath>, std::vector<std::string>>> pathsExtensionsPairs;
|
||||
pathsExtensionsPairs.push_back(std::make_pair(m_sourcePaths, m_includeExtensions));
|
||||
pathsExtensionsPairs.push_back(std::make_pair(m_sourcePaths, m_sourceExtensions));
|
||||
pathsExtensionsPairs.push_back(std::make_pair(m_headerPaths, m_includeExtensions));
|
||||
|
||||
for (size_t i = 0; i < pathsExtensionsPairs.size(); i++)
|
||||
{
|
||||
utility::append(
|
||||
fileInfos,
|
||||
FileSystem::getFileInfosFromPaths(pathsExtensionsPairs[i].first, pathsExtensionsPairs[i].second)
|
||||
);
|
||||
}
|
||||
|
||||
return fileInfos;
|
||||
}
|
||||
|
||||
@@ -18,11 +18,9 @@ public:
|
||||
void setPaths(
|
||||
std::vector<FilePath> sourcePaths,
|
||||
std::vector<FilePath> headerPaths,
|
||||
std::vector<std::string> sourceExtensions,
|
||||
std::vector<std::string> includeExtensions
|
||||
std::vector<std::string> sourceExtensions
|
||||
);
|
||||
|
||||
void clear();
|
||||
void fetchFilePaths(const std::vector<FileInfo>& oldFileInfos);
|
||||
|
||||
std::set<FilePath> getAddedFilePaths() const;
|
||||
@@ -31,13 +29,10 @@ public:
|
||||
|
||||
virtual bool hasFilePath(const FilePath& filePath) const;
|
||||
virtual bool hasSourceExtension(const FilePath& filePath) const;
|
||||
virtual bool hasIncludeExtension(const FilePath& filePath) const;
|
||||
|
||||
virtual const FileInfo getFileInfo(const FilePath& filePath) const;
|
||||
|
||||
private:
|
||||
std::vector<FileInfo> getFileInfosInProject() const;
|
||||
|
||||
std::map<FilePath, FileInfo> m_files;
|
||||
|
||||
std::vector<FilePath> m_sourcePaths;
|
||||
|
||||
@@ -174,6 +174,27 @@ FilePath FilePath::concat(const FilePath& other) const
|
||||
return boost::filesystem::path(m_path) / other.m_path;
|
||||
}
|
||||
|
||||
bool FilePath::contains(const FilePath& other) const
|
||||
{
|
||||
if (!isDirectory())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
boost::filesystem::path dir = m_path;
|
||||
boost::filesystem::path dir2 = other.m_path;
|
||||
|
||||
auto dir_len = std::distance(dir.begin(), dir.end());
|
||||
auto dir2_len = std::distance(dir2.begin(), dir2.end());
|
||||
|
||||
if (dir_len > dir2_len)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return std::equal(dir.begin(), dir.end(), dir2.begin());
|
||||
}
|
||||
|
||||
std::string FilePath::str() const
|
||||
{
|
||||
return m_path.generic_string();
|
||||
|
||||
@@ -28,6 +28,8 @@ public:
|
||||
FilePath concat(const FilePath& other) const;
|
||||
FilePath expandEnvironmentVariables() const;
|
||||
|
||||
bool contains(const FilePath& other) const;
|
||||
|
||||
std::string str() const;
|
||||
std::string fileName() const;
|
||||
|
||||
|
||||
@@ -10,30 +10,60 @@ FileRegister::FileRegister(const FileManager* fileManager)
|
||||
|
||||
void FileRegister::setFilePaths(const std::vector<FilePath>& filePaths)
|
||||
{
|
||||
std::lock_guard<std::mutex> sourceFileLock(m_sourceFileMutex);
|
||||
std::lock_guard<std::mutex> includeFileLock(m_includeFileMutex);
|
||||
|
||||
m_sourceFilePaths.clear();
|
||||
m_includeFilePaths.clear();
|
||||
|
||||
for (const FilePath& p : filePaths)
|
||||
{
|
||||
FilePath path = p.exists() ? p.absolute() : p;
|
||||
std::lock_guard<std::mutex> lock(m_sourceFileMutex);
|
||||
m_sourceFilePaths.clear();
|
||||
|
||||
if (m_fileManager->hasSourceExtension(path))
|
||||
for (const FilePath& p : filePaths)
|
||||
{
|
||||
m_sourceFilePaths.emplace(path, STATE_UNPARSED);
|
||||
}
|
||||
else if (m_fileManager->hasIncludeExtension(path))
|
||||
{
|
||||
m_includeFilePaths.emplace(path, STATE_UNPARSED);
|
||||
FilePath path = p.exists() ? p.absolute() : p;
|
||||
|
||||
if (m_fileManager->hasSourceExtension(path))
|
||||
{
|
||||
m_sourceFilePaths.emplace(path, STATE_UNPARSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_includeFileMutex);
|
||||
m_includeFilePaths.clear();
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_threadFileMutex);
|
||||
m_threadParsingFiles.clear();
|
||||
}
|
||||
}
|
||||
|
||||
const FileManager* FileRegister::getFileManager() const
|
||||
bool FileRegister::hasFilePath(const FilePath& filePath) const
|
||||
{
|
||||
return m_fileManager;
|
||||
std::lock_guard<std::mutex> lock(m_projectFilesMutex);
|
||||
std::unordered_map<std::string, bool>::iterator it = m_projectFiles.find(filePath.str());
|
||||
if (it != m_projectFiles.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
|
||||
bool has = m_fileManager->hasFilePath(filePath);
|
||||
m_projectFiles.emplace(filePath.str(), has);
|
||||
|
||||
return has;
|
||||
}
|
||||
|
||||
const FileInfo FileRegister::getFileInfo(const FilePath& filePath) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_projectFileInfosMutex);
|
||||
std::unordered_map<std::string, FileInfo>::iterator it = m_projectFileInfos.find(filePath.str());
|
||||
if (it != m_projectFileInfos.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
|
||||
FileInfo info = m_fileManager->getFileInfo(filePath);
|
||||
m_projectFileInfos.emplace(filePath.str(), info);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
std::vector<FilePath> FileRegister::getUnparsedSourceFilePaths() const
|
||||
@@ -140,30 +170,55 @@ bool FileRegister::includeFileIsParsed(const FilePath& filePath) const
|
||||
|
||||
FilePath FileRegister::consumeSourceFile()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_sourceFileMutex);
|
||||
for (std::map<FilePath, ParseState>::iterator it = m_sourceFilePaths.begin(); it != m_sourceFilePaths.end(); it++)
|
||||
FilePath path;
|
||||
{
|
||||
if (it->second == STATE_UNPARSED)
|
||||
std::lock_guard<std::mutex> lock(m_sourceFileMutex);
|
||||
for (std::map<FilePath, ParseState>::iterator it = m_sourceFilePaths.begin(); it != m_sourceFilePaths.end(); it++)
|
||||
{
|
||||
it->second = STATE_PARSING;
|
||||
m_threadParsingFiles[std::this_thread::get_id()].insert(it->first);
|
||||
return it->first;
|
||||
if (it->second == STATE_UNPARSED)
|
||||
{
|
||||
it->second = STATE_PARSING;
|
||||
path = it->first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FilePath();
|
||||
|
||||
if (!path.empty())
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_threadFileMutex);
|
||||
m_threadParsingFiles[std::this_thread::get_id()].insert(path);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
void FileRegister::markIncludeFileParsing(const FilePath& filePath)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_includeFileMutex);
|
||||
std::map<FilePath, ParseState>::iterator it = m_includeFilePaths.find(filePath);
|
||||
if (it != m_includeFilePaths.end())
|
||||
bool unparsed = false;
|
||||
{
|
||||
if (it->second == STATE_UNPARSED)
|
||||
std::lock_guard<std::mutex> lock(m_includeFileMutex);
|
||||
std::map<FilePath, ParseState>::iterator it = m_includeFilePaths.find(filePath);
|
||||
|
||||
if (it != m_includeFilePaths.end())
|
||||
{
|
||||
it->second = STATE_PARSING;
|
||||
m_threadParsingFiles[std::this_thread::get_id()].insert(it->first);
|
||||
if (it->second == STATE_UNPARSED)
|
||||
{
|
||||
it->second = STATE_PARSING;
|
||||
unparsed = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_includeFilePaths.emplace(filePath, STATE_PARSING);
|
||||
unparsed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (unparsed)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_threadFileMutex);
|
||||
m_threadParsingFiles[std::this_thread::get_id()].insert(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +227,10 @@ void FileRegister::markThreadFilesParsed()
|
||||
std::lock_guard<std::mutex> sourceFileLock(m_sourceFileMutex);
|
||||
std::lock_guard<std::mutex> includeFileLock(m_includeFileMutex);
|
||||
std::lock_guard<std::mutex> threadFileLock(m_threadFileMutex);
|
||||
for (std::set<FilePath>::iterator it = m_threadParsingFiles[std::this_thread::get_id()].begin(); it != m_threadParsingFiles[std::this_thread::get_id()].end(); it++)
|
||||
|
||||
std::set<FilePath>& threadFiles = m_threadParsingFiles[std::this_thread::get_id()];
|
||||
|
||||
for (std::set<FilePath>::iterator it = threadFiles.begin(); it != threadFiles.end(); it++)
|
||||
{
|
||||
std::map<FilePath, ParseState>::iterator it2;
|
||||
it2 = m_sourceFilePaths.find(*it);
|
||||
@@ -188,7 +246,8 @@ void FileRegister::markThreadFilesParsed()
|
||||
it2->second = STATE_PARSED;
|
||||
}
|
||||
}
|
||||
m_threadParsingFiles[std::this_thread::get_id()].clear();
|
||||
|
||||
threadFiles.clear();
|
||||
}
|
||||
|
||||
size_t FileRegister::getSourceFilesCount() const
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define FILE_REGISTER_H
|
||||
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <string>
|
||||
@@ -12,6 +13,8 @@
|
||||
|
||||
class FileManager;
|
||||
|
||||
struct FileInfo;
|
||||
|
||||
class FileRegister
|
||||
{
|
||||
public:
|
||||
@@ -19,7 +22,8 @@ public:
|
||||
|
||||
void setFilePaths(const std::vector<FilePath>& filePaths);
|
||||
|
||||
const FileManager* getFileManager() const;
|
||||
bool hasFilePath(const FilePath& filePath) const;
|
||||
const FileInfo getFileInfo(const FilePath& filePath) const;
|
||||
|
||||
std::vector<FilePath> getUnparsedSourceFilePaths() const;
|
||||
|
||||
@@ -47,6 +51,12 @@ private:
|
||||
|
||||
const FileManager* m_fileManager;
|
||||
|
||||
mutable std::unordered_map<std::string, bool> m_projectFiles;
|
||||
mutable std::mutex m_projectFilesMutex;
|
||||
|
||||
mutable std::unordered_map<std::string, FileInfo> m_projectFileInfos;
|
||||
mutable std::mutex m_projectFileInfosMutex;
|
||||
|
||||
std::map<FilePath, ParseState> m_sourceFilePaths;
|
||||
std::map<FilePath, ParseState> m_includeFilePaths;
|
||||
|
||||
@@ -55,6 +65,7 @@ private:
|
||||
mutable std::mutex m_sourceFileMutex;
|
||||
mutable std::mutex m_includeFileMutex;
|
||||
mutable std::mutex m_threadFileMutex;
|
||||
mutable std::mutex m_fileManagerMutex;
|
||||
};
|
||||
|
||||
#endif // FILE_REGISTER_H
|
||||
|
||||
@@ -397,9 +397,22 @@ void QtProjectWizzard::emptyProject()
|
||||
|
||||
void QtProjectWizzard::sourcePaths()
|
||||
{
|
||||
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentPathsSource>();
|
||||
QtProjectWizzardWindow* window = createWindowWithSummary(
|
||||
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
|
||||
{
|
||||
ProjectSettings* settings = &m_settings;
|
||||
|
||||
QtProjectWizzardContent* source = new QtProjectWizzardContentPathsSource(settings, window);
|
||||
summary->addContent(source, false, false);
|
||||
connectShowFiles(source);
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentExtensions(settings, window), false, false);
|
||||
|
||||
window->setup();
|
||||
}
|
||||
);
|
||||
|
||||
connect(window, SIGNAL(next()), this, SLOT(headerSearchPaths()));
|
||||
connectShowFiles(window->content());
|
||||
}
|
||||
|
||||
void QtProjectWizzard::headerSearchPaths()
|
||||
@@ -462,7 +475,6 @@ void QtProjectWizzard::headerPathsCDB()
|
||||
|
||||
QtProjectWizzardContent* header = new QtProjectWizzardContentPathsCDBHeader(settings, window);
|
||||
summary->addContent(header, false, false);
|
||||
connectShowFiles(header);
|
||||
|
||||
window->setup();
|
||||
|
||||
|
||||
@@ -11,18 +11,29 @@ QtProjectWizzardContentExtensions::QtProjectWizzardContentExtensions(
|
||||
{
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentExtensions::populateWindow(QGridLayout* layout, int& row)
|
||||
{
|
||||
layout->setRowMinimumHeight(row++, 20);
|
||||
|
||||
QLabel* title = new QLabel("Source File Extensions");
|
||||
title->setWordWrap(true);
|
||||
title->setObjectName("section");
|
||||
layout->addWidget(title, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop);
|
||||
layout->setRowStretch(row, 0);
|
||||
|
||||
QLabel* text = new QLabel("Define extensions for source files including the dot e.g. .cpp");
|
||||
text->setWordWrap(true);
|
||||
text->setOpenExternalLinks(true);
|
||||
layout->addWidget(text, row + 1, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop);
|
||||
layout->setRowStretch(row + 1, 1);
|
||||
|
||||
m_sourceList = new QtDirectoryListBox(this);
|
||||
layout->addWidget(m_sourceList, row, QtProjectWizzardWindow::BACK_COL, 2, 1, Qt::AlignTop);
|
||||
row += 2;
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentExtensions::populateForm(QGridLayout* layout, int& row)
|
||||
{
|
||||
QLabel* headerLabel = createFormLabel("Header File Extensions");
|
||||
headerLabel->setObjectName("label");
|
||||
layout->addWidget(headerLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||
|
||||
addHelpButton("Define extensions for header files including the dot e.g. .h", layout, row);
|
||||
|
||||
m_headerList = new QtDirectoryListBox(this, true);
|
||||
layout->addWidget(m_headerList, row, QtProjectWizzardWindow::BACK_COL);
|
||||
row++;
|
||||
|
||||
QLabel* sourceLabel = createFormLabel("Source File Extensions");
|
||||
sourceLabel->setObjectName("label");
|
||||
layout->addWidget(sourceLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||
@@ -36,12 +47,10 @@ void QtProjectWizzardContentExtensions::populateForm(QGridLayout* layout, int& r
|
||||
|
||||
void QtProjectWizzardContentExtensions::load()
|
||||
{
|
||||
m_headerList->setStringList(m_settings->getHeaderExtensions());
|
||||
m_sourceList->setStringList(m_settings->getSourceExtensions());
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentExtensions::save()
|
||||
{
|
||||
m_settings->setHeaderExtensions(m_headerList->getStringList());
|
||||
m_settings->setSourceExtensions(m_sourceList->getStringList());
|
||||
}
|
||||
|
||||
@@ -14,13 +14,13 @@ public:
|
||||
QtProjectWizzardContentExtensions(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void populateWindow(QGridLayout* layout, int& row) override;
|
||||
virtual void populateForm(QGridLayout* layout, int& row) override;
|
||||
|
||||
virtual void load() override;
|
||||
virtual void save() override;
|
||||
|
||||
private:
|
||||
QtDirectoryListBox* m_headerList;
|
||||
QtDirectoryListBox* m_sourceList;
|
||||
};
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ void QtProjectWizzardContentPaths::populateWindow(QGridLayout* layout, int& row)
|
||||
|
||||
if (m_showFilesString.size() > 0)
|
||||
{
|
||||
layout->setRowStretch(row, 10);
|
||||
layout->setRowStretch(row, 0);
|
||||
addFilesButton(m_showFilesString, layout, row);
|
||||
}
|
||||
|
||||
@@ -242,30 +242,10 @@ bool QtProjectWizzardContentPathsSource::check()
|
||||
}
|
||||
|
||||
QStringList QtProjectWizzardContentPathsSource::getFileNames() const
|
||||
{
|
||||
return getSourceFileNames(false);
|
||||
}
|
||||
|
||||
QString QtProjectWizzardContentPathsSource::getFileNamesTitle() const
|
||||
{
|
||||
return "Analyzed Files";
|
||||
}
|
||||
|
||||
QString QtProjectWizzardContentPathsSource::getFileNamesDescription() const
|
||||
{
|
||||
return "files will be analyzed.";
|
||||
}
|
||||
|
||||
QStringList QtProjectWizzardContentPathsSource::getSourceFileNames(bool headersOnly) const
|
||||
{
|
||||
std::vector<FilePath> sourcePaths = m_settings->getAbsoluteSourcePaths();
|
||||
|
||||
std::vector<std::string> extensions;
|
||||
if (!headersOnly)
|
||||
{
|
||||
utility::append(extensions, m_settings->getSourceExtensions());
|
||||
}
|
||||
utility::append(extensions, m_settings->getHeaderExtensions());
|
||||
std::vector<std::string> extensions = m_settings->getSourceExtensions();
|
||||
|
||||
std::vector<FileInfo> fileInfos = FileSystem::getFileInfosFromPaths(sourcePaths, extensions);
|
||||
FilePath projectPath = m_settings->getProjectFileLocation();
|
||||
@@ -286,17 +266,27 @@ QStringList QtProjectWizzardContentPathsSource::getSourceFileNames(bool headersO
|
||||
return list;
|
||||
}
|
||||
|
||||
QString QtProjectWizzardContentPathsSource::getFileNamesTitle() const
|
||||
{
|
||||
return "Analyzed Files";
|
||||
}
|
||||
|
||||
QString QtProjectWizzardContentPathsSource::getFileNamesDescription() const
|
||||
{
|
||||
return "files will be analyzed.";
|
||||
}
|
||||
|
||||
QtProjectWizzardContentPathsCDBHeader::QtProjectWizzardContentPathsCDBHeader(
|
||||
ProjectSettings* settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContentPathsSource(settings, window)
|
||||
{
|
||||
m_showFilesString = "show header files";
|
||||
m_showFilesString = "";
|
||||
|
||||
setTitleString("Header Paths");
|
||||
setDescriptionString(
|
||||
"Add the header files or directories containing the header files of the source files above. These header files "
|
||||
"will be analyzed if included."
|
||||
"or files within these directories will be analyzed if included."
|
||||
);
|
||||
setHelpString(
|
||||
"The compilation database only contains source files. Add the header files or directories containing the header "
|
||||
@@ -304,21 +294,6 @@ QtProjectWizzardContentPathsCDBHeader::QtProjectWizzardContentPathsCDBHeader(
|
||||
);
|
||||
}
|
||||
|
||||
QStringList QtProjectWizzardContentPathsCDBHeader::getFileNames() const
|
||||
{
|
||||
return getSourceFileNames(true);
|
||||
}
|
||||
|
||||
QString QtProjectWizzardContentPathsCDBHeader::getFileNamesTitle() const
|
||||
{
|
||||
return "Header Files";
|
||||
}
|
||||
|
||||
QString QtProjectWizzardContentPathsCDBHeader::getFileNamesDescription() const
|
||||
{
|
||||
return "header files found.";
|
||||
}
|
||||
|
||||
QtProjectWizzardContentPathsHeaderSearch::QtProjectWizzardContentPathsHeaderSearch(
|
||||
ProjectSettings* settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
|
||||
@@ -69,9 +69,6 @@ public:
|
||||
virtual QStringList getFileNames() const override;
|
||||
virtual QString getFileNamesTitle() const override;
|
||||
virtual QString getFileNamesDescription() const override;
|
||||
|
||||
protected:
|
||||
QStringList getSourceFileNames(bool headersOnly) const;
|
||||
};
|
||||
|
||||
class QtProjectWizzardContentPathsCDBHeader
|
||||
@@ -79,11 +76,6 @@ class QtProjectWizzardContentPathsCDBHeader
|
||||
{
|
||||
public:
|
||||
QtProjectWizzardContentPathsCDBHeader(ProjectSettings* settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual QStringList getFileNames() const override;
|
||||
virtual QString getFileNamesTitle() const override;
|
||||
virtual QString getFileNamesDescription() const override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "data/parser/cxx/utilityCxx.h"
|
||||
#include "data/parser/ParseLocation.h"
|
||||
|
||||
#include "utility/file/FileManager.h"
|
||||
#include "utility/ScopedSwitcher.h"
|
||||
|
||||
// TODO: For an array access, X[I], skip over the array-to-pointer decay. We
|
||||
@@ -1534,9 +1533,9 @@ bool ASTVisitor::isLocatedInProjectFile(clang::SourceLocation loc)
|
||||
{
|
||||
fileId = sourceManager.getFileID(spellingLoc);
|
||||
}
|
||||
|
||||
if (!fileId.isInvalid())
|
||||
{
|
||||
|
||||
auto it = m_inProjectFileMap.find(fileId);
|
||||
if (it != m_inProjectFileMap.end())
|
||||
{
|
||||
@@ -1548,11 +1547,12 @@ bool ASTVisitor::isLocatedInProjectFile(clang::SourceLocation loc)
|
||||
{
|
||||
std::string fileName = fileEntry->getName();
|
||||
FilePath filePath = FilePath(fileName).canonical();
|
||||
bool ret = m_fileRegister->getFileManager()->hasFilePath(filePath.str());
|
||||
bool ret = m_fileRegister->hasFilePath(filePath.str());
|
||||
m_inProjectFileMap[fileId] = ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include "data/parser/ParseLocation.h"
|
||||
#include "data/parser/ParserClient.h"
|
||||
#include "utility/file/FileManager.h"
|
||||
#include "utility/file/FileRegister.h"
|
||||
|
||||
CommentHandler::CommentHandler(ParserClient* client, FileRegister* fileRegister)
|
||||
@@ -22,7 +21,7 @@ bool CommentHandler::HandleComment(clang::Preprocessor& preprocessor, clang::Sou
|
||||
const clang::PresumedLoc& presumedEnd = sourceManager.getPresumedLoc(sourceRange.getEnd(), false);
|
||||
|
||||
FilePath filePath = FilePath(presumedBegin.getFilename());
|
||||
if (m_fileRegister->getFileManager()->hasFilePath(filePath) && !m_fileRegister->fileIsParsed(filePath))
|
||||
if (m_fileRegister->hasFilePath(filePath) && !m_fileRegister->fileIsParsed(filePath))
|
||||
{
|
||||
m_client->onCommentParsed(ParseLocation(
|
||||
presumedBegin.getFilename(),
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
#include "clang/Basic/SourceManager.h"
|
||||
|
||||
#include "utility/file/FileManager.h"
|
||||
|
||||
#include "data/parser/ParseLocation.h"
|
||||
#include "data/parser/ParserClient.h"
|
||||
|
||||
@@ -11,12 +9,10 @@ CxxDiagnosticConsumer::CxxDiagnosticConsumer(
|
||||
clang::raw_ostream &os,
|
||||
clang::DiagnosticOptions *diags,
|
||||
ParserClient* client,
|
||||
const FileManager* fileManager,
|
||||
bool useLogging
|
||||
)
|
||||
: clang::TextDiagnosticPrinter(os, diags)
|
||||
, m_client(client)
|
||||
, m_fileManager(fileManager)
|
||||
, m_isParsingFile(false)
|
||||
, m_useLogging(useLogging)
|
||||
{
|
||||
@@ -79,10 +75,6 @@ void CxxDiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level lev
|
||||
column = presumedLocation.getColumn();
|
||||
}
|
||||
|
||||
// if (m_fileManager->hasFilePath(filePath))
|
||||
if (m_fileManager)
|
||||
{
|
||||
m_client->onError(ParseLocation(filePath, line, column), message, (level == clang::DiagnosticsEngine::Fatal));
|
||||
}
|
||||
m_client->onError(ParseLocation(filePath, line, column), message, (level == clang::DiagnosticsEngine::Fatal));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "clang/Frontend/TextDiagnosticPrinter.h"
|
||||
|
||||
class FileManager;
|
||||
class ParserClient;
|
||||
|
||||
class CxxDiagnosticConsumer
|
||||
@@ -14,7 +13,6 @@ public:
|
||||
clang::raw_ostream &os,
|
||||
clang::DiagnosticOptions *diags,
|
||||
ParserClient* client,
|
||||
const FileManager* fileManager,
|
||||
bool useLogging = true
|
||||
);
|
||||
|
||||
@@ -25,7 +23,6 @@ public:
|
||||
|
||||
private:
|
||||
ParserClient* m_client;
|
||||
const FileManager* m_fileManager;
|
||||
bool m_isParsingFile;
|
||||
bool m_useLogging;
|
||||
};
|
||||
|
||||
@@ -179,7 +179,7 @@ std::shared_ptr<CxxDiagnosticConsumer> CxxParser::getDiagnostics(const Arguments
|
||||
{
|
||||
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> options = new clang::DiagnosticOptions();
|
||||
return std::make_shared<CxxDiagnosticConsumer>(
|
||||
llvm::errs(), &*options, m_client, m_fileRegister->getFileManager(), arguments.logErrors);
|
||||
llvm::errs(), &*options, m_client, arguments.logErrors);
|
||||
}
|
||||
|
||||
void CxxParser::setupParsing(const Arguments& arguments)
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
#include "data/parser/cxx/PreprocessorCallbacks.h"
|
||||
|
||||
|
||||
#include "clang/Driver/Util.h"
|
||||
#include "clang/Basic/IdentifierTable.h"
|
||||
#include "clang/Lex/MacroArgs.h"
|
||||
|
||||
#include "utility/file/FileManager.h"
|
||||
#include "utility/file/FileRegister.h"
|
||||
|
||||
#include "data/parser/ParserClient.h"
|
||||
@@ -29,19 +27,17 @@ void PreprocessorCallbacks::FileChanged(
|
||||
}
|
||||
|
||||
const clang::FileEntry *fileEntry = m_sourceManager.getFileEntryForID(m_sourceManager.getFileID(location));
|
||||
|
||||
if (!fileEntry)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FilePath filePath(fileEntry->getName());
|
||||
filePath = filePath.canonical();
|
||||
FilePath filePath = FilePath(fileEntry->getName()).canonical();
|
||||
|
||||
if (m_fileRegister->getFileManager()->hasFilePath(filePath.str()))
|
||||
if (m_fileRegister->hasFilePath(filePath) && !m_fileRegister->includeFileIsParsed(filePath))
|
||||
{
|
||||
m_client->onFileParsed(m_fileRegister->getFileManager()->getFileInfo(filePath));
|
||||
m_fileRegister->markIncludeFileParsing(filePath.str());
|
||||
m_client->onFileParsed(m_fileRegister->getFileInfo(filePath));
|
||||
m_fileRegister->markIncludeFileParsing(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,16 +50,18 @@ void PreprocessorCallbacks::InclusionDirective(
|
||||
if (fileEntry && baseFileEntry)
|
||||
{
|
||||
FilePath baseFilePath = FilePath(baseFileEntry->getName()).canonical();
|
||||
FilePath includedFilePath = FilePath(fileEntry->getName()).canonical();
|
||||
if (!m_fileRegister->hasFilePath(baseFilePath) || m_fileRegister->fileIsParsed(baseFilePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const FileManager* fileManager = m_fileRegister->getFileManager();
|
||||
if (fileManager->hasFilePath(baseFilePath) && fileManager->hasFilePath(includedFilePath) &&
|
||||
!m_fileRegister->fileIsParsed(baseFilePath))
|
||||
FilePath includedFilePath = FilePath(fileEntry->getName()).canonical();
|
||||
if (m_fileRegister->hasFilePath(includedFilePath))
|
||||
{
|
||||
m_client->onFileIncludeParsed(
|
||||
getParseLocation(fileNameRange.getAsRange()),
|
||||
fileManager->getFileInfo(baseFilePath),
|
||||
fileManager->getFileInfo(includedFilePath)
|
||||
m_fileRegister->getFileInfo(baseFilePath),
|
||||
m_fileRegister->getFileInfo(includedFilePath)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -78,7 +76,7 @@ void PreprocessorCallbacks::MacroDefined(const clang::Token& macroNameToken, con
|
||||
}
|
||||
|
||||
FilePath filePath = FilePath(fileStr);
|
||||
if (m_fileRegister->getFileManager()->hasFilePath(filePath) && !m_fileRegister->fileIsParsed(filePath))
|
||||
if (m_fileRegister->hasFilePath(filePath) && !m_fileRegister->fileIsParsed(filePath))
|
||||
{
|
||||
// ignore builtin macros
|
||||
if (m_sourceManager.getSpellingLoc(macroNameToken.getLocation()).printToString(m_sourceManager)[0] == '<')
|
||||
@@ -105,7 +103,7 @@ void PreprocessorCallbacks::MacroExpands(
|
||||
}
|
||||
|
||||
FilePath filePath = FilePath(fileStr);
|
||||
if (m_fileRegister->getFileManager()->hasFilePath(filePath) && !m_fileRegister->fileIsParsed(filePath))
|
||||
if (m_fileRegister->hasFilePath(filePath) && !m_fileRegister->fileIsParsed(filePath))
|
||||
{
|
||||
NameHierarchy nameHierarchy;
|
||||
nameHierarchy.push(std::make_shared<NameElement>(macroNameToken.getIdentifierInfo()->getName().str()));
|
||||
|
||||
@@ -2784,7 +2784,6 @@ public:
|
||||
CxxParser parser(&client, fr);
|
||||
|
||||
std::vector<FilePath> filePaths;
|
||||
filePaths.push_back(FilePath("data/CxxParserTestSuite/header.h"));
|
||||
filePaths.push_back(FilePath("data/CxxParserTestSuite/code.cpp"));
|
||||
|
||||
Parser::Arguments args;
|
||||
@@ -2811,7 +2810,7 @@ public:
|
||||
TS_ASSERT_EQUALS(client.usages.size(), 3);
|
||||
TS_ASSERT_EQUALS(client.typeUses.size(), 17);
|
||||
|
||||
TS_ASSERT_EQUALS(client.files.size(), 3);
|
||||
TS_ASSERT_EQUALS(client.files.size(), 2);
|
||||
TS_ASSERT_EQUALS(client.includes.size(), 1);
|
||||
}
|
||||
|
||||
@@ -3090,13 +3089,6 @@ private:
|
||||
|
||||
std::shared_ptr<TestParserClient> parseCode(std::string code, bool logErrors = true)
|
||||
{
|
||||
if (!m_args.headerSearchPaths.size())
|
||||
{
|
||||
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
||||
settings->load("data/TestSettings.xml");
|
||||
m_args.headerSearchPaths = settings->getHeaderSearchPaths();
|
||||
}
|
||||
|
||||
m_args.logErrors = logErrors;
|
||||
m_args.language = "c++";
|
||||
m_args.languageStandard = "1z";
|
||||
|
||||
@@ -23,14 +23,11 @@ public:
|
||||
std::vector<std::string> sourceExtensions;
|
||||
sourceExtensions.push_back(".cpp");
|
||||
sourceExtensions.push_back(".c");
|
||||
std::vector<std::string> includeExtensions;
|
||||
includeExtensions.push_back(".hpp");
|
||||
includeExtensions.push_back(".h");
|
||||
|
||||
FileManager fm;
|
||||
fm.setPaths(sourcePaths, headerPaths, sourceExtensions, includeExtensions);
|
||||
fm.setPaths(sourcePaths, headerPaths, sourceExtensions);
|
||||
fm.fetchFilePaths(std::vector<FileInfo>());
|
||||
|
||||
TS_ASSERT_EQUALS(fm.getAddedFilePaths().size(), 4);
|
||||
TS_ASSERT_EQUALS(fm.getAddedFilePaths().size(), 2);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
TestStorage storage;
|
||||
|
||||
std::shared_ptr<IntermediateStorage> intermetiateStorage = std::make_shared<IntermediateStorage>();
|
||||
Id id = intermetiateStorage->addNode(Node::typeToInt(Node::NODE_TYPEDEF), NameHierarchy::serialize(a), true);
|
||||
intermetiateStorage->addNode(Node::typeToInt(Node::NODE_TYPEDEF), NameHierarchy::serialize(a), true);
|
||||
|
||||
storage.inject(intermetiateStorage.get());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user