LanguageClient: Add option to always send hover requests

Even if we already have a diangostic visible at this location. This is
used in the coco server to display additional information inside the
coverage browser.

Change-Id: I0d75f2e9f469ebdf6df7d6948a8e3e6b0cc58969
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2022-05-16 14:36:06 +02:00
parent a802a633f6
commit 94e2fa7df0
3 changed files with 40 additions and 15 deletions

View File

@@ -48,6 +48,13 @@ public:
void abort() override;
/// If prefer diagnostics is enabled the hover handler checks whether a diagnostics is at the
/// pos passed to identifyMatch _before_ sending hover request to the server. If a diagnostic
/// can be found it will be used as a tooltip and no hover request is sent to the server.
/// If prefer diagnostics is disabled the diagnostics are only checked if the response is empty.
/// Defaults to prefer diagnostics.
void setPreferDiagnosticts(bool prefer);
void setHelpItemProvider(const HelpItemProvider &provider) { m_helpItemProvider = provider; }
void setHelpItem(const LanguageServerProtocol::MessageId &msgId, const Core::HelpItem &help);
@@ -57,8 +64,10 @@ protected:
ReportPriority report) override;
private:
void handleResponse(const LanguageServerProtocol::HoverRequest::Response &response);
void handleResponse(const LanguageServerProtocol::HoverRequest::Response &response,
const QTextCursor &cursor);
void setContent(const LanguageServerProtocol::HoverContent &content);
bool reportDiagnostics(const QTextCursor &cursor);
QPointer<Client> m_client;
Utils::optional<LanguageServerProtocol::MessageId> m_currentRequest;
@@ -66,6 +75,7 @@ private:
LanguageServerProtocol::HoverRequest::Response m_response;
TextEditor::BaseHoverHandler::ReportPriority m_report;
HelpItemProvider m_helpItemProvider;
bool m_preferDiagnostics = true;
};
} // namespace LanguageClient