forked from qt-creator/qt-creator
Mark the usages of a symbol using the semantic highlighter.
This commit is contained in:
@@ -737,6 +737,9 @@ CPlusPlus::Symbol *CPPEditor::findCanonicalSymbol(const QTextCursor &cursor,
|
|||||||
Document::Ptr doc,
|
Document::Ptr doc,
|
||||||
const Snapshot &snapshot) const
|
const Snapshot &snapshot) const
|
||||||
{
|
{
|
||||||
|
if (! doc)
|
||||||
|
return 0;
|
||||||
|
|
||||||
QTextCursor tc = cursor;
|
QTextCursor tc = cursor;
|
||||||
int line, col;
|
int line, col;
|
||||||
convertPosition(tc.position(), &line, &col);
|
convertPosition(tc.position(), &line, &col);
|
||||||
@@ -769,15 +772,9 @@ CPlusPlus::Symbol *CPPEditor::findCanonicalSymbol(const QTextCursor &cursor,
|
|||||||
|
|
||||||
void CPPEditor::findUsages()
|
void CPPEditor::findUsages()
|
||||||
{
|
{
|
||||||
updateSemanticInfo(m_semanticHighlighter->semanticInfo(currentSource()));
|
if (Symbol *canonicalSymbol = markSymbols()) {
|
||||||
|
|
||||||
SemanticInfo info = m_lastSemanticInfo;
|
|
||||||
|
|
||||||
if (! info.doc)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (Symbol *canonicalSymbol = findCanonicalSymbol(textCursor(), info.doc, info.snapshot))
|
|
||||||
m_modelManager->findUsages(canonicalSymbol);
|
m_modelManager->findUsages(canonicalSymbol);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPPEditor::renameUsages()
|
void CPPEditor::renameUsages()
|
||||||
@@ -790,7 +787,15 @@ void CPPEditor::renameUsages()
|
|||||||
|
|
||||||
void CPPEditor::renameUsagesNow()
|
void CPPEditor::renameUsagesNow()
|
||||||
{
|
{
|
||||||
|
if (Symbol *canonicalSymbol = markSymbols()) {
|
||||||
Core::EditorManager::instance()->hideEditorInfoBar(QLatin1String("CppEditor.Rename"));
|
Core::EditorManager::instance()->hideEditorInfoBar(QLatin1String("CppEditor.Rename"));
|
||||||
|
m_modelManager->renameUsages(canonicalSymbol);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Symbol *CPPEditor::markSymbols()
|
||||||
|
{
|
||||||
|
updateSemanticInfo(m_semanticHighlighter->semanticInfo(currentSource()));
|
||||||
|
|
||||||
m_currentRenameSelection = -1;
|
m_currentRenameSelection = -1;
|
||||||
|
|
||||||
@@ -798,8 +803,8 @@ void CPPEditor::renameUsagesNow()
|
|||||||
|
|
||||||
SemanticInfo info = m_lastSemanticInfo;
|
SemanticInfo info = m_lastSemanticInfo;
|
||||||
|
|
||||||
if (info.doc) {
|
Symbol *canonicalSymbol = findCanonicalSymbol(textCursor(), info.doc, info.snapshot);
|
||||||
if (Symbol *canonicalSymbol = findCanonicalSymbol(textCursor(), info.doc, info.snapshot)) {
|
if (canonicalSymbol) {
|
||||||
TranslationUnit *unit = info.doc->translationUnit();
|
TranslationUnit *unit = info.doc->translationUnit();
|
||||||
|
|
||||||
const QList<int> references = m_modelManager->references(canonicalSymbol, info.doc, info.snapshot);
|
const QList<int> references = m_modelManager->references(canonicalSymbol, info.doc, info.snapshot);
|
||||||
@@ -821,12 +826,10 @@ void CPPEditor::renameUsagesNow()
|
|||||||
sel.cursor = cursor;
|
sel.cursor = cursor;
|
||||||
selections.append(sel);
|
selections.append(sel);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setExtraSelections(CodeSemanticsSelection, selections);
|
setExtraSelections(CodeSemanticsSelection, selections);
|
||||||
|
return canonicalSymbol;
|
||||||
m_modelManager->renameUsages(canonicalSymbol);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPPEditor::renameSymbolUnderCursor()
|
void CPPEditor::renameSymbolUnderCursor()
|
||||||
|
|||||||
@@ -232,6 +232,7 @@ private Q_SLOTS:
|
|||||||
void updateSemanticInfo(const SemanticInfo &semanticInfo);
|
void updateSemanticInfo(const SemanticInfo &semanticInfo);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
CPlusPlus::Symbol *markSymbols();
|
||||||
bool sortedMethodOverview() const;
|
bool sortedMethodOverview() const;
|
||||||
CPlusPlus::Symbol *findDefinition(CPlusPlus::Symbol *symbol);
|
CPlusPlus::Symbol *findDefinition(CPlusPlus::Symbol *symbol);
|
||||||
virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar);
|
virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar);
|
||||||
|
|||||||
Reference in New Issue
Block a user