diff options
author | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2014-03-11 14:00:57 -0300 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2014-03-17 14:39:50 +0100 |
commit | cbf98ba819e424345fcf9ad0bd42a52c462f072a (patch) | |
tree | 8bc437e2c2684c03c8b3f309688ac5a0ee54b4ae /src/plugins/cpptools | |
parent | 18e6be55d7260a6f21e0021d6eba7da002125ab2 (diff) |
CppEditor: Allow force highlighting if using clang
...so we can rehighlight if it's requested by the editor. This is e.g.
necessary if the font size changes.
Task-number: QTCREATORBUG-11502
Change-Id: I608921899fc37fcf1394db9ff041e6b378196bdd
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/plugins/cpptools')
-rw-r--r-- | src/plugins/cpptools/cpptoolseditorsupport.cpp | 13 | ||||
-rw-r--r-- | src/plugins/cpptools/cpptoolseditorsupport.h | 12 |
2 files changed, 16 insertions, 9 deletions
diff --git a/src/plugins/cpptools/cpptoolseditorsupport.cpp b/src/plugins/cpptools/cpptoolseditorsupport.cpp index 4a6f4351e98..4932b21e9a6 100644 --- a/src/plugins/cpptools/cpptoolseditorsupport.cpp +++ b/src/plugins/cpptools/cpptoolseditorsupport.cpp @@ -237,7 +237,7 @@ Document::Ptr CppEditorSupport::lastSemanticInfoDocument() const return m_lastSemanticInfo.doc; } -void CppEditorSupport::recalculateSemanticInfoDetached(bool force) +void CppEditorSupport::recalculateSemanticInfoDetached(ForceReason forceReason) { // Block premature calculation caused by CppEditorPlugin::currentEditorChanged // when the editor is created. @@ -245,12 +245,13 @@ void CppEditorSupport::recalculateSemanticInfoDetached(bool force) return; m_futureSemanticInfo.cancel(); + const bool force = forceReason != NoForce; SemanticInfo::Source source = currentSource(force); m_futureSemanticInfo = QtConcurrent::run<CppEditorSupport, void>( &CppEditorSupport::recalculateSemanticInfoDetached_helper, this, source); if (force && m_highlightingSupport && !m_highlightingSupport->requiresSemanticInfo()) - startHighlighting(); + startHighlighting(forceReason); } CppCompletionAssistProvider *CppEditorSupport::completionAssistProvider() const @@ -352,14 +353,14 @@ void CppEditorSupport::onDocumentUpdated(Document::Ptr doc) || m_lastSemanticInfo.doc->translationUnit()->ast() == 0 || m_lastSemanticInfo.doc->fileName() != fileName()))) { m_initialized = true; - recalculateSemanticInfoDetached(/* force = */ true); + recalculateSemanticInfoDetached(ForceDueToMissingSemanticInfo); } // notify the editor that the document is updated emit documentUpdated(); } -void CppEditorSupport::startHighlighting() +void CppEditorSupport::startHighlighting(ForceReason forceReason) { if (!m_highlightingSupport) return; @@ -395,8 +396,8 @@ void CppEditorSupport::startHighlighting() m_lastHighlightOnCompleteSemanticInfo = complete; emit highlighterStarted(&m_highlighter, m_lastHighlightRevision); } else { - const unsigned revision = currentSource(false).revision; - if (m_lastHighlightRevision == revision) + const unsigned revision = editorRevision(); + if (forceReason != ForceDueEditorRequest && m_lastHighlightRevision == revision) return; m_highlighter.cancel(); diff --git a/src/plugins/cpptools/cpptoolseditorsupport.h b/src/plugins/cpptools/cpptoolseditorsupport.h index b4f950712da..29cfb508e04 100644 --- a/src/plugins/cpptools/cpptoolseditorsupport.h +++ b/src/plugins/cpptools/cpptoolseditorsupport.h @@ -119,11 +119,17 @@ public: CPlusPlus::Document::Ptr lastSemanticInfoDocument() const; + enum ForceReason { + NoForce, + ForceDueToMissingSemanticInfo, + ForceDueEditorRequest + }; + /// Recalculates the semantic info in a future, and will emit the /// semanticInfoUpdated() signal when finished. /// Requires that initialized() is true. - /// \param force do not check if the old semantic info is still valid - void recalculateSemanticInfoDetached(bool force = false); + /// \param forceReason the reason to force, if any + void recalculateSemanticInfoDetached(ForceReason forceReason); CppCompletionAssistProvider *completionAssistProvider() const; @@ -148,7 +154,7 @@ private slots: void updateDocumentNow(); void onDocumentUpdated(CPlusPlus::Document::Ptr doc); - void startHighlighting(); + void startHighlighting(ForceReason forceReason = NoForce); void onDiagnosticsChanged(); |