forked from qt-creator/qt-creator
Clang: Extent sources manager with dependency
For many index cases such a function call it is needed to check if any of the included files are changed because the function which is called could be changed too. Change-Id: Ibe0f43426c735d39072f284cad075dd4dc6f99c0 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -59,6 +59,8 @@ public:
|
|||||||
if (!upToDate)
|
if (!upToDate)
|
||||||
addOrUpdateNewEntry(filePathId, modifiedTime);
|
addOrUpdateNewEntry(filePathId, modifiedTime);
|
||||||
|
|
||||||
|
m_dependendFilesModified = m_dependendFilesModified || !upToDate;
|
||||||
|
|
||||||
return upToDate ;
|
return upToDate ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +82,17 @@ public:
|
|||||||
|
|
||||||
m_modifiedTimeStamps = std::move(mergedModifiedTimeStamps);
|
m_modifiedTimeStamps = std::move(mergedModifiedTimeStamps);
|
||||||
m_newModifiedTimeStamps.clear();
|
m_newModifiedTimeStamps.clear();
|
||||||
|
m_dependendFilesModified = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dependendFilesModified() const
|
||||||
|
{
|
||||||
|
return m_dependendFilesModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool alreadyParsedAllDependFiles(FilePathId filePathId, std::time_t modifiedTime)
|
||||||
|
{
|
||||||
|
return alreadyParsed(filePathId, modifiedTime) && !dependendFilesModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -101,6 +114,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
std::vector<FilePathIdTime> m_modifiedTimeStamps;
|
std::vector<FilePathIdTime> m_modifiedTimeStamps;
|
||||||
std::vector<FilePathIdTime> m_newModifiedTimeStamps;
|
std::vector<FilePathIdTime> m_newModifiedTimeStamps;
|
||||||
|
bool m_dependendFilesModified = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -136,4 +136,100 @@ TEST_F(SourcesManager, TimeIsUpdated)
|
|||||||
ASSERT_TRUE(sources.alreadyParsed({1, 1}, 57));
|
ASSERT_TRUE(sources.alreadyParsed({1, 1}, 57));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(SourcesManager, AnyDependFileIsNotModifiedAfterInitialization)
|
||||||
|
{
|
||||||
|
ASSERT_FALSE(sources.dependendFilesModified());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SourcesManager, AnyDependFileIsModified)
|
||||||
|
{
|
||||||
|
sources.alreadyParsed({1, 1}, 56);
|
||||||
|
|
||||||
|
ASSERT_TRUE(sources.dependendFilesModified());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SourcesManager, AnyDependFileIsModifiedAfterParsingTwoTimesSameTimeStamp)
|
||||||
|
{
|
||||||
|
sources.alreadyParsed({1, 1}, 56);
|
||||||
|
sources.alreadyParsed({1, 1}, 56);
|
||||||
|
|
||||||
|
ASSERT_TRUE(sources.dependendFilesModified());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SourcesManager, AnyDependFileIsNotModifiedAfterUpdate)
|
||||||
|
{
|
||||||
|
sources.alreadyParsed({1, 1}, 56);
|
||||||
|
sources.updateModifiedTimeStamps();
|
||||||
|
|
||||||
|
ASSERT_FALSE(sources.dependendFilesModified());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SourcesManager, AnyDependFileIsNotModifiedAfterNotAlreadyPared)
|
||||||
|
{
|
||||||
|
sources.alreadyParsed({1, 1}, 56);
|
||||||
|
sources.updateModifiedTimeStamps();
|
||||||
|
|
||||||
|
sources.alreadyParsed({1, 1}, 56);
|
||||||
|
|
||||||
|
ASSERT_FALSE(sources.dependendFilesModified());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SourcesManager, AnyDependFileIsNotModifiedAfterAlreadyPared)
|
||||||
|
{
|
||||||
|
sources.alreadyParsed({1, 1}, 56);
|
||||||
|
sources.updateModifiedTimeStamps();
|
||||||
|
|
||||||
|
sources.alreadyParsed({1, 1}, 57);
|
||||||
|
|
||||||
|
ASSERT_TRUE(sources.dependendFilesModified());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SourcesManager, AnyDependFileIsModifiedAfterUpdateNewTimeStamp)
|
||||||
|
{
|
||||||
|
sources.alreadyParsed({1, 1}, 56);
|
||||||
|
sources.alreadyParsed({1, 2}, 56);
|
||||||
|
sources.updateModifiedTimeStamps();
|
||||||
|
sources.alreadyParsed({1, 1}, 57);
|
||||||
|
|
||||||
|
sources.alreadyParsed({1, 2}, 56);
|
||||||
|
|
||||||
|
ASSERT_TRUE(sources.dependendFilesModified());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SourcesManager, AlreadyParsedWithDependencyAfterUpdateNewTimeStamp)
|
||||||
|
{
|
||||||
|
sources.alreadyParsedAllDependFiles({1, 1}, 56);
|
||||||
|
sources.alreadyParsedAllDependFiles({1, 2}, 56);
|
||||||
|
sources.updateModifiedTimeStamps();
|
||||||
|
sources.alreadyParsedAllDependFiles({1, 1}, 57);
|
||||||
|
|
||||||
|
bool alreadyParsed = sources.alreadyParsedAllDependFiles({1, 2}, 56);
|
||||||
|
|
||||||
|
ASSERT_FALSE(alreadyParsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SourcesManager, AlreadyParsedWithDependencyAfterUpdateNewSecondTimeStamp)
|
||||||
|
{
|
||||||
|
sources.alreadyParsedAllDependFiles({1, 1}, 56);
|
||||||
|
sources.alreadyParsedAllDependFiles({1, 2}, 56);
|
||||||
|
sources.updateModifiedTimeStamps();
|
||||||
|
sources.alreadyParsedAllDependFiles({1, 1}, 56);
|
||||||
|
|
||||||
|
bool alreadyParsed = sources.alreadyParsedAllDependFiles({1, 2}, 57);
|
||||||
|
|
||||||
|
ASSERT_FALSE(alreadyParsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SourcesManager, AlreadyParsedWithDependencyAfterUpdateSameTimeStamps)
|
||||||
|
{
|
||||||
|
sources.alreadyParsedAllDependFiles({1, 1}, 56);
|
||||||
|
sources.alreadyParsedAllDependFiles({1, 2}, 56);
|
||||||
|
sources.updateModifiedTimeStamps();
|
||||||
|
sources.alreadyParsedAllDependFiles({1, 1}, 56);
|
||||||
|
|
||||||
|
bool alreadyParsed = sources.alreadyParsedAllDependFiles({1, 2}, 56);
|
||||||
|
|
||||||
|
ASSERT_TRUE(alreadyParsed);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user