MCPcopy Create free account
hub / github.com/argotorg/solidity / handleInitialize

Method handleInitialize

libsolidity/lsp/LanguageServer.cpp:383–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

381}
382
383void LanguageServer::handleInitialize(MessageID _id, Json const& _args)
384{
385 lspRequire(
386 m_state == State::Started,
387 ErrorCode::RequestFailed,
388 "Initialize called at the wrong time."
389 );
390
391 m_state = State::Initialized;
392
393 // The default of FileReader is to use `.`, but the path from where the LSP was started
394 // should not matter.
395 std::string rootPath("/");
396 if (_args.contains("rootUri") && _args["rootUri"].is_string())
397 {
398 rootPath = _args["rootUri"].get<std::string>();
399 lspRequire(
400 boost::starts_with(rootPath, "file://"),
401 ErrorCode::InvalidParams,
402 "rootUri only supports file URI scheme."
403 );
404 rootPath = stripFileUriSchemePrefix(rootPath);
405 }
406 else if (_args.contains("rootPath"))
407 rootPath = _args["rootPath"].get<std::string>();
408
409 if (_args.contains("trace"))
410 setTrace(_args["trace"]);
411
412 m_fileRepository = FileRepository(rootPath, {});
413 if (_args.contains("initializationOptions") && _args["initializationOptions"].is_object())
414 changeConfiguration(_args["initializationOptions"]);
415
416 Json replyArgs;
417 replyArgs["serverInfo"]["name"] = "solc";
418 replyArgs["serverInfo"]["version"] = std::string(VersionNumber);
419 replyArgs["capabilities"]["definitionProvider"] = true;
420 replyArgs["capabilities"]["implementationProvider"] = true;
421 replyArgs["capabilities"]["textDocumentSync"]["change"] = 2; // 0=none, 1=full, 2=incremental
422 replyArgs["capabilities"]["textDocumentSync"]["openClose"] = true;
423 replyArgs["capabilities"]["semanticTokensProvider"]["legend"] = semanticTokensLegend();
424 replyArgs["capabilities"]["semanticTokensProvider"]["range"] = false;
425 replyArgs["capabilities"]["semanticTokensProvider"]["full"] = true; // XOR requests.full.delta = true
426 replyArgs["capabilities"]["renameProvider"] = true;
427 replyArgs["capabilities"]["hoverProvider"] = true;
428
429 m_client.reply(_id, std::move(replyArgs));
430}
431
432void LanguageServer::handleInitialized(MessageID, Json const&)
433{

Callers

nothing calls this directly

Calls 5

stripFileUriSchemePrefixFunction · 0.85
semanticTokensLegendFunction · 0.85
replyMethod · 0.80
FileRepositoryClass · 0.70
containsMethod · 0.45

Tested by

no test coverage detected