CppEditor: Clean up CppUseSelectionsUpdater

* Remove unused member m_snapshot
* QTC_CHECK -> "if (!...)" - the revision might have changed in the mean
  time
* Restore previous document in synchronous case

Change-Id: Ie05c044fbb75e92edbf0fdb041178aadde8113c5
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
Nikolai Kosjar
2014-09-08 10:15:31 +02:00
parent 300c48e864
commit 9e81bd0b36
2 changed files with 6 additions and 4 deletions

View File

@@ -255,7 +255,9 @@ void CppUseSelectionsUpdater::update(CallType callType)
{
CppEditorWidget *cppEditorWidget = qobject_cast<CppEditorWidget *>(m_editorWidget);
QTC_ASSERT(cppEditorWidget, return);
QTC_CHECK(cppEditorWidget->isSemanticInfoValidExceptLocalUses());
if (!cppEditorWidget->isSemanticInfoValidExceptLocalUses())
return;
const CppTools::SemanticInfo semanticInfo = cppEditorWidget->semanticInfo();
const Document::Ptr document = semanticInfo.doc;
const Snapshot snapshot = semanticInfo.snapshot;
@@ -296,7 +298,6 @@ void CppUseSelectionsUpdater::onFindUsesFinished()
m_findUsesWatcher.reset();
m_document.reset();
m_snapshot = Snapshot();
}
bool CppUseSelectionsUpdater::handleMacroCase(const Document::Ptr document)
@@ -342,7 +343,6 @@ void CppUseSelectionsUpdater::handleSymbolCaseAsynchronously(const Document::Ptr
const Snapshot &snapshot)
{
m_document = document;
m_snapshot = snapshot;
if (m_findUsesWatcher)
m_findUsesWatcher->cancel();
@@ -359,11 +359,14 @@ void CppUseSelectionsUpdater::handleSymbolCaseAsynchronously(const Document::Ptr
void CppUseSelectionsUpdater::handleSymbolCaseSynchronously(const Document::Ptr document,
const Snapshot &snapshot)
{
const CPlusPlus::Document::Ptr previousDocument = m_document;
m_document = document;
const Params params = Params(m_editorWidget->textCursor(), document, snapshot);
const UseSelectionsResult result = findUses(params);
processSymbolCaseResults(result);
m_document = previousDocument;
}
void CppUseSelectionsUpdater::processSymbolCaseResults(const UseSelectionsResult &result)