From 5aeb80ec3c254e6e6fb2025d8c745b4856b9fe68 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Wed, 13 Jul 2022 15:46:49 +0200 Subject: [PATCH] lsp.py: Pass trace option during initialization already. --- libsolidity/lsp/LanguageServer.cpp | 10 ++++++---- test/lsp.py | 7 +++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/libsolidity/lsp/LanguageServer.cpp b/libsolidity/lsp/LanguageServer.cpp index 762a698a6..5465406c0 100644 --- a/libsolidity/lsp/LanguageServer.cpp +++ b/libsolidity/lsp/LanguageServer.cpp @@ -119,7 +119,7 @@ LanguageServer::LanguageServer(Transport& _transport): {"exit", [this](auto, auto) { m_state = (m_state == State::ShutdownRequested ? State::ExitRequested : State::ExitWithoutShutdown); }}, {"initialize", bind(&LanguageServer::handleInitialize, this, _1, _2)}, {"initialized", [](auto, auto) {}}, - {"$/setTrace", bind(&LanguageServer::setTrace, this, _2)}, + {"$/setTrace", [this](auto, Json::Value const& args) { setTrace(args["value"]); }}, {"shutdown", [this](auto, auto) { m_state = State::ShutdownRequested; }}, {"textDocument/definition", GotoDefinition(*this) }, {"textDocument/didOpen", bind(&LanguageServer::handleTextDocumentDidOpen, this, _2)}, @@ -325,6 +325,9 @@ void LanguageServer::handleInitialize(MessageID _id, Json::Value const& _args) else if (Json::Value rootPath = _args["rootPath"]) rootPath = rootPath.asString(); + if (_args["trace"]) + setTrace(_args["trace"]); + m_fileRepository = FileRepository(rootPath, {}); if (_args["initializationOptions"].isObject()) changeConfiguration(_args["initializationOptions"]); @@ -341,7 +344,6 @@ void LanguageServer::handleInitialize(MessageID _id, Json::Value const& _args) replyArgs["capabilities"]["semanticTokensProvider"]["full"] = true; // XOR requests.full.delta = true replyArgs["capabilities"]["renameProvider"] = true; - m_client.reply(_id, move(replyArgs)); } @@ -372,11 +374,11 @@ void LanguageServer::handleWorkspaceDidChangeConfiguration(Json::Value const& _a void LanguageServer::setTrace(Json::Value const& _args) { - if (!_args["value"].isString()) + if (!_args.isString()) // Simply ignore invalid parameter. return; - string const stringValue = _args["value"].asString(); + string const stringValue = _args.asString(); if (stringValue == "off") m_client.setTrace(TraceValue::Off); else if (stringValue == "messages") diff --git a/test/lsp.py b/test/lsp.py index f4c428baf..543a7ca43 100755 --- a/test/lsp.py +++ b/test/lsp.py @@ -906,7 +906,9 @@ class SolidityLSPTestSuite: # {{{ params = { 'processId': None, 'rootUri': self.project_root_uri, - 'trace': 'off', + # Enable traces to receive the amount of expected diagnostics before + # actually receiving them. + 'trace': 'messages', 'initializationOptions': {}, 'capabilities': { 'textDocument': { @@ -925,9 +927,6 @@ class SolidityLSPTestSuite: # {{{ params['rootUri'] = None lsp.call_method('initialize', params) lsp.send_notification('initialized') - # Enable traces to receive the amount of expected diagnostics before - # actually receiving them. - lsp.send_message("$/setTrace", { 'value': 'messages' }) # {{{ helpers def get_test_file_path(self, test_case_name, sub_dir=None):