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());
|
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,
|
ClangdClient *ClangModelManagerSupport::createClient(ProjectExplorer::Project *project,
|
||||||
const Utils::FilePath &jsonDbDir)
|
const Utils::FilePath &jsonDbDir)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ public:
|
|||||||
ClangProjectSettings &projectSettings(ProjectExplorer::Project *project) const;
|
ClangProjectSettings &projectSettings(ProjectExplorer::Project *project) const;
|
||||||
|
|
||||||
ClangdClient *clientForProject(const ProjectExplorer::Project *project);
|
ClangdClient *clientForProject(const ProjectExplorer::Project *project);
|
||||||
|
ClangdClient *clientForFile(const Utils::FilePath &file);
|
||||||
|
|
||||||
static ClangModelManagerSupport *instance();
|
static ClangModelManagerSupport *instance();
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
#include <cpptools/cppmodelmanager.h>
|
#include <cpptools/cppmodelmanager.h>
|
||||||
#include <languageclient/languageclientsymbolsupport.h>
|
#include <languageclient/languageclientsymbolsupport.h>
|
||||||
#include <projectexplorer/session.h>
|
|
||||||
#include <utils/textutils.h>
|
#include <utils/textutils.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -90,9 +89,8 @@ void RefactoringEngine::globalRename(const CppTools::CursorInEditor &cursor,
|
|||||||
CppTools::UsagesCallback &&callback,
|
CppTools::UsagesCallback &&callback,
|
||||||
const QString &replacement)
|
const QString &replacement)
|
||||||
{
|
{
|
||||||
ProjectExplorer::Project * const project
|
ClangdClient * const client
|
||||||
= ProjectExplorer::SessionManager::projectForFile(cursor.filePath());
|
= ClangModelManagerSupport::instance()->clientForFile(cursor.filePath());
|
||||||
ClangdClient * const client = ClangModelManagerSupport::instance()->clientForProject(project);
|
|
||||||
if (!client || !client->isFullyIndexed()) {
|
if (!client || !client->isFullyIndexed()) {
|
||||||
CppTools::CppModelManager::builtinRefactoringEngine()
|
CppTools::CppModelManager::builtinRefactoringEngine()
|
||||||
->globalRename(cursor, std::move(callback), replacement);
|
->globalRename(cursor, std::move(callback), replacement);
|
||||||
@@ -106,9 +104,8 @@ void RefactoringEngine::globalRename(const CppTools::CursorInEditor &cursor,
|
|||||||
void RefactoringEngine::findUsages(const CppTools::CursorInEditor &cursor,
|
void RefactoringEngine::findUsages(const CppTools::CursorInEditor &cursor,
|
||||||
CppTools::UsagesCallback &&callback) const
|
CppTools::UsagesCallback &&callback) const
|
||||||
{
|
{
|
||||||
ProjectExplorer::Project * const project
|
ClangdClient * const client
|
||||||
= ProjectExplorer::SessionManager::projectForFile(cursor.filePath());
|
= ClangModelManagerSupport::instance()->clientForFile(cursor.filePath());
|
||||||
ClangdClient * const client = ClangModelManagerSupport::instance()->clientForProject(project);
|
|
||||||
if (!client || !client->isFullyIndexed()) {
|
if (!client || !client->isFullyIndexed()) {
|
||||||
CppTools::CppModelManager::builtinRefactoringEngine()
|
CppTools::CppModelManager::builtinRefactoringEngine()
|
||||||
->findUsages(cursor, std::move(callback));
|
->findUsages(cursor, std::move(callback));
|
||||||
@@ -127,9 +124,8 @@ void RefactoringEngine::globalFollowSymbol(
|
|||||||
CppTools::SymbolFinder *symbolFinder,
|
CppTools::SymbolFinder *symbolFinder,
|
||||||
bool inNextSplit) const
|
bool inNextSplit) const
|
||||||
{
|
{
|
||||||
ProjectExplorer::Project * const project
|
ClangdClient * const client
|
||||||
= ProjectExplorer::SessionManager::projectForFile(cursor.filePath());
|
= ClangModelManagerSupport::instance()->clientForFile(cursor.filePath());
|
||||||
ClangdClient * const client = ClangModelManagerSupport::instance()->clientForProject(project);
|
|
||||||
if (!client || !client->isFullyIndexed()) {
|
if (!client || !client->isFullyIndexed()) {
|
||||||
CppTools::CppModelManager::builtinRefactoringEngine()
|
CppTools::CppModelManager::builtinRefactoringEngine()
|
||||||
->globalFollowSymbol(cursor, std::move(callback), snapshot, doc, symbolFinder,
|
->globalFollowSymbol(cursor, std::move(callback), snapshot, doc, symbolFinder,
|
||||||
|
|||||||
Reference in New Issue
Block a user