Commit 6051584c authored by Roberto Raggi's avatar Roberto Raggi

Don't create selections for unused symbols

parent 9cb9f29d
......@@ -947,29 +947,27 @@ void CPPEditor::updateMethodBoxIndex()
m_updateMethodBoxTimer->start(UPDATE_METHOD_BOX_INTERVAL);
}
static void highlightUses(QTextDocument *doc,
const QTextCharFormat &format,
const QTextCharFormat &unusedFormat,
const QList<SemanticInfo::Use> &uses,
QList<QTextEdit::ExtraSelection> *selections)
void CPPEditor::highlightUses(const QList<SemanticInfo::Use> &uses,
QList<QTextEdit::ExtraSelection> *selections)
{
bool isUnused = false;
if (uses.size() == 1)
if (uses.size() == 1) {
isUnused = true;
return; // ###
}
foreach (const SemanticInfo::Use &use, uses) {
QTextEdit::ExtraSelection sel;
if (isUnused)
sel.format = unusedFormat;
sel.format = m_occurrencesUnusedFormat;
else
sel.format = format;
sel.cursor = QTextCursor(doc);
sel.format = m_occurrencesFormat;
const int anchor = doc->findBlockByNumber(use.line - 1).position() + use.column - 1;
const int anchor = document()->findBlockByNumber(use.line - 1).position() + use.column - 1;
const int position = anchor + use.length;
sel.cursor = QTextCursor(document());
sel.cursor.setPosition(anchor);
sel.cursor.setPosition(position, QTextCursor::KeepAnchor);
......@@ -1794,8 +1792,7 @@ void CPPEditor::updateSemanticInfo(const SemanticInfo &semanticInfo)
}
if (uses.size() == 1 || good)
highlightUses(document(), m_occurrencesFormat, m_occurrencesUnusedFormat,
uses, &selections);
highlightUses(uses, &selections);
}
setExtraSelections(CodeSemanticsSelection, selections);
......
......@@ -252,6 +252,9 @@ private:
SemanticHighlighter::Source currentSource();
void highlightUses(const QList<SemanticInfo::Use> &uses,
QList<QTextEdit::ExtraSelection> *selections);
void createToolBar(CPPEditorEditable *editable);
enum EditOperation {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment