forked from qt-creator/qt-creator
LanguageClient/ClangCodeModel: Reimplement matchers()
Don't assert when ClientRequestTask::preStartCheck() failed. Change-Id: I157fe8fc15aa055b70823d6a54454c6eec692f88 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -47,6 +47,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: Remove this class, it's used only internally by ClangGlobalSymbolFilter
|
||||
class LspWorkspaceFilter : public WorkspaceLocatorFilter
|
||||
{
|
||||
public:
|
||||
@@ -81,6 +82,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: Remove this class, it's used only internally by ClangClassesFilter
|
||||
class LspClassesFilter : public WorkspaceClassLocatorFilter
|
||||
{
|
||||
public:
|
||||
@@ -114,6 +116,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: Remove this class, it's used only internally by ClangFunctionsFilter
|
||||
class LspFunctionsFilter : public WorkspaceMethodLocatorFilter
|
||||
{
|
||||
public:
|
||||
@@ -156,6 +159,13 @@ ClangGlobalSymbolFilter::~ClangGlobalSymbolFilter()
|
||||
delete m_lspFilter;
|
||||
}
|
||||
|
||||
LocatorMatcherTasks ClangGlobalSymbolFilter::matchers()
|
||||
{
|
||||
return CppEditor::cppMatchers(MatcherType::AllSymbols)
|
||||
+ LanguageClient::workspaceMatchers(MatcherType::AllSymbols,
|
||||
ClangModelManagerSupport::clientsForOpenProjects(), MaxResultCount);
|
||||
}
|
||||
|
||||
void ClangGlobalSymbolFilter::prepareSearch(const QString &entry)
|
||||
{
|
||||
m_cppFilter->prepareSearch(entry);
|
||||
@@ -178,6 +188,13 @@ ClangClassesFilter::ClangClassesFilter()
|
||||
setDefaultIncludedByDefault(false);
|
||||
}
|
||||
|
||||
LocatorMatcherTasks ClangClassesFilter::matchers()
|
||||
{
|
||||
return CppEditor::cppMatchers(MatcherType::Classes)
|
||||
+ LanguageClient::workspaceMatchers(MatcherType::Classes,
|
||||
ClangModelManagerSupport::clientsForOpenProjects(), MaxResultCount);
|
||||
}
|
||||
|
||||
ClangFunctionsFilter::ClangFunctionsFilter()
|
||||
: ClangGlobalSymbolFilter(new CppFunctionsFilter, new LspFunctionsFilter)
|
||||
{
|
||||
@@ -188,6 +205,13 @@ ClangFunctionsFilter::ClangFunctionsFilter()
|
||||
setDefaultIncludedByDefault(false);
|
||||
}
|
||||
|
||||
LocatorMatcherTasks ClangFunctionsFilter::matchers()
|
||||
{
|
||||
return CppEditor::cppMatchers(MatcherType::Functions)
|
||||
+ LanguageClient::workspaceMatchers(MatcherType::Functions,
|
||||
ClangModelManagerSupport::clientsForOpenProjects(), MaxResultCount);
|
||||
}
|
||||
|
||||
class LspCurrentDocumentFilter : public DocumentLocatorFilter
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
~ClangGlobalSymbolFilter() override;
|
||||
|
||||
private:
|
||||
Core::LocatorMatcherTasks matchers() override;
|
||||
void prepareSearch(const QString &entry) override;
|
||||
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
|
||||
const QString &entry) override;
|
||||
@@ -26,16 +27,24 @@ private:
|
||||
Core::ILocatorFilter * const m_lspFilter;
|
||||
};
|
||||
|
||||
// TODO: Don't derive, flatten the hierarchy
|
||||
class ClangClassesFilter : public ClangGlobalSymbolFilter
|
||||
{
|
||||
public:
|
||||
ClangClassesFilter();
|
||||
|
||||
private:
|
||||
Core::LocatorMatcherTasks matchers() final;
|
||||
};
|
||||
|
||||
// TODO: Don't derive, flatten the hierarchy
|
||||
class ClangFunctionsFilter : public ClangGlobalSymbolFilter
|
||||
{
|
||||
public:
|
||||
ClangFunctionsFilter();
|
||||
|
||||
private:
|
||||
Core::LocatorMatcherTasks matchers() final;
|
||||
};
|
||||
|
||||
class ClangdCurrentDocumentFilter : public Core::ILocatorFilter
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
namespace LanguageClient {
|
||||
|
||||
|
||||
template <typename Request>
|
||||
class LANGUAGECLIENT_EXPORT ClientRequestTask
|
||||
{
|
||||
@@ -32,8 +31,10 @@ public:
|
||||
void start()
|
||||
{
|
||||
QTC_ASSERT(!isRunning(), return);
|
||||
QTC_ASSERT(preStartCheck(), m_callback({}); return);
|
||||
|
||||
if (!preStartCheck()) {
|
||||
m_callback({});
|
||||
return;
|
||||
}
|
||||
Request request(m_params);
|
||||
request.setResponseCallback([this](const typename Request::Response &response) {
|
||||
m_response = response;
|
||||
|
||||
@@ -301,6 +301,12 @@ WorkspaceLocatorFilter::WorkspaceLocatorFilter()
|
||||
: WorkspaceLocatorFilter(QVector<SymbolKind>())
|
||||
{}
|
||||
|
||||
LocatorMatcherTasks WorkspaceLocatorFilter::matchers()
|
||||
{
|
||||
return workspaceMatchers(MatcherType::AllSymbols,
|
||||
Utils::filtered(LanguageClientManager::clients(), &Client::locatorsEnabled));
|
||||
}
|
||||
|
||||
WorkspaceLocatorFilter::WorkspaceLocatorFilter(const QVector<SymbolKind> &filter)
|
||||
: m_filterKinds(filter)
|
||||
{
|
||||
@@ -407,6 +413,12 @@ WorkspaceClassLocatorFilter::WorkspaceClassLocatorFilter()
|
||||
setDefaultShortcutString("c");
|
||||
}
|
||||
|
||||
LocatorMatcherTasks WorkspaceClassLocatorFilter::matchers()
|
||||
{
|
||||
return workspaceMatchers(MatcherType::Classes,
|
||||
Utils::filtered(LanguageClientManager::clients(), &Client::locatorsEnabled));
|
||||
}
|
||||
|
||||
WorkspaceMethodLocatorFilter::WorkspaceMethodLocatorFilter()
|
||||
: WorkspaceLocatorFilter({SymbolKind::Method, SymbolKind::Function, SymbolKind::Constructor})
|
||||
{
|
||||
@@ -416,4 +428,10 @@ WorkspaceMethodLocatorFilter::WorkspaceMethodLocatorFilter()
|
||||
setDefaultShortcutString("m");
|
||||
}
|
||||
|
||||
LocatorMatcherTasks WorkspaceMethodLocatorFilter::matchers()
|
||||
{
|
||||
return workspaceMatchers(MatcherType::Functions,
|
||||
Utils::filtered(LanguageClientManager::clients(), &Client::locatorsEnabled));
|
||||
}
|
||||
|
||||
} // namespace LanguageClient
|
||||
|
||||
@@ -85,6 +85,7 @@ protected:
|
||||
void setMaxResultCount(qint64 limit) { m_maxResultCount = limit; }
|
||||
|
||||
private:
|
||||
Core::LocatorMatcherTasks matchers() override;
|
||||
void handleResponse(Client *client,
|
||||
const LanguageServerProtocol::WorkspaceSymbolRequest::Response &response);
|
||||
|
||||
@@ -102,16 +103,24 @@ private:
|
||||
qint64 m_maxResultCount = 0;
|
||||
};
|
||||
|
||||
// TODO: Don't derive, flatten the hierarchy
|
||||
class LANGUAGECLIENT_EXPORT WorkspaceClassLocatorFilter : public WorkspaceLocatorFilter
|
||||
{
|
||||
public:
|
||||
WorkspaceClassLocatorFilter();
|
||||
|
||||
private:
|
||||
Core::LocatorMatcherTasks matchers() final;
|
||||
};
|
||||
|
||||
// TODO: Don't derive, flatten the hierarchy
|
||||
class LANGUAGECLIENT_EXPORT WorkspaceMethodLocatorFilter : public WorkspaceLocatorFilter
|
||||
{
|
||||
public:
|
||||
WorkspaceMethodLocatorFilter();
|
||||
|
||||
private:
|
||||
Core::LocatorMatcherTasks matchers() final;
|
||||
};
|
||||
|
||||
} // namespace LanguageClient
|
||||
|
||||
Reference in New Issue
Block a user