1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
|
#pragma once
#include <string>
#include <boost/optional.hpp>
#include "LibLsp/JsonRpc/RequestInMessage.h"
#include "LibLsp/lsp/lsDocumentUri.h"
#include "LibLsp/lsp/lsAny.h"
#include "LibLsp/JsonRpc/NotificationInMessage.h"
#include "LibLsp/lsp/general/InitializeParams.h"
struct LintRule
{
std::string key;
std::string name;
std::string Display() const
{
return name + " (" + key + ")";
}
bool activeByDefault = true;
boost::optional<std::string> severity;
boost::optional<std::string> type;
int icon_index = -1;
MAKE_SWAP_METHOD(LintRule, key, name, activeByDefault, severity, type);
};
MAKE_REFLECT_STRUCT(LintRule, key, name, activeByDefault, severity, type);
struct RuleParameter {
std::string name;
boost::optional<std::string> description;
boost::optional<std::string> defaultValue;
};
MAKE_REFLECT_STRUCT(RuleParameter, name, description, defaultValue);
struct ShowRuleDescriptionParams {
boost::optional<std::string> key;
boost::optional<std::string> name;
boost::optional<std::string> htmlDescription;
boost::optional<std::string> type;
boost::optional<std::string> severity;
boost::optional< std::vector<RuleParameter> > parameters;
MAKE_SWAP_METHOD(ShowRuleDescriptionParams, key, name, htmlDescription, type, severity, parameters)
};
MAKE_REFLECT_STRUCT(ShowRuleDescriptionParams, key, name, htmlDescription, type, severity, parameters);
struct GetJavaConfigResponse {
std::string projectRoot;
std::string sourceLevel;
std::vector<std::string> classpath;
bool isTest;
std::string vmLocation;
MAKE_SWAP_METHOD(GetJavaConfigResponse, projectRoot, sourceLevel, classpath, isTest, vmLocation);
};
MAKE_REFLECT_STRUCT(GetJavaConfigResponse, projectRoot, sourceLevel, classpath, isTest, vmLocation);
struct SetTraceNotificationParams {
lsInitializeParams::lsTrace value;
};
MAKE_REFLECT_STRUCT(SetTraceNotificationParams, value);
struct ServerConnectionSettings {
std::string SONARCLOUD_URL = "https://sonarcloud.io";
std::vector<std::string>SONARCLOUD_ALIAS = { "https://sonarqube.com",
"https://www.sonarqube.com",
"https://www.sonarcloud.io",
"https://sonarcloud.io" };
std::string connectionId;
std::string serverUrl;
std::string token;
boost::optional<std::string> organizationKey;
MAKE_SWAP_METHOD(ServerConnectionSettings, connectionId, serverUrl, token, organizationKey)
};
MAKE_REFLECT_STRUCT(ServerConnectionSettings, connectionId, serverUrl, token, organizationKey)
struct RuleSetting
{
bool IsOn();
std::string level = "on";
RuleSetting(bool activate);
RuleSetting() = default;
void toggle();
void on()
{
level = "on";
}
void off()
{
level = "off";
}
void turn(bool activate)
{
if (activate)
{
on();
}
else
{
off();
}
}
boost::optional< std::map<std::string, std::string > > parameters;
};
MAKE_REFLECT_STRUCT(RuleSetting, level, parameters)
struct ConsoleParams
{
boost::optional < bool >showAnalyzerLogs;
boost::optional < bool >showVerboseLogs;
MAKE_SWAP_METHOD(ConsoleParams, showAnalyzerLogs, showVerboseLogs)
};
MAKE_REFLECT_STRUCT(ConsoleParams, showAnalyzerLogs, showVerboseLogs)
struct SonarLintWorkspaceSettings
{
boost::optional < bool > disableTelemetry;
boost::optional < std::map<std::string, ServerConnectionSettings> >connectedMode;
boost::optional<std::map<std::string, RuleSetting>> rules;
boost::optional<ConsoleParams> output;
boost::optional<std::string > pathToNodeExecutable;
boost::optional< std::map<std::string, std::string > > getConfigurationParameters(const std::string& ruleKey);
};
MAKE_REFLECT_STRUCT(SonarLintWorkspaceSettings, disableTelemetry, connectedMode,
rules, output, pathToNodeExecutable)
DEFINE_REQUEST_RESPONSE_TYPE(slls_listAllRules, JsonNull, lsp::Any, "sonarlint/listAllRules");
DEFINE_NOTIFICATION_TYPE(Notify_didClasspathUpdate, lsDocumentUri, "sonarlint/didClasspathUpdate")
DEFINE_NOTIFICATION_TYPE(Notify_didJavaServerModeChange, std::string, "sonarlint/didJavaServerModeChange")
DEFINE_REQUEST_RESPONSE_TYPE(slls_showSonarLintOutput, JsonNull, JsonNull, "sonarlint/showSonarLintOutput");
DEFINE_REQUEST_RESPONSE_TYPE(slls_openJavaHomeSettings, JsonNull, JsonNull, "sonarlint/openJavaHomeSettings");
DEFINE_REQUEST_RESPONSE_TYPE(slls_openPathToNodeSettings, JsonNull, JsonNull, "sonarlint/openPathToNodeSettings");
DEFINE_REQUEST_RESPONSE_TYPE(slls_showRuleDescription, ShowRuleDescriptionParams, JsonNull, "sonarlint/showRuleDescription");
DEFINE_REQUEST_RESPONSE_TYPE(slls_getJavaConfig, lsDocumentUri, GetJavaConfigResponse, "sonarlint/getJavaConfig");
DEFINE_NOTIFICATION_TYPE(slls_setTraceNotification, SetTraceNotificationParams, "$/setTraceNotification")
|