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