forked from qt-creator/qt-creator
Clang: Differentiate between user and non user includes for updating
We don't want to recreate a PCH if the include or source is not contained by a PCH. Change-Id: If52fc1aed92054b4165cdc634656147fbe8baa47 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -98,7 +98,7 @@ void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart)
|
||||
std::vector<SymbolIndexerTask> symbolIndexerTask;
|
||||
symbolIndexerTask.reserve(projectPart.sourcePathIds.size());
|
||||
for (FilePathId sourcePathId : projectPart.sourcePathIds) {
|
||||
SourceTimeStamps dependentTimeStamps = m_symbolStorage.fetchIncludedIndexingTimeStamps(
|
||||
SourceTimeStamps dependentTimeStamps = m_buildDependencyStorage.fetchIncludedIndexingTimeStamps(
|
||||
sourcePathId);
|
||||
|
||||
if (!m_modifiedTimeChecker.isUpToDate(dependentTimeStamps)) {
|
||||
@@ -122,7 +122,8 @@ void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart)
|
||||
|
||||
auto store = [&] {
|
||||
Sqlite::ImmediateTransaction transaction{m_transactionInterface};
|
||||
m_symbolStorage.insertOrUpdateIndexingTimeStamps(symbolsCollector.fileStatuses());
|
||||
m_buildDependencyStorage.insertOrUpdateIndexingTimeStamps(
|
||||
symbolsCollector.fileStatuses());
|
||||
m_symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(),
|
||||
symbolsCollector.sourceLocations());
|
||||
transaction.commit();
|
||||
@@ -144,28 +145,17 @@ void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart)
|
||||
}
|
||||
}
|
||||
|
||||
m_pathWatcher.updateIdPaths(
|
||||
{{projectPartId, m_buildDependencyStorage.fetchPchSources(projectPartId)}});
|
||||
m_pathWatcher.updateIdPaths({{{projectPartId, SourceType::Source},
|
||||
m_buildDependencyStorage.fetchPchSources(projectPartId)}});
|
||||
m_symbolIndexerTaskQueue.addOrUpdateTasks(std::move(symbolIndexerTask));
|
||||
m_symbolIndexerTaskQueue.processEntries();
|
||||
}
|
||||
|
||||
void SymbolIndexer::pathsWithIdsChanged(const ProjectPartIds &) {}
|
||||
void SymbolIndexer::pathsWithIdsChanged(const std::vector<IdPaths> &) {}
|
||||
|
||||
void SymbolIndexer::pathsChanged(const FilePathIds &filePathIds)
|
||||
{
|
||||
m_modifiedTimeChecker.pathsChanged(filePathIds);
|
||||
|
||||
FilePathIds dependentSourcePathIds = m_symbolStorage.fetchDependentSourceIds(filePathIds);
|
||||
|
||||
std::vector<SymbolIndexerTask> symbolIndexerTask;
|
||||
symbolIndexerTask.reserve(dependentSourcePathIds.size());
|
||||
|
||||
for (FilePathId dependentSourcePathId : dependentSourcePathIds)
|
||||
updateChangedPath(dependentSourcePathId, symbolIndexerTask);
|
||||
|
||||
m_symbolIndexerTaskQueue.addOrUpdateTasks(std::move(symbolIndexerTask));
|
||||
m_symbolIndexerTaskQueue.processEntries();
|
||||
}
|
||||
|
||||
void SymbolIndexer::updateChangedPath(FilePathId filePathId,
|
||||
@@ -182,7 +172,8 @@ void SymbolIndexer::updateChangedPath(FilePathId filePathId,
|
||||
|
||||
ProjectPartId projectPartId = optionalArtefact->projectPartId;
|
||||
|
||||
SourceTimeStamps dependentTimeStamps = m_symbolStorage.fetchIncludedIndexingTimeStamps(filePathId);
|
||||
SourceTimeStamps dependentTimeStamps = m_buildDependencyStorage.fetchIncludedIndexingTimeStamps(
|
||||
filePathId);
|
||||
|
||||
auto indexing = [optionalArtefact = std::move(optionalArtefact),
|
||||
filePathId,
|
||||
@@ -207,7 +198,7 @@ void SymbolIndexer::updateChangedPath(FilePathId filePathId,
|
||||
|
||||
auto store = [&] {
|
||||
Sqlite::ImmediateTransaction transaction{m_transactionInterface};
|
||||
m_symbolStorage.insertOrUpdateIndexingTimeStamps(symbolsCollector.fileStatuses());
|
||||
m_buildDependencyStorage.insertOrUpdateIndexingTimeStamps(symbolsCollector.fileStatuses());
|
||||
m_symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(),
|
||||
symbolsCollector.sourceLocations());
|
||||
transaction.commit();
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
void updateProjectParts(ProjectPartContainers &&projectParts);
|
||||
void updateProjectPart(ProjectPartContainer &&projectPart);
|
||||
|
||||
void pathsWithIdsChanged(const ProjectPartIds &ids) override;
|
||||
void pathsWithIdsChanged(const std::vector<IdPaths> &idPaths) override;
|
||||
void pathsChanged(const FilePathIds &filePathIds) override;
|
||||
void updateChangedPath(FilePathId filePath,
|
||||
std::vector<SymbolIndexerTask> &symbolIndexerTask);
|
||||
@@ -75,6 +75,9 @@ public:
|
||||
FilePathIds updatableFilePathIds(const ProjectPartContainer &projectPart,
|
||||
const Utils::optional<ProjectPartArtefact> &optionalArtefact) const;
|
||||
|
||||
private:
|
||||
FilePathIds filterProjectPartSources(const FilePathIds &filePathIds) const;
|
||||
|
||||
private:
|
||||
SymbolIndexerTaskQueueInterface &m_symbolIndexerTaskQueue;
|
||||
SymbolStorageInterface &m_symbolStorage;
|
||||
|
||||
@@ -70,93 +70,6 @@ public:
|
||||
deleteNewLocationsTable();
|
||||
}
|
||||
|
||||
void insertOrUpdateIndexingTimeStamps(const FilePathIds &filePathIds, TimeStamp indexingTimeStamp) override
|
||||
{
|
||||
try {
|
||||
Sqlite::ImmediateTransaction transaction{database};
|
||||
|
||||
for (FilePathId filePathId : filePathIds) {
|
||||
inserOrUpdateIndexingTimesStampStatement.write(filePathId.filePathId,
|
||||
indexingTimeStamp.value);
|
||||
}
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Sqlite::StatementIsBusy &) {
|
||||
insertOrUpdateIndexingTimeStamps(filePathIds, indexingTimeStamp);
|
||||
}
|
||||
}
|
||||
|
||||
void insertOrUpdateIndexingTimeStamps(const FileStatuses &fileStatuses) override
|
||||
{
|
||||
for (FileStatus fileStatus : fileStatuses) {
|
||||
inserOrUpdateIndexingTimesStampStatement.write(fileStatus.filePathId.filePathId,
|
||||
fileStatus.lastModified);
|
||||
}
|
||||
}
|
||||
|
||||
SourceTimeStamps fetchIndexingTimeStamps() const override
|
||||
{
|
||||
try {
|
||||
Sqlite::DeferredTransaction transaction{database};
|
||||
|
||||
auto timeStamps = fetchIndexingTimeStampsStatement.template values<SourceTimeStamp, 2>(
|
||||
1024);
|
||||
|
||||
transaction.commit();
|
||||
|
||||
return timeStamps;
|
||||
} catch (const Sqlite::StatementIsBusy &) {
|
||||
return fetchIndexingTimeStamps();
|
||||
}
|
||||
}
|
||||
|
||||
SourceTimeStamps fetchIncludedIndexingTimeStamps(FilePathId sourcePathId) const override
|
||||
{
|
||||
try {
|
||||
Sqlite::DeferredTransaction transaction{database};
|
||||
|
||||
auto timeStamps = fetchIncludedIndexingTimeStampsStatement
|
||||
.template values<SourceTimeStamp, 2>(1024, sourcePathId.filePathId);
|
||||
|
||||
transaction.commit();
|
||||
|
||||
return timeStamps;
|
||||
} catch (const Sqlite::StatementIsBusy &) {
|
||||
return fetchIncludedIndexingTimeStamps(sourcePathId);
|
||||
}
|
||||
}
|
||||
|
||||
FilePathIds fetchDependentSourceIds(const FilePathIds &sourcePathIds) const override
|
||||
{
|
||||
try {
|
||||
FilePathIds dependentSourceIds;
|
||||
|
||||
Sqlite::DeferredTransaction transaction{database};
|
||||
|
||||
for (FilePathId sourcePathId : sourcePathIds) {
|
||||
FilePathIds newDependentSourceIds;
|
||||
newDependentSourceIds.reserve(dependentSourceIds.size() + 1024);
|
||||
|
||||
auto newIds = fetchDependentSourceIdsStatement
|
||||
.template values<FilePathId>(1024, sourcePathId.filePathId);
|
||||
|
||||
std::set_union(dependentSourceIds.begin(),
|
||||
dependentSourceIds.end(),
|
||||
newIds.begin(),
|
||||
newIds.end(),
|
||||
std::back_inserter(newDependentSourceIds));
|
||||
|
||||
dependentSourceIds = std::move(newDependentSourceIds);
|
||||
}
|
||||
|
||||
transaction.commit();
|
||||
|
||||
return dependentSourceIds;
|
||||
} catch (const Sqlite::StatementIsBusy &) {
|
||||
return fetchDependentSourceIds(sourcePathIds);
|
||||
}
|
||||
}
|
||||
|
||||
void fillTemporarySymbolsTable(const SymbolEntries &symbolEntries)
|
||||
{
|
||||
WriteStatement &statement = insertSymbolsToNewSymbolsStatement;
|
||||
@@ -278,25 +191,6 @@ public:
|
||||
database};
|
||||
WriteStatement deleteNewSymbolsTableStatement{"DELETE FROM newSymbols", database};
|
||||
WriteStatement deleteNewLocationsTableStatement{"DELETE FROM newLocations", database};
|
||||
WriteStatement inserOrUpdateIndexingTimesStampStatement{
|
||||
"INSERT INTO fileStatuses(sourceId, indexingTimeStamp) VALUES (?001, ?002) ON "
|
||||
"CONFLICT(sourceId) DO UPDATE SET indexingTimeStamp = ?002",
|
||||
database};
|
||||
mutable ReadStatement fetchIncludedIndexingTimeStampsStatement{
|
||||
"WITH RECURSIVE collectedDependencies(sourceId) AS (VALUES(?) UNION SELECT "
|
||||
"dependencySourceId FROM sourceDependencies, collectedDependencies WHERE "
|
||||
"sourceDependencies.sourceId == collectedDependencies.sourceId) SELECT DISTINCT sourceId, "
|
||||
"indexingTimeStamp FROM collectedDependencies NATURAL JOIN fileStatuses ORDER BY sourceId",
|
||||
database};
|
||||
mutable ReadStatement fetchIndexingTimeStampsStatement{
|
||||
"SELECT sourceId, indexingTimeStamp FROM fileStatuses", database};
|
||||
mutable ReadStatement fetchDependentSourceIdsStatement{
|
||||
"WITH RECURSIVE collectedDependencies(sourceId) AS (VALUES(?) UNION SELECT "
|
||||
"sourceDependencies.sourceId FROM sourceDependencies, collectedDependencies WHERE "
|
||||
"sourceDependencies.dependencySourceId == collectedDependencies.sourceId) SELECT sourceId "
|
||||
"FROM collectedDependencies WHERE sourceId NOT IN (SELECT dependencySourceId FROM "
|
||||
"sourceDependencies) ORDER BY sourceId",
|
||||
database};
|
||||
};
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
@@ -48,11 +48,6 @@ public:
|
||||
virtual void addSymbolsAndSourceLocations(const SymbolEntries &symbolEntries,
|
||||
const SourceLocationEntries &sourceLocations)
|
||||
= 0;
|
||||
virtual void insertOrUpdateIndexingTimeStamps(const FilePathIds &filePathIds, TimeStamp indexingTimeStamp) = 0;
|
||||
virtual void insertOrUpdateIndexingTimeStamps(const FileStatuses &fileStatuses) = 0;
|
||||
virtual SourceTimeStamps fetchIndexingTimeStamps() const = 0;
|
||||
virtual SourceTimeStamps fetchIncludedIndexingTimeStamps(FilePathId sourcePathId) const = 0;
|
||||
virtual FilePathIds fetchDependentSourceIds(const FilePathIds &sourcePathIds) const = 0;
|
||||
|
||||
protected:
|
||||
~SymbolStorageInterface() = default;
|
||||
|
||||
Reference in New Issue
Block a user