Clang: add globalFollowSymbol to RefactoringEngine

Allows to follow outside of current TU.

Change-Id: Ieea2fd72bfdf6d60a988b40efcf2f41c5a71d045
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Ivan Donchevskii
2017-10-05 09:54:21 +02:00
parent c760804102
commit 7a7123b1bc
27 changed files with 133 additions and 265 deletions

View File

@@ -35,6 +35,7 @@
#include <clangsupport/filepathcachinginterface.h>
#include <utils/algorithm.h>
#include <utils/textutils.h>
#include <QTextCursor>
@@ -115,6 +116,24 @@ void RefactoringEngine::findUsages(const CppTools::CursorInEditor &data,
showUsagesCallback(locationsAt(data));
}
RefactoringEngine::Link RefactoringEngine::globalFollowSymbol(const CppTools::CursorInEditor &data,
const CPlusPlus::Snapshot &,
const CPlusPlus::Document::Ptr &,
CppTools::SymbolFinder *,
bool) const
{
// TODO: replace that with specific followSymbol query
const CppTools::Usages usages = locationsAt(data);
CppTools::Usage usage = Utils::findOrDefault(usages, [&data](const CppTools::Usage &usage) {
// We've already searched in the current file, skip it.
if (usage.path == data.filePath().toString())
return false;
return true;
});
return Link(usage.path, usage.line, usage.column);
}
bool RefactoringEngine::isRefactoringEngineAvailable() const
{
return m_server.isAvailable();