src: Fixed FileRegisterStateData synchronisation
This commit is contained in:
@@ -49,7 +49,7 @@ FileRegister::~FileRegister()
|
||||
{
|
||||
}
|
||||
|
||||
FileRegisterStateData FileRegister::getStateData() const
|
||||
const FileRegisterStateData& FileRegister::getStateData() const
|
||||
{
|
||||
return m_stateData;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public:
|
||||
FileRegister(const FileRegisterStateData& stateData, const std::set<FilePath>& indexedPaths, const std::set<FilePath>& excludedPaths);
|
||||
virtual ~FileRegister();
|
||||
|
||||
FileRegisterStateData getStateData() const;
|
||||
const FileRegisterStateData& getStateData() const;
|
||||
|
||||
void markFileIndexing(const FilePath& filePath);
|
||||
void markIndexingFilesIndexed();
|
||||
|
||||
@@ -25,21 +25,13 @@ void FileRegisterStateData::inject(const FileRegisterStateData& o)
|
||||
void FileRegisterStateData::markFileIndexing(const FilePath& filePath)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_filePathsMutex);
|
||||
auto it = m_filePaths.find(filePath);
|
||||
if (it != m_filePaths.end())
|
||||
{
|
||||
it->second = STATE_INDEXING;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_filePaths.insert(std::make_pair(filePath, STATE_INDEXING));
|
||||
}
|
||||
m_filePaths[filePath] = STATE_INDEXING;
|
||||
}
|
||||
|
||||
void FileRegisterStateData::markIndexingFilesIndexed()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_filePathsMutex);
|
||||
for (auto it: m_filePaths)
|
||||
for (auto& it: m_filePaths)
|
||||
{
|
||||
if (it.second == STATE_INDEXING)
|
||||
{
|
||||
|
||||
@@ -22,6 +22,8 @@ PreprocessorCallbacks::PreprocessorCallbacks(
|
||||
void PreprocessorCallbacks::FileChanged(
|
||||
clang::SourceLocation location, FileChangeReason reason, clang::SrcMgr::CharacteristicKind, clang::FileID prevID)
|
||||
{
|
||||
m_currentPath = FilePath();
|
||||
|
||||
FilePath filePath;
|
||||
|
||||
const clang::FileEntry *fileEntry = m_sourceManager.getFileEntryForID(m_sourceManager.getFileID(location));
|
||||
@@ -30,23 +32,19 @@ void PreprocessorCallbacks::FileChanged(
|
||||
filePath = FilePath(fileEntry->getName()).canonical();
|
||||
}
|
||||
|
||||
const bool fileIsInProject = m_fileRegister->hasFilePath(filePath);
|
||||
if (!filePath.empty() && fileIsInProject)
|
||||
if (!filePath.empty() && m_fileRegister->hasFilePath(filePath))
|
||||
{
|
||||
m_client->onFileParsed(FileSystem::getFileInfoForPath(filePath)); // todo: fix for tests
|
||||
if (reason == EnterFile && !m_fileRegister->fileIsIndexed(filePath))
|
||||
{
|
||||
m_fileRegister->markFileIndexing(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
if (!filePath.empty() && fileIsInProject && !m_fileRegister->fileIsIndexed(filePath))
|
||||
{
|
||||
m_currentPath = filePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_currentPath = FilePath();
|
||||
if (!m_fileRegister->fileIsIndexed(filePath))
|
||||
{
|
||||
m_currentPath = filePath;
|
||||
|
||||
if (reason == EnterFile)
|
||||
{
|
||||
m_fileRegister->markFileIndexing(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user