forked from qt-creator/qt-creator
ClangCodeModel: Provide tooltips via clangd
Note that we temporarily lose the ability to hover over an include and get the full path of the header file. This is a valuable feature that we need to restore, preferably by fixing clangd itself. Fixing the remaining few test failures would likely require more complicated code as well as additional LSP round-trips, and as of now I'm not convinced it is worth the effort. Change-Id: I08c72c4bd1268bbd67baeb57bbfd29d9b11303a5 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -25,14 +25,21 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "languageclient_global.h"
|
||||
|
||||
#include <languageserverprotocol/languagefeatures.h>
|
||||
#include <texteditor/basehoverhandler.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace LanguageClient {
|
||||
|
||||
class Client;
|
||||
|
||||
class HoverHandler final : public TextEditor::BaseHoverHandler
|
||||
using HelpItemProvider = std::function<void(const LanguageServerProtocol::HoverRequest::Response &,
|
||||
const LanguageServerProtocol::DocumentUri &uri)>;
|
||||
|
||||
class LANGUAGECLIENT_EXPORT HoverHandler final : public TextEditor::BaseHoverHandler
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(HoverHandler)
|
||||
public:
|
||||
@@ -41,6 +48,9 @@ public:
|
||||
|
||||
void abort() override;
|
||||
|
||||
void setHelpItemProvider(const HelpItemProvider &provider) { m_helpItemProvider = provider; }
|
||||
void setHelpItem(const LanguageServerProtocol::MessageId &msgId, const Core::HelpItem &help);
|
||||
|
||||
protected:
|
||||
void identifyMatch(TextEditor::TextEditorWidget *editorWidget,
|
||||
int pos,
|
||||
@@ -52,7 +62,10 @@ private:
|
||||
|
||||
QPointer<Client> m_client;
|
||||
Utils::optional<LanguageServerProtocol::MessageId> m_currentRequest;
|
||||
LanguageServerProtocol::DocumentUri m_uri;
|
||||
LanguageServerProtocol::HoverRequest::Response m_response;
|
||||
TextEditor::BaseHoverHandler::ReportPriority m_report;
|
||||
HelpItemProvider m_helpItemProvider;
|
||||
};
|
||||
|
||||
} // namespace LanguageClient
|
||||
|
||||
Reference in New Issue
Block a user