forked from qt-creator/qt-creator
CppTools: Move DependencyTable to Snapshot
It logically depends on the Snapshot and has a related lifetime. Keeping it in the Snapshot avoids some code compelxity. Change-Id: I24ee4483b44d9b0d7f2e4d494ae7ea624b949f9c Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
@@ -713,6 +713,7 @@ bool Document::DiagnosticMessage::operator!=(const Document::DiagnosticMessage &
|
||||
}
|
||||
|
||||
Snapshot::Snapshot()
|
||||
: m_deps(new DependencyTable)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -747,8 +748,10 @@ bool Snapshot::contains(const QString &fileName) const
|
||||
|
||||
void Snapshot::insert(Document::Ptr doc)
|
||||
{
|
||||
if (doc)
|
||||
if (doc) {
|
||||
_documents.insert(doc->fileName(), doc);
|
||||
m_deps->files.clear(); // Will trigger re-build when accessed.
|
||||
}
|
||||
}
|
||||
|
||||
Document::Ptr Snapshot::preprocessedDocument(const QByteArray &source,
|
||||
@@ -795,6 +798,18 @@ QSet<QString> Snapshot::allIncludesForDocument(const QString &fileName) const
|
||||
return result;
|
||||
}
|
||||
|
||||
QStringList Snapshot::filesDependingOn(const QString &fileName) const
|
||||
{
|
||||
updateDependencyTable();
|
||||
return m_deps->filesDependingOn(fileName);
|
||||
}
|
||||
|
||||
void Snapshot::updateDependencyTable() const
|
||||
{
|
||||
if (m_deps->files.isEmpty())
|
||||
m_deps->build(*this);
|
||||
}
|
||||
|
||||
void Snapshot::allIncludesForDocument_helper(const QString &fileName, QSet<QString> &result) const
|
||||
{
|
||||
if (Document::Ptr doc = document(fileName)) {
|
||||
|
||||
Reference in New Issue
Block a user