, m_inRename(false)
, m_allowSkippingOfBlockEnd(false)
{
+ m_initialized = false;
qRegisterMetaType<SemanticInfo>("SemanticInfo");
m_semanticHighlighter = new SemanticHighlighter(this);
if (doc->fileName() != file()->fileName())
return;
+ if (! m_initialized) {
+ m_initialized = true;
+
+ const SemanticHighlighter::Source source = currentSource(/*force = */ true);
+ m_semanticHighlighter->rehighlight(source);
+ }
+
m_overviewModel->rebuild(doc);
OverviewTreeView *treeView = static_cast<OverviewTreeView *>(m_methodCombo->view());
treeView->sync();
setExtraSelections(CodeSemanticsSelection, allSelections);
}
-SemanticHighlighter::Source CPPEditor::currentSource()
+SemanticHighlighter::Source CPPEditor::currentSource(bool force)
{
int line = 0, column = 0;
convertPosition(position(), &line, &column);
const QString fileName = file()->fileName();
QString code;
- if (m_lastSemanticInfo.revision != document()->revision())
+ if (force || m_lastSemanticInfo.revision != document()->revision())
code = toPlainText(); // get the source code only when needed.
const int revision = document()->revision();
- const SemanticHighlighter::Source source(snapshot, fileName, code,
- line, column, revision);
+ SemanticHighlighter::Source source(snapshot, fileName, code,
+ line, column, revision);
+ source.force = force;
return source;
}
Snapshot snapshot;
Document::Ptr doc;
- if (revision == source.revision) {
+ if (! source.force && revision == source.revision) {
m_mutex.lock();
snapshot = m_lastSemanticInfo.snapshot;
doc = m_lastSemanticInfo.doc;
m_mutex.unlock();
}
- if (!doc) {
+ if (! doc) {
const QByteArray preprocessedCode = source.snapshot.preprocessedCode(source.code, source.fileName);
snapshot = source.snapshot;
int line;
int column;
int revision;
+ bool force;
Source()
- : line(0), column(0), revision(0)
+ : line(0), column(0), revision(0), force(false)
{ }
Source(const CPlusPlus::Snapshot &snapshot,
int revision)
: snapshot(snapshot), fileName(fileName),
code(code), line(line), column(column),
- revision(revision)
+ revision(revision), force(false)
{ }
void clear()
line = 0;
column = 0;
revision = 0;
+ force = false;
}
};
TextEditor::ITextEditor *openCppEditorAt(const QString &fileName, int line,
int column = 0);
- SemanticHighlighter::Source currentSource();
+ SemanticHighlighter::Source currentSource(bool force = false);
void highlightUses(const QList<SemanticInfo::Use> &uses,
QList<QTextEdit::ExtraSelection> *selections);
SemanticHighlighter *m_semanticHighlighter;
SemanticInfo m_lastSemanticInfo;
+ bool m_initialized;
};