forked from qt-creator/qt-creator
LanguageClient: set the client info in initialize params
Change-Id: If7be38a9bd8f7bae0d2a4263a5a6bf7d2c7e34a9 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -53,6 +53,19 @@ private:
|
||||
Values m_value = off;
|
||||
};
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT ClientInfo : public JsonObject
|
||||
{
|
||||
public:
|
||||
using JsonObject::JsonObject;
|
||||
|
||||
QString name() const { return typedValue<QString>(nameKey); }
|
||||
void setName(const QString &name) { insert(nameKey, name); }
|
||||
|
||||
Utils::optional<QString> version() const { return optionalValue<QString>(versionKey); }
|
||||
void setVersion(const QString &version) { insert(versionKey, version); }
|
||||
void clearVersion() { remove(versionKey); }
|
||||
};
|
||||
|
||||
class LANGUAGESERVERPROTOCOL_EXPORT InitializeParams : public JsonObject
|
||||
{
|
||||
public:
|
||||
@@ -120,6 +133,10 @@ public:
|
||||
{ insert(workspaceFoldersKey, folders.toJson()); }
|
||||
void clearWorkSpaceFolders() { remove(workspaceFoldersKey); }
|
||||
|
||||
Utils::optional<ClientInfo> clientInfo() const { return optionalValue<ClientInfo>(clientInfoKey); }
|
||||
void setClientInfo(const ClientInfo &clientInfo) { insert(clientInfoKey, clientInfo); }
|
||||
void clearClientInfo() { remove(clientInfoKey); }
|
||||
|
||||
bool isValid() const override
|
||||
{ return contains(processIdKey) && contains(rootUriKey) && contains(capabilitiesKey); }
|
||||
};
|
||||
|
||||
@@ -46,6 +46,7 @@ constexpr char changeNotificationsKey[] = "changeNotifications";
|
||||
constexpr char changesKey[] = "changes";
|
||||
constexpr char characterKey[] = "character";
|
||||
constexpr char childrenKey[] = "children";
|
||||
constexpr char clientInfoKey[] = "clientInfo";
|
||||
constexpr char codeActionKey[] = "codeAction";
|
||||
constexpr char codeActionKindKey[] = "codeActionKind";
|
||||
constexpr char codeActionKindsKey[] = "codeActionKinds";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
add_qtc_plugin(LanguageClient
|
||||
PUBLIC_DEPENDS LanguageServerProtocol Qt5::Core
|
||||
PUBLIC_DEPENDS LanguageServerProtocol Qt5::Core app_version
|
||||
PLUGIN_DEPENDS ProjectExplorer Core TextEditor
|
||||
SOURCES
|
||||
client.cpp client.h
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include "languageclientutils.h"
|
||||
#include "semantichighlightsupport.h"
|
||||
|
||||
#include <app/app_version.h>
|
||||
|
||||
#include <coreplugin/editormanager/documentmodel.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
@@ -87,6 +89,10 @@ Client::Client(BaseClientInterface *clientInterface)
|
||||
, m_tokenSupport(this)
|
||||
{
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
m_clientInfo.setName(Core::Constants::IDE_DISPLAY_NAME);
|
||||
m_clientInfo.setVersion(Core::Constants::IDE_VERSION_DISPLAY);
|
||||
|
||||
m_clientProviders.completionAssistProvider = new LanguageClientCompletionAssistProvider(this);
|
||||
m_clientProviders.functionHintProvider = new FunctionHintAssistProvider(this);
|
||||
m_clientProviders.quickFixAssistProvider = new LanguageClientQuickFixProvider(this);
|
||||
@@ -299,6 +305,7 @@ void Client::initialize()
|
||||
QTC_ASSERT(m_state == Uninitialized, return);
|
||||
qCDebug(LOGLSPCLIENT) << "initializing language server " << m_displayName;
|
||||
InitializeParams params;
|
||||
params.setClientInfo(m_clientInfo);
|
||||
params.setCapabilities(m_clientCapabilities);
|
||||
params.setInitializationOptions(m_initializationOptions);
|
||||
if (m_project)
|
||||
@@ -356,6 +363,11 @@ QString Client::stateString() const
|
||||
return {};
|
||||
}
|
||||
|
||||
void Client::setClientInfo(const LanguageServerProtocol::ClientInfo &clientInfo)
|
||||
{
|
||||
m_clientInfo = clientInfo;
|
||||
}
|
||||
|
||||
ClientCapabilities Client::defaultClientCapabilities()
|
||||
{
|
||||
return generateClientCapabilities();
|
||||
|
||||
@@ -123,6 +123,7 @@ public:
|
||||
QString stateString() const;
|
||||
bool reachable() const { return m_state == Initialized; }
|
||||
|
||||
void setClientInfo(const LanguageServerProtocol::ClientInfo &clientInfo);
|
||||
// capabilities
|
||||
static LanguageServerProtocol::ClientCapabilities defaultClientCapabilities();
|
||||
void setClientCapabilities(const LanguageServerProtocol::ClientCapabilities &caps);
|
||||
@@ -317,6 +318,7 @@ private:
|
||||
bool m_locatorsEnabled = true;
|
||||
bool m_autoRequestCodeActions = true;
|
||||
QTimer m_shutdownTimer;
|
||||
LanguageServerProtocol::ClientInfo m_clientInfo;
|
||||
};
|
||||
|
||||
} // namespace LanguageClient
|
||||
|
||||
@@ -17,6 +17,8 @@ QtcPlugin {
|
||||
Depends { name: "Core" }
|
||||
Depends { name: "TextEditor" }
|
||||
|
||||
Depends { name: "app_version_header" }
|
||||
|
||||
files: [
|
||||
"client.cpp",
|
||||
"client.h",
|
||||
|
||||
Reference in New Issue
Block a user