CppTools: Tag incomplete semantic info

...in order to be able to full-rehighlight on the next turn.

The following sequence was problematic:

1. recalculateSemanticInfoDetached(true)
   * e.g. triggered by opening the document
2. recalculateSemanticInfoDetached(false)
   * e.g. triggered by moving the cursor
   * cancels 1. and leads to incompletely parsed/checked document - OK
3. startHighlighting()
   * triggered by 1.; starts highlighting on incomplete document - OK
4. startHighlighting()
   * gets a completely parsed/checked document - OK
   * not forced, so just compare revisions; they are the same, so
     skip/return - a partly highlighted document is left behind.

Task-number: QTCREATORBUG-11367
Change-Id: Ic56e00e862ec4a1ffa197b2fc8b48be56a3562de
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2014-03-12 12:40:33 -03:00
parent 1f0fd959fa
commit 18e6be55d7
4 changed files with 34 additions and 20 deletions

View File

@@ -35,6 +35,7 @@
#include "cppsemanticinfo.h"
#include "cppsnapshotupdater.h"
#include <cplusplus/Control.h>
#include <cplusplus/CppDocument.h>
#include <QFuture>
@@ -43,7 +44,10 @@
#include <QSharedPointer>
#include <QTimer>
namespace CPlusPlus { class AST; }
namespace CPlusPlus {
class AST;
class DeclarationAST;
} // namespace CPlusPlus
namespace TextEditor {
class BaseTextEditor;
@@ -171,9 +175,19 @@ private:
};
private:
class FuturizedTopLevelDeclarationProcessor: public CPlusPlus::TopLevelDeclarationProcessor
{
public:
FuturizedTopLevelDeclarationProcessor(QFutureInterface<void> &future): m_future(future) {}
bool processDeclaration(CPlusPlus::DeclarationAST *) { return !isCanceled(); }
bool isCanceled() { return m_future.isCanceled(); }
private:
QFutureInterface<void> m_future;
};
SemanticInfo::Source currentSource(bool force);
void recalculateSemanticInfoNow(const SemanticInfo::Source &source, bool emitSignalWhenFinished,
CPlusPlus::TopLevelDeclarationProcessor *processor = 0);
FuturizedTopLevelDeclarationProcessor *processor = 0);
void recalculateSemanticInfoDetached_helper(QFutureInterface<void> &future,
SemanticInfo::Source source);
@@ -209,6 +223,7 @@ private:
// Highlighting:
unsigned m_lastHighlightRevision;
bool m_lastHighlightOnCompleteSemanticInfo;
QFuture<TextEditor::HighlightingResult> m_highlighter;
QScopedPointer<CppTools::CppHighlightingSupport> m_highlightingSupport;