CppEditor: refactor FollowSymbol

Create an interface to get the ability to use
another FollowSymbol implementation

Change-Id: I5802f62523ff3ee47b8a14e487adf43edcb6c9b1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Ivan Donchevskii
2017-08-03 16:43:38 +02:00
parent 76d12dc2d5
commit a137b08eaa
26 changed files with 442 additions and 164 deletions

View File

@@ -129,8 +129,8 @@ public:
CppLocalRenaming m_localRenaming;
CppUseSelectionsUpdater m_useSelectionsUpdater;
QScopedPointer<FollowSymbolUnderCursor> m_followSymbolUnderCursor;
CppSelectionChanger m_cppSelectionChanger;
FollowSymbolUnderCursor m_builtinFollowSymbol;
CppRefactoringEngine m_builtinRefactoringEngine;
};
@@ -141,7 +141,6 @@ CppEditorWidgetPrivate::CppEditorWidgetPrivate(CppEditorWidget *q)
, m_declDefLinkFinder(new FunctionDeclDefLinkFinder(q))
, m_localRenaming(q)
, m_useSelectionsUpdater(q)
, m_followSymbolUnderCursor(new FollowSymbolUnderCursor(q))
, m_cppSelectionChanger()
{}
@@ -647,12 +646,23 @@ CppEditorWidget::Link CppEditorWidget::findLinkAt(const QTextCursor &cursor,
if (!d->m_modelManager)
return Link();
return d->m_followSymbolUnderCursor->findLink(cursor,
resolveTarget,
d->m_modelManager->snapshot(),
d->m_lastSemanticInfo.doc,
d->m_modelManager->symbolFinder(),
inNextSplit);
const Utils::FileName &filePath = textDocument()->filePath();
if (!resolveTarget) {
// TODO: get that part also from clang
return d->m_builtinFollowSymbol.findLink(CppTools::CursorInEditor{cursor, filePath, this},
resolveTarget,
d->m_modelManager->snapshot(),
d->m_lastSemanticInfo.doc,
d->m_modelManager->symbolFinder(),
inNextSplit);
}
return followSymbolInterface()->findLink(CppTools::CursorInEditor{cursor, filePath, this},
resolveTarget,
d->m_modelManager->snapshot(),
d->m_lastSemanticInfo.doc,
d->m_modelManager->symbolFinder(),
inNextSplit);
}
unsigned CppEditorWidget::documentRevision() const
@@ -687,6 +697,14 @@ RefactoringEngineInterface *CppEditorWidget::refactoringEngine() const
: static_cast<RefactoringEngineInterface *>(&d->m_builtinRefactoringEngine);
}
CppTools::FollowSymbolInterface *CppEditorWidget::followSymbolInterface() const
{
CppTools::FollowSymbolInterface *followSymbol
= CppTools::CppModelManager::instance()->followSymbolInterface();
return followSymbol ? followSymbol
: static_cast<CppTools::FollowSymbolInterface *>(&d->m_builtinFollowSymbol);
}
bool CppEditorWidget::isSemanticInfoValidExceptLocalUses() const
{
return d->m_lastSemanticInfo.doc && d->m_lastSemanticInfo.revision == documentRevision()
@@ -973,11 +991,6 @@ void CppEditorWidget::applyDeclDefLinkChanges(bool jumpToMatch)
updateFunctionDeclDefLink();
}
FollowSymbolUnderCursor *CppEditorWidget::followSymbolUnderCursorDelegate()
{
return d->m_followSymbolUnderCursor.data();
}
void CppEditorWidget::encourageApply()
{
if (d->m_localRenaming.encourageApply())