forked from qt-creator/qt-creator
Mark unused symbols.
This commit is contained in:
@@ -949,16 +949,22 @@ void CPPEditor::updateMethodBoxIndex()
|
|||||||
|
|
||||||
static void highlightUses(QTextDocument *doc,
|
static void highlightUses(QTextDocument *doc,
|
||||||
const QTextCharFormat &format,
|
const QTextCharFormat &format,
|
||||||
|
const QTextCharFormat &unusedFormat,
|
||||||
const QList<SemanticInfo::Use> &uses,
|
const QList<SemanticInfo::Use> &uses,
|
||||||
QList<QTextEdit::ExtraSelection> *selections)
|
QList<QTextEdit::ExtraSelection> *selections)
|
||||||
{
|
{
|
||||||
if (uses.size() <= 1)
|
bool isUnused = false;
|
||||||
return;
|
if (uses.size() == 1)
|
||||||
|
isUnused = true;
|
||||||
|
|
||||||
foreach (const SemanticInfo::Use &use, uses) {
|
foreach (const SemanticInfo::Use &use, uses) {
|
||||||
QTextEdit::ExtraSelection sel;
|
QTextEdit::ExtraSelection sel;
|
||||||
|
|
||||||
|
if (isUnused)
|
||||||
|
sel.format = unusedFormat;
|
||||||
|
else
|
||||||
sel.format = format;
|
sel.format = format;
|
||||||
|
|
||||||
sel.cursor = QTextCursor(doc);
|
sel.cursor = QTextCursor(doc);
|
||||||
|
|
||||||
const int anchor = doc->findBlockByNumber(use.line - 1).position() + use.column - 1;
|
const int anchor = doc->findBlockByNumber(use.line - 1).position() + use.column - 1;
|
||||||
@@ -1708,6 +1714,7 @@ void CPPEditor::setFontSettings(const TextEditor::FontSettings &fs)
|
|||||||
highlighter->rehighlight();
|
highlighter->rehighlight();
|
||||||
|
|
||||||
m_occurrencesFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES));
|
m_occurrencesFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES));
|
||||||
|
m_occurrencesUnusedFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES_UNUSED));
|
||||||
m_occurrenceRenameFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES_RENAME));
|
m_occurrenceRenameFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES_RENAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1786,11 +1793,9 @@ void CPPEditor::updateSemanticInfo(const SemanticInfo &semanticInfo)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! good)
|
if (uses.size() == 1 || good)
|
||||||
continue;
|
highlightUses(document(), m_occurrencesFormat, m_occurrencesUnusedFormat,
|
||||||
|
uses, &selections);
|
||||||
highlightUses(document(), m_occurrencesFormat, uses, &selections);
|
|
||||||
break; // done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setExtraSelections(CodeSemanticsSelection, selections);
|
setExtraSelections(CodeSemanticsSelection, selections);
|
||||||
|
|||||||
@@ -281,6 +281,7 @@ private:
|
|||||||
QTimer *m_updateMethodBoxTimer;
|
QTimer *m_updateMethodBoxTimer;
|
||||||
QTimer *m_updateUsesTimer;
|
QTimer *m_updateUsesTimer;
|
||||||
QTextCharFormat m_occurrencesFormat;
|
QTextCharFormat m_occurrencesFormat;
|
||||||
|
QTextCharFormat m_occurrencesUnusedFormat;
|
||||||
QTextCharFormat m_occurrenceRenameFormat;
|
QTextCharFormat m_occurrenceRenameFormat;
|
||||||
|
|
||||||
QList<QTextEdit::ExtraSelection> m_renameSelections;
|
QList<QTextEdit::ExtraSelection> m_renameSelections;
|
||||||
|
|||||||
@@ -251,6 +251,8 @@ QColor FormatDescription::foreground() const
|
|||||||
} else {
|
} else {
|
||||||
return m_format.foreground();
|
return m_format.foreground();
|
||||||
}
|
}
|
||||||
|
} else if (m_name == QLatin1String(Constants::C_OCCURRENCES_UNUSED)) {
|
||||||
|
return Qt::lightGray;
|
||||||
} else if (m_name == QLatin1String(Constants::C_PARENTHESES)) {
|
} else if (m_name == QLatin1String(Constants::C_PARENTHESES)) {
|
||||||
return QColor(Qt::red);
|
return QColor(Qt::red);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ const char * const C_PARENTHESES = "Parentheses";
|
|||||||
const char * const C_CURRENT_LINE = "CurrentLine";
|
const char * const C_CURRENT_LINE = "CurrentLine";
|
||||||
const char * const C_CURRENT_LINE_NUMBER = "CurrentLineNumber";
|
const char * const C_CURRENT_LINE_NUMBER = "CurrentLineNumber";
|
||||||
const char * const C_OCCURRENCES = "Occurrences";
|
const char * const C_OCCURRENCES = "Occurrences";
|
||||||
|
const char * const C_OCCURRENCES_UNUSED = "Occurrences.Unused";
|
||||||
const char * const C_OCCURRENCES_RENAME = "Occurrences.Rename";
|
const char * const C_OCCURRENCES_RENAME = "Occurrences.Rename";
|
||||||
|
|
||||||
const char * const C_NUMBER = "Number";
|
const char * const C_NUMBER = "Number";
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ TextEditorSettings::TextEditorSettings(QObject *parent)
|
|||||||
formatDescriptions.append(currentLineNumber);
|
formatDescriptions.append(currentLineNumber);
|
||||||
|
|
||||||
formatDescriptions.append(FormatDescription(QLatin1String(C_OCCURRENCES), tr("Occurrences")));
|
formatDescriptions.append(FormatDescription(QLatin1String(C_OCCURRENCES), tr("Occurrences")));
|
||||||
|
formatDescriptions.append(FormatDescription(QLatin1String(C_OCCURRENCES_UNUSED), tr("Unused Occurrence")));
|
||||||
formatDescriptions.append(FormatDescription(QLatin1String(C_OCCURRENCES_RENAME), tr("Renaming Occurrence")));
|
formatDescriptions.append(FormatDescription(QLatin1String(C_OCCURRENCES_RENAME), tr("Renaming Occurrence")));
|
||||||
|
|
||||||
// Standard categories
|
// Standard categories
|
||||||
|
|||||||
Reference in New Issue
Block a user