diff options
author | hjk <hjk121@nokiamail.com> | 2014-09-11 13:15:44 +0200 |
---|---|---|
committer | hjk <hjk121@nokiamail.com> | 2014-09-19 11:11:30 +0200 |
commit | 9a968b74173625773fb00add5602a6385dafbf04 (patch) | |
tree | 40b868631af0aa27461a0ee59420c5d4ca31ccdd /src/libs/cplusplus/CppDocument.cpp | |
parent | 0273757c937c1694bb25ad9bd3e78fb0afd4e969 (diff) | |
download | qt-creator-9a968b74173625773fb00add5602a6385dafbf04.tar.gz |
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>
Diffstat (limited to 'src/libs/cplusplus/CppDocument.cpp')
-rw-r--r-- | src/libs/cplusplus/CppDocument.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp index 389a030b55..a107749883 100644 --- a/src/libs/cplusplus/CppDocument.cpp +++ b/src/libs/cplusplus/CppDocument.cpp @@ -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)) { |