Skip to content

Commit 454603e

Browse files
Merge pull request #13273 from ethereum/lsp-ci-trace
lsp.py: Pass trace option during initialization already.
2 parents 8cb1287 + 5aeb80e commit 454603e

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

libsolidity/lsp/LanguageServer.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ LanguageServer::LanguageServer(Transport& _transport):
119119
{"exit", [this](auto, auto) { m_state = (m_state == State::ShutdownRequested ? State::ExitRequested : State::ExitWithoutShutdown); }},
120120
{"initialize", bind(&LanguageServer::handleInitialize, this, _1, _2)},
121121
{"initialized", [](auto, auto) {}},
122-
{"$/setTrace", bind(&LanguageServer::setTrace, this, _2)},
122+
{"$/setTrace", [this](auto, Json::Value const& args) { setTrace(args["value"]); }},
123123
{"shutdown", [this](auto, auto) { m_state = State::ShutdownRequested; }},
124124
{"textDocument/definition", GotoDefinition(*this) },
125125
{"textDocument/didOpen", bind(&LanguageServer::handleTextDocumentDidOpen, this, _2)},
@@ -325,6 +325,9 @@ void LanguageServer::handleInitialize(MessageID _id, Json::Value const& _args)
325325
else if (Json::Value rootPath = _args["rootPath"])
326326
rootPath = rootPath.asString();
327327

328+
if (_args["trace"])
329+
setTrace(_args["trace"]);
330+
328331
m_fileRepository = FileRepository(rootPath, {});
329332
if (_args["initializationOptions"].isObject())
330333
changeConfiguration(_args["initializationOptions"]);
@@ -341,7 +344,6 @@ void LanguageServer::handleInitialize(MessageID _id, Json::Value const& _args)
341344
replyArgs["capabilities"]["semanticTokensProvider"]["full"] = true; // XOR requests.full.delta = true
342345
replyArgs["capabilities"]["renameProvider"] = true;
343346

344-
345347
m_client.reply(_id, move(replyArgs));
346348
}
347349

@@ -372,11 +374,11 @@ void LanguageServer::handleWorkspaceDidChangeConfiguration(Json::Value const& _a
372374

373375
void LanguageServer::setTrace(Json::Value const& _args)
374376
{
375-
if (!_args["value"].isString())
377+
if (!_args.isString())
376378
// Simply ignore invalid parameter.
377379
return;
378380

379-
string const stringValue = _args["value"].asString();
381+
string const stringValue = _args.asString();
380382
if (stringValue == "off")
381383
m_client.setTrace(TraceValue::Off);
382384
else if (stringValue == "messages")

test/lsp.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,9 @@ def setup_lsp(self, lsp: JsonRpcProcess, expose_project_root=True):
906906
params = {
907907
'processId': None,
908908
'rootUri': self.project_root_uri,
909-
'trace': 'off',
909+
# Enable traces to receive the amount of expected diagnostics before
910+
# actually receiving them.
911+
'trace': 'messages',
910912
'initializationOptions': {},
911913
'capabilities': {
912914
'textDocument': {
@@ -925,9 +927,6 @@ def setup_lsp(self, lsp: JsonRpcProcess, expose_project_root=True):
925927
params['rootUri'] = None
926928
lsp.call_method('initialize', params)
927929
lsp.send_notification('initialized')
928-
# Enable traces to receive the amount of expected diagnostics before
929-
# actually receiving them.
930-
lsp.send_message("$/setTrace", { 'value': 'messages' })
931930

932931
# {{{ helpers
933932
def get_test_file_path(self, test_case_name, sub_dir=None):

0 commit comments

Comments
 (0)