forked from qt-creator/qt-creator
Introduced our own document revision.
This commit is contained in:
@@ -538,6 +538,8 @@ CPPEditor::CPPEditor(QWidget *parent)
|
|||||||
{
|
{
|
||||||
qRegisterMetaType<SemanticInfo>("SemanticInfo");
|
qRegisterMetaType<SemanticInfo>("SemanticInfo");
|
||||||
|
|
||||||
|
m_revision = 0;
|
||||||
|
|
||||||
m_semanticHighlighter = new SemanticHighlighter(this);
|
m_semanticHighlighter = new SemanticHighlighter(this);
|
||||||
m_semanticHighlighter->start();
|
m_semanticHighlighter->start();
|
||||||
|
|
||||||
@@ -900,6 +902,8 @@ void CPPEditor::onContentsChanged(int position, int charsRemoved, int charsAdded
|
|||||||
Q_UNUSED(position)
|
Q_UNUSED(position)
|
||||||
Q_UNUSED(charsAdded)
|
Q_UNUSED(charsAdded)
|
||||||
|
|
||||||
|
++m_revision;
|
||||||
|
|
||||||
if (m_currentRenameSelection == -1)
|
if (m_currentRenameSelection == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1307,6 +1311,11 @@ Symbol *CPPEditor::findDefinition(Symbol *symbol)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned CPPEditor::revision() const
|
||||||
|
{
|
||||||
|
return m_revision;
|
||||||
|
}
|
||||||
|
|
||||||
SemanticInfo CPPEditor::semanticInfo() const
|
SemanticInfo CPPEditor::semanticInfo() const
|
||||||
{
|
{
|
||||||
return m_lastSemanticInfo;
|
return m_lastSemanticInfo;
|
||||||
@@ -1763,7 +1772,7 @@ void CPPEditor::semanticRehighlight()
|
|||||||
|
|
||||||
void CPPEditor::updateSemanticInfo(const SemanticInfo &semanticInfo)
|
void CPPEditor::updateSemanticInfo(const SemanticInfo &semanticInfo)
|
||||||
{
|
{
|
||||||
if (semanticInfo.revision != document()->revision()) {
|
if (semanticInfo.revision != m_revision) {
|
||||||
// got outdated semantic info
|
// got outdated semantic info
|
||||||
semanticRehighlight();
|
semanticRehighlight();
|
||||||
return;
|
return;
|
||||||
@@ -1807,10 +1816,10 @@ SemanticHighlighter::Source CPPEditor::currentSource()
|
|||||||
const QString fileName = file()->fileName();
|
const QString fileName = file()->fileName();
|
||||||
|
|
||||||
QString code;
|
QString code;
|
||||||
if (m_lastSemanticInfo.revision != document()->revision())
|
if (m_lastSemanticInfo.revision != m_revision)
|
||||||
code = toPlainText(); // get the source code only when needed.
|
code = toPlainText(); // get the source code only when needed.
|
||||||
|
|
||||||
const int revision = document()->revision();
|
const int revision = m_revision;
|
||||||
const SemanticHighlighter::Source source(snapshot, fileName, code,
|
const SemanticHighlighter::Source source(snapshot, fileName, code,
|
||||||
line, column, revision);
|
line, column, revision);
|
||||||
return source;
|
return source;
|
||||||
|
|||||||
@@ -84,10 +84,10 @@ public:
|
|||||||
typedef QHashIterator<CPlusPlus::Identifier *, QList<Use> > ExternalUseIterator;
|
typedef QHashIterator<CPlusPlus::Identifier *, QList<Use> > ExternalUseIterator;
|
||||||
|
|
||||||
SemanticInfo()
|
SemanticInfo()
|
||||||
: revision(-1)
|
: revision(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
int revision;
|
unsigned revision;
|
||||||
CPlusPlus::Snapshot snapshot;
|
CPlusPlus::Snapshot snapshot;
|
||||||
CPlusPlus::Document::Ptr doc;
|
CPlusPlus::Document::Ptr doc;
|
||||||
LocalUseMap localUses;
|
LocalUseMap localUses;
|
||||||
@@ -190,6 +190,7 @@ public:
|
|||||||
void indentInsertedText(const QTextCursor &tc);
|
void indentInsertedText(const QTextCursor &tc);
|
||||||
|
|
||||||
SemanticInfo semanticInfo() const;
|
SemanticInfo semanticInfo() const;
|
||||||
|
unsigned revision() const;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
virtual void setFontSettings(const TextEditor::FontSettings &);
|
virtual void setFontSettings(const TextEditor::FontSettings &);
|
||||||
@@ -295,6 +296,8 @@ private:
|
|||||||
|
|
||||||
SemanticHighlighter *m_semanticHighlighter;
|
SemanticHighlighter *m_semanticHighlighter;
|
||||||
SemanticInfo m_lastSemanticInfo;
|
SemanticInfo m_lastSemanticInfo;
|
||||||
|
|
||||||
|
unsigned m_revision;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user