forked from qt-creator/qt-creator
ClangCodeModel: Make some ClangModelManagerSupport methods static
Change-Id: Ie34a89ae01783631c6482cff8d4866595e757be5 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -158,10 +158,10 @@ void ClangGlobalSymbolFilter::prepareSearch(const QString &entry)
|
||||
m_cppFilter->prepareSearch(entry);
|
||||
QList<LanguageClient::Client *> clients;
|
||||
for (ProjectExplorer::Project * const project : ProjectExplorer::SessionManager::projects()) {
|
||||
LanguageClient::Client * const client
|
||||
= ClangModelManagerSupport::instance()->clientForProject(project);
|
||||
if (client)
|
||||
if (LanguageClient::Client * const client
|
||||
= ClangModelManagerSupport::clientForProject(project)) {
|
||||
clients << client;
|
||||
}
|
||||
}
|
||||
if (!clients.isEmpty()) {
|
||||
static_cast<LanguageClient::WorkspaceLocatorFilter *>(m_lspFilter)
|
||||
@@ -296,8 +296,8 @@ void ClangdCurrentDocumentFilter::prepareSearch(const QString &entry)
|
||||
{
|
||||
const auto doc = TextEditor::TextDocument::currentTextDocument();
|
||||
QTC_ASSERT(doc, return);
|
||||
if (const ClangdClient * const client = ClangModelManagerSupport::instance()
|
||||
->clientForFile(doc->filePath()); client && client->reachable()) {
|
||||
if (const ClangdClient * const client = ClangModelManagerSupport::clientForFile
|
||||
(doc->filePath()); client && client->reachable()) {
|
||||
d->activeFilter = &d->lspFilter;
|
||||
} else {
|
||||
d->activeFilter = d->cppFilter;
|
||||
|
||||
@@ -42,7 +42,7 @@ ClangdQuickFixFactory::ClangdQuickFixFactory() = default;
|
||||
void ClangdQuickFixFactory::match(const CppEditor::Internal::CppQuickFixInterface &interface,
|
||||
QuickFixOperations &result)
|
||||
{
|
||||
const auto client = ClangModelManagerSupport::instance()->clientForFile(interface.filePath());
|
||||
const auto client = ClangModelManagerSupport::clientForFile(interface.filePath());
|
||||
if (!client)
|
||||
return;
|
||||
|
||||
|
||||
@@ -383,10 +383,8 @@ void doSemanticHighlighting(
|
||||
}
|
||||
QMetaObject::invokeMethod(ClangModelManagerSupport::instance(),
|
||||
[filePath, virtualRanges, docRevision] {
|
||||
if (ClangdClient * const client
|
||||
= ClangModelManagerSupport::instance()->clientForFile(filePath)) {
|
||||
if (ClangdClient * const client = ClangModelManagerSupport::clientForFile(filePath))
|
||||
client->setVirtualRanges(filePath, virtualRanges, docRevision);
|
||||
}
|
||||
}, Qt::QueuedConnection);
|
||||
future.reportResults(QVector<HighlightingResult>(results.cbegin(), results.cend()));
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ ClangEditorDocumentProcessor::ClangEditorDocumentProcessor(TextEditor::TextDocum
|
||||
connect(parser().data(), &CppEditor::BaseEditorDocumentParser::projectPartInfoUpdated,
|
||||
this, &BaseEditorDocumentProcessor::projectPartInfoUpdated);
|
||||
setSemanticHighlightingChecker([this] {
|
||||
return !ClangModelManagerSupport::instance()->clientForFile(m_document.filePath());
|
||||
return !ClangModelManagerSupport::clientForFile(m_document.filePath());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ void ClangEditorDocumentProcessor::semanticRehighlight()
|
||||
};
|
||||
if (!Utils::contains(Core::EditorManager::visibleEditors(), matchesEditor))
|
||||
return;
|
||||
if (ClangModelManagerSupport::instance()->clientForFile(m_document.filePath()))
|
||||
if (ClangModelManagerSupport::clientForFile(m_document.filePath()))
|
||||
return;
|
||||
BuiltinEditorDocumentProcessor::semanticRehighlight();
|
||||
}
|
||||
|
||||
@@ -499,8 +499,7 @@ void ClangModelManagerSupport::updateLanguageClient(
|
||||
m_generatorSynchronizer.addFuture(future);
|
||||
}
|
||||
|
||||
ClangdClient *ClangModelManagerSupport::clientForProject(
|
||||
const ProjectExplorer::Project *project) const
|
||||
ClangdClient *ClangModelManagerSupport::clientForProject(const ProjectExplorer::Project *project)
|
||||
{
|
||||
const QList<Client *> clients = Utils::filtered(
|
||||
LanguageClientManager::clientsForProject(project),
|
||||
@@ -525,7 +524,7 @@ ClangdClient *ClangModelManagerSupport::clientForProject(
|
||||
return clients.empty() ? nullptr : qobject_cast<ClangdClient *>(clients.first());
|
||||
}
|
||||
|
||||
ClangdClient *ClangModelManagerSupport::clientForFile(const Utils::FilePath &file) const
|
||||
ClangdClient *ClangModelManagerSupport::clientForFile(const Utils::FilePath &file)
|
||||
{
|
||||
return qobject_cast<ClangdClient *>(LanguageClientManager::clientForFilePath(file));
|
||||
}
|
||||
|
||||
@@ -69,8 +69,8 @@ public:
|
||||
std::unique_ptr<CppEditor::AbstractOverviewModel> createOverviewModel() override;
|
||||
bool usesClangd(const TextEditor::TextDocument *document) const override;
|
||||
|
||||
ClangdClient *clientForProject(const ProjectExplorer::Project *project) const;
|
||||
ClangdClient *clientForFile(const Utils::FilePath &file) const;
|
||||
static ClangdClient *clientForProject(const ProjectExplorer::Project *project);
|
||||
static ClangdClient *clientForFile(const Utils::FilePath &file);
|
||||
|
||||
static ClangModelManagerSupport *instance();
|
||||
|
||||
|
||||
@@ -2029,7 +2029,7 @@ void ClangdTestExternalChanges::test()
|
||||
waitForSignalOrTimeout(ClangModelManagerSupport::instance(),
|
||||
&ClangModelManagerSupport::createdClient, timeOutInMs());
|
||||
QCOMPARE(client(), oldClient);
|
||||
QCOMPARE(client(), ClangModelManagerSupport::instance()->clientForProject(project()));
|
||||
QCOMPARE(client(), ClangModelManagerSupport::clientForProject(project()));
|
||||
const TextDocument * const curDoc = document("main.cpp");
|
||||
QVERIFY(curDoc);
|
||||
QVERIFY(curDoc->marks().isEmpty());
|
||||
@@ -2044,8 +2044,7 @@ void ClangdTestExternalChanges::test()
|
||||
otherSource.close();
|
||||
QVERIFY(waitForSignalOrTimeout(ClangModelManagerSupport::instance(),
|
||||
&ClangModelManagerSupport::createdClient, timeOutInMs()));
|
||||
ClangdClient * const newClient = ClangModelManagerSupport::instance()
|
||||
->clientForProject(project());
|
||||
ClangdClient * const newClient = ClangModelManagerSupport::clientForProject(project());
|
||||
QVERIFY(newClient);
|
||||
QVERIFY(newClient != oldClient);
|
||||
newClient->enableTesting();
|
||||
|
||||
Reference in New Issue
Block a user