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;
|
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
|
class LANGUAGESERVERPROTOCOL_EXPORT InitializeParams : public JsonObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -120,6 +133,10 @@ public:
|
|||||||
{ insert(workspaceFoldersKey, folders.toJson()); }
|
{ insert(workspaceFoldersKey, folders.toJson()); }
|
||||||
void clearWorkSpaceFolders() { remove(workspaceFoldersKey); }
|
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
|
bool isValid() const override
|
||||||
{ return contains(processIdKey) && contains(rootUriKey) && contains(capabilitiesKey); }
|
{ return contains(processIdKey) && contains(rootUriKey) && contains(capabilitiesKey); }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ constexpr char changeNotificationsKey[] = "changeNotifications";
|
|||||||
constexpr char changesKey[] = "changes";
|
constexpr char changesKey[] = "changes";
|
||||||
constexpr char characterKey[] = "character";
|
constexpr char characterKey[] = "character";
|
||||||
constexpr char childrenKey[] = "children";
|
constexpr char childrenKey[] = "children";
|
||||||
|
constexpr char clientInfoKey[] = "clientInfo";
|
||||||
constexpr char codeActionKey[] = "codeAction";
|
constexpr char codeActionKey[] = "codeAction";
|
||||||
constexpr char codeActionKindKey[] = "codeActionKind";
|
constexpr char codeActionKindKey[] = "codeActionKind";
|
||||||
constexpr char codeActionKindsKey[] = "codeActionKinds";
|
constexpr char codeActionKindsKey[] = "codeActionKinds";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
add_qtc_plugin(LanguageClient
|
add_qtc_plugin(LanguageClient
|
||||||
PUBLIC_DEPENDS LanguageServerProtocol Qt5::Core
|
PUBLIC_DEPENDS LanguageServerProtocol Qt5::Core app_version
|
||||||
PLUGIN_DEPENDS ProjectExplorer Core TextEditor
|
PLUGIN_DEPENDS ProjectExplorer Core TextEditor
|
||||||
SOURCES
|
SOURCES
|
||||||
client.cpp client.h
|
client.cpp client.h
|
||||||
|
|||||||
@@ -30,6 +30,8 @@
|
|||||||
#include "languageclientutils.h"
|
#include "languageclientutils.h"
|
||||||
#include "semantichighlightsupport.h"
|
#include "semantichighlightsupport.h"
|
||||||
|
|
||||||
|
#include <app/app_version.h>
|
||||||
|
|
||||||
#include <coreplugin/editormanager/documentmodel.h>
|
#include <coreplugin/editormanager/documentmodel.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/idocument.h>
|
#include <coreplugin/idocument.h>
|
||||||
@@ -87,6 +89,10 @@ Client::Client(BaseClientInterface *clientInterface)
|
|||||||
, m_tokenSupport(this)
|
, m_tokenSupport(this)
|
||||||
{
|
{
|
||||||
using namespace ProjectExplorer;
|
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.completionAssistProvider = new LanguageClientCompletionAssistProvider(this);
|
||||||
m_clientProviders.functionHintProvider = new FunctionHintAssistProvider(this);
|
m_clientProviders.functionHintProvider = new FunctionHintAssistProvider(this);
|
||||||
m_clientProviders.quickFixAssistProvider = new LanguageClientQuickFixProvider(this);
|
m_clientProviders.quickFixAssistProvider = new LanguageClientQuickFixProvider(this);
|
||||||
@@ -299,6 +305,7 @@ void Client::initialize()
|
|||||||
QTC_ASSERT(m_state == Uninitialized, return);
|
QTC_ASSERT(m_state == Uninitialized, return);
|
||||||
qCDebug(LOGLSPCLIENT) << "initializing language server " << m_displayName;
|
qCDebug(LOGLSPCLIENT) << "initializing language server " << m_displayName;
|
||||||
InitializeParams params;
|
InitializeParams params;
|
||||||
|
params.setClientInfo(m_clientInfo);
|
||||||
params.setCapabilities(m_clientCapabilities);
|
params.setCapabilities(m_clientCapabilities);
|
||||||
params.setInitializationOptions(m_initializationOptions);
|
params.setInitializationOptions(m_initializationOptions);
|
||||||
if (m_project)
|
if (m_project)
|
||||||
@@ -356,6 +363,11 @@ QString Client::stateString() const
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::setClientInfo(const LanguageServerProtocol::ClientInfo &clientInfo)
|
||||||
|
{
|
||||||
|
m_clientInfo = clientInfo;
|
||||||
|
}
|
||||||
|
|
||||||
ClientCapabilities Client::defaultClientCapabilities()
|
ClientCapabilities Client::defaultClientCapabilities()
|
||||||
{
|
{
|
||||||
return generateClientCapabilities();
|
return generateClientCapabilities();
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ public:
|
|||||||
QString stateString() const;
|
QString stateString() const;
|
||||||
bool reachable() const { return m_state == Initialized; }
|
bool reachable() const { return m_state == Initialized; }
|
||||||
|
|
||||||
|
void setClientInfo(const LanguageServerProtocol::ClientInfo &clientInfo);
|
||||||
// capabilities
|
// capabilities
|
||||||
static LanguageServerProtocol::ClientCapabilities defaultClientCapabilities();
|
static LanguageServerProtocol::ClientCapabilities defaultClientCapabilities();
|
||||||
void setClientCapabilities(const LanguageServerProtocol::ClientCapabilities &caps);
|
void setClientCapabilities(const LanguageServerProtocol::ClientCapabilities &caps);
|
||||||
@@ -317,6 +318,7 @@ private:
|
|||||||
bool m_locatorsEnabled = true;
|
bool m_locatorsEnabled = true;
|
||||||
bool m_autoRequestCodeActions = true;
|
bool m_autoRequestCodeActions = true;
|
||||||
QTimer m_shutdownTimer;
|
QTimer m_shutdownTimer;
|
||||||
|
LanguageServerProtocol::ClientInfo m_clientInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace LanguageClient
|
} // namespace LanguageClient
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ QtcPlugin {
|
|||||||
Depends { name: "Core" }
|
Depends { name: "Core" }
|
||||||
Depends { name: "TextEditor" }
|
Depends { name: "TextEditor" }
|
||||||
|
|
||||||
|
Depends { name: "app_version_header" }
|
||||||
|
|
||||||
files: [
|
files: [
|
||||||
"client.cpp",
|
"client.cpp",
|
||||||
"client.h",
|
"client.h",
|
||||||
|
|||||||
Reference in New Issue
Block a user