diff options
author | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2014-08-26 14:26:28 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2014-08-29 16:12:57 +0200 |
commit | 45570d406889bbf881e033feab163e149a5628cc (patch) | |
tree | 2c6a3844ef1e8eb08c05ff5b15ba5b2ca800feed /src/plugins/cpptools/cppsemanticinfoupdater.cpp | |
parent | 46b5ed2ba942847d91fdb347718d798dd5244524 (diff) | |
download | qt-creator-45570d406889bbf881e033feab163e149a5628cc.tar.gz |
CppTools: Provide the editor snapshot for SemanticInfoUpdater
...so that SemanticInfoUpdater does not depend anymore on the
EditorDocumentParser. Accessing the snapshot was a blocking operation
that delayed the semantic info update longer than actually needed.
Change-Id: I348d22ef83ab310d4319b2e8b9678fe90ee24d6a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/plugins/cpptools/cppsemanticinfoupdater.cpp')
-rw-r--r-- | src/plugins/cpptools/cppsemanticinfoupdater.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/src/plugins/cpptools/cppsemanticinfoupdater.cpp b/src/plugins/cpptools/cppsemanticinfoupdater.cpp index 71fbb16e46..dc8b4962ab 100644 --- a/src/plugins/cpptools/cppsemanticinfoupdater.cpp +++ b/src/plugins/cpptools/cppsemanticinfoupdater.cpp @@ -27,10 +27,10 @@ ** ****************************************************************************/ -#include "builtineditordocumentparser.h" -#include "cpplocalsymbols.h" #include "cppsemanticinfoupdater.h" +#include "cpplocalsymbols.h" + #include <utils/qtcassert.h> #include <utils/qtcoverride.h> #include <utils/runextensions.h> @@ -60,7 +60,7 @@ public: }; public: - SemanticInfoUpdaterPrivate(SemanticInfoUpdater *q, BuiltinEditorDocumentParser *m_parser); + SemanticInfoUpdaterPrivate(SemanticInfoUpdater *q); ~SemanticInfoUpdaterPrivate(); SemanticInfo semanticInfo() const; @@ -79,13 +79,10 @@ public: mutable QMutex m_lock; SemanticInfo m_semanticInfo; QFuture<void> m_future; - BuiltinEditorDocumentParser *m_parser; }; -SemanticInfoUpdaterPrivate::SemanticInfoUpdaterPrivate(SemanticInfoUpdater *q, - BuiltinEditorDocumentParser *parser) +SemanticInfoUpdaterPrivate::SemanticInfoUpdaterPrivate(SemanticInfoUpdater *q) : q(q) - , m_parser(parser) { } @@ -123,10 +120,7 @@ SemanticInfo SemanticInfoUpdaterPrivate::update(const SemanticInfo::Source &sour SemanticInfo newSemanticInfo; newSemanticInfo.revision = source.revision; - - QTC_ASSERT(m_parser, return newSemanticInfo); - newSemanticInfo.snapshot = m_parser->snapshot(); - QTC_ASSERT(newSemanticInfo.snapshot.contains(source.fileName), return newSemanticInfo); + newSemanticInfo.snapshot = source.snapshot; Document::Ptr doc = newSemanticInfo.snapshot.preprocessedDocument(source.code, source.fileName); if (processor) @@ -154,11 +148,12 @@ bool SemanticInfoUpdaterPrivate::reuseCurrentSemanticInfo(const SemanticInfo::So && currentSemanticInfo.revision == source.revision && currentSemanticInfo.doc && currentSemanticInfo.doc->translationUnit()->ast() - && currentSemanticInfo.doc->fileName() == source.fileName) { + && currentSemanticInfo.doc->fileName() == source.fileName + && !currentSemanticInfo.snapshot.isEmpty()) { SemanticInfo newSemanticInfo; newSemanticInfo.revision = source.revision; + newSemanticInfo.snapshot = source.snapshot; newSemanticInfo.doc = currentSemanticInfo.doc; - newSemanticInfo.snapshot = currentSemanticInfo.snapshot; // ### TODO: use the new snapshot. setSemanticInfo(newSemanticInfo, emitSignalWhenFinished); if (debug) qDebug() << "SemanticInfoUpdater: re-using current semantic info - source.revision" @@ -176,8 +171,8 @@ void SemanticInfoUpdaterPrivate::update_helper(QFutureInterface<void> &future, update(source, true, &processor); } -SemanticInfoUpdater::SemanticInfoUpdater(BuiltinEditorDocumentParser *parser) - : d(new SemanticInfoUpdaterPrivate(this, parser)) +SemanticInfoUpdater::SemanticInfoUpdater() + : d(new SemanticInfoUpdaterPrivate(this)) { } |