Commit db9a390e authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Highlight unused symbols.

parent 64ccdc7e
......@@ -908,7 +908,6 @@ void CPPEditor::renameSymbolUnderCursor()
QTextCursor c = textCursor();
m_currentRenameSelection = -1;
m_renameSelections = extraSelections(CodeSemanticsSelection);
for (int i = 0; i < m_renameSelections.size(); ++i) {
QTextEdit::ExtraSelection s = m_renameSelections.at(i);
if (c.position() >= s.cursor.anchor()
......@@ -980,10 +979,9 @@ 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;
......@@ -1882,7 +1880,6 @@ void CPPEditor::setFontSettings(const TextEditor::FontSettings &fs)
// only set the background, we do not want to modify foreground properties set by the syntax highlighter or the link
m_occurrencesFormat.clearForeground();
m_occurrencesUnusedFormat.clearForeground();
m_occurrenceRenameFormat.clearForeground();
}
......@@ -1944,7 +1941,9 @@ void CPPEditor::updateSemanticInfo(const SemanticInfo &semanticInfo)
int line = 0, column = 0;
convertPosition(position(), &line, &column);
QList<QTextEdit::ExtraSelection> selections;
QList<QTextEdit::ExtraSelection> allSelections;
m_renameSelections.clear();
SemanticInfo::LocalUseIterator it(semanticInfo.localUses);
while (it.hasNext()) {
......@@ -1961,11 +1960,18 @@ void CPPEditor::updateSemanticInfo(const SemanticInfo &semanticInfo)
}
}
if (uses.size() == 1 || good)
if (uses.size() == 1) {
// it's an unused declaration
highlightUses(uses, &allSelections);
} else if (good) {
QList<QTextEdit::ExtraSelection> selections;
highlightUses(uses, &selections);
m_renameSelections += selections;
allSelections += selections;
}
}
setExtraSelections(CodeSemanticsSelection, selections);
setExtraSelections(CodeSemanticsSelection, allSelections);
}
SemanticHighlighter::Source CPPEditor::currentSource()
......
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