forked from qt-creator/qt-creator
Highlight references to macro under cursor.
Uses to be done only for symbols, implement for macros as well. Change-Id: I5403527cc8b423e7051c3ce470e2f40ad65e65d5 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
committed by
Erik Verbruggen
parent
8c3794f9d1
commit
f128a92485
@@ -833,6 +833,41 @@ void CPPEditorWidget::markSymbols(const QTextCursor &tc, const SemanticInfo &inf
|
||||
if (! info.doc)
|
||||
return;
|
||||
|
||||
if (const Macro *macro = findCanonicalMacro(textCursor(), info.doc)) {
|
||||
QList<QTextEdit::ExtraSelection> selections;
|
||||
|
||||
//Macro definition
|
||||
if (macro->fileName() == info.doc->fileName()) {
|
||||
QTextCursor cursor(document());
|
||||
cursor.setPosition(macro->offset());
|
||||
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, macro->name().length());
|
||||
|
||||
QTextEdit::ExtraSelection sel;
|
||||
sel.format = m_occurrencesFormat;
|
||||
sel.cursor = cursor;
|
||||
selections.append(sel);
|
||||
}
|
||||
|
||||
//Other macro uses
|
||||
foreach (Document::MacroUse use, info.doc->macroUses()) {
|
||||
if (use.macro().line() != macro->line()
|
||||
|| use.macro().offset() != macro->offset()
|
||||
|| use.macro().length() != macro->length()
|
||||
|| use.macro().fileName() != macro->fileName())
|
||||
continue;
|
||||
|
||||
QTextCursor cursor(document());
|
||||
cursor.setPosition(use.begin());
|
||||
cursor.setPosition(use.end(), QTextCursor::KeepAnchor);
|
||||
|
||||
QTextEdit::ExtraSelection sel;
|
||||
sel.format = m_occurrencesFormat;
|
||||
sel.cursor = cursor;
|
||||
selections.append(sel);
|
||||
}
|
||||
|
||||
setExtraSelections(CodeSemanticsSelection, selections);
|
||||
} else {
|
||||
CanonicalSymbol cs(this, info);
|
||||
QString expression;
|
||||
if (Scope *scope = cs.getScopeAndExpression(this, info, tc, &expression)) {
|
||||
@@ -848,6 +883,7 @@ void CPPEditorWidget::markSymbols(const QTextCursor &tc, const SemanticInfo &inf
|
||||
setExtraSelections(CodeSemanticsSelection, QList<QTextEdit::ExtraSelection>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPPEditorWidget::renameSymbolUnderCursor()
|
||||
{
|
||||
|
Reference in New Issue
Block a user