forked from qt-creator/qt-creator
ClangCodeModel: Add helper for retrieving ClangdClient for source file
Change-Id: I0a379e146abe65a144efb307696852de75fa14a6 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -353,6 +353,11 @@ ClangdClient *ClangModelManagerSupport::clientForProject(
|
||||
return clients.empty() ? nullptr : qobject_cast<ClangdClient *>(clients.first());
|
||||
}
|
||||
|
||||
ClangdClient *ClangModelManagerSupport::clientForFile(const Utils::FilePath &file)
|
||||
{
|
||||
return clientForProject(ProjectExplorer::SessionManager::projectForFile(file));
|
||||
}
|
||||
|
||||
ClangdClient *ClangModelManagerSupport::createClient(ProjectExplorer::Project *project,
|
||||
const Utils::FilePath &jsonDbDir)
|
||||
{
|
||||
|
||||
@@ -80,6 +80,7 @@ public:
|
||||
ClangProjectSettings &projectSettings(ProjectExplorer::Project *project) const;
|
||||
|
||||
ClangdClient *clientForProject(const ProjectExplorer::Project *project);
|
||||
ClangdClient *clientForFile(const Utils::FilePath &file);
|
||||
|
||||
static ClangModelManagerSupport *instance();
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
#include <languageclient/languageclientsymbolsupport.h>
|
||||
#include <projectexplorer/session.h>
|
||||
#include <utils/textutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -90,9 +89,8 @@ void RefactoringEngine::globalRename(const CppTools::CursorInEditor &cursor,
|
||||
CppTools::UsagesCallback &&callback,
|
||||
const QString &replacement)
|
||||
{
|
||||
ProjectExplorer::Project * const project
|
||||
= ProjectExplorer::SessionManager::projectForFile(cursor.filePath());
|
||||
ClangdClient * const client = ClangModelManagerSupport::instance()->clientForProject(project);
|
||||
ClangdClient * const client
|
||||
= ClangModelManagerSupport::instance()->clientForFile(cursor.filePath());
|
||||
if (!client || !client->isFullyIndexed()) {
|
||||
CppTools::CppModelManager::builtinRefactoringEngine()
|
||||
->globalRename(cursor, std::move(callback), replacement);
|
||||
@@ -106,9 +104,8 @@ void RefactoringEngine::globalRename(const CppTools::CursorInEditor &cursor,
|
||||
void RefactoringEngine::findUsages(const CppTools::CursorInEditor &cursor,
|
||||
CppTools::UsagesCallback &&callback) const
|
||||
{
|
||||
ProjectExplorer::Project * const project
|
||||
= ProjectExplorer::SessionManager::projectForFile(cursor.filePath());
|
||||
ClangdClient * const client = ClangModelManagerSupport::instance()->clientForProject(project);
|
||||
ClangdClient * const client
|
||||
= ClangModelManagerSupport::instance()->clientForFile(cursor.filePath());
|
||||
if (!client || !client->isFullyIndexed()) {
|
||||
CppTools::CppModelManager::builtinRefactoringEngine()
|
||||
->findUsages(cursor, std::move(callback));
|
||||
@@ -127,9 +124,8 @@ void RefactoringEngine::globalFollowSymbol(
|
||||
CppTools::SymbolFinder *symbolFinder,
|
||||
bool inNextSplit) const
|
||||
{
|
||||
ProjectExplorer::Project * const project
|
||||
= ProjectExplorer::SessionManager::projectForFile(cursor.filePath());
|
||||
ClangdClient * const client = ClangModelManagerSupport::instance()->clientForProject(project);
|
||||
ClangdClient * const client
|
||||
= ClangModelManagerSupport::instance()->clientForFile(cursor.filePath());
|
||||
if (!client || !client->isFullyIndexed()) {
|
||||
CppTools::CppModelManager::builtinRefactoringEngine()
|
||||
->globalFollowSymbol(cursor, std::move(callback), snapshot, doc, symbolFinder,
|
||||
|
||||
Reference in New Issue
Block a user