src: Fixed FileRegisterStateData synchronisation

This commit is contained in:
Eberhard Graether
2017-04-12 00:38:48 +02:00
parent b9d1f5367c
commit 0e4b606c7c
4 changed files with 16 additions and 26 deletions
@@ -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);
}
}
}
}