| 447 | } |
| 448 | |
| 449 | bool LSPClientServerManager::codeAction( std::shared_ptr<TextDocument> doc, |
| 450 | const nlohmann::json& diagnostics, |
| 451 | const LSPClientServer::CodeActionHandler& h ) { |
| 452 | auto* server = getOneLSPClientServer( doc ); |
| 453 | if ( !server || !server->isRunning() ) |
| 454 | return false; |
| 455 | |
| 456 | auto range = doc->getSelection(); |
| 457 | if ( !diagnostics.empty() && diagnostics.contains( "diagnostics" ) && |
| 458 | diagnostics["diagnostics"].is_array() && !diagnostics["diagnostics"].empty() && |
| 459 | diagnostics["diagnostics"][0].contains( "range" ) ) { |
| 460 | range = LSPConverter::parseRange( diagnostics["diagnostics"][0]["range"] ); |
| 461 | } else if ( !doc->hasSelection() ) { |
| 462 | range = { doc->startOfLine( range.start() ), |
| 463 | doc->positionOffset( doc->endOfLine( range.end() ), 1 ) }; |
| 464 | } |
| 465 | |
| 466 | server->documentCodeAction( doc->getURI(), range, {}, diagnostics, h ); |
| 467 | return true; |
| 468 | } |
| 469 | |
| 470 | void LSPClientServerManager::memoryUsage( std::shared_ptr<TextDocument> doc ) { |
| 471 | auto* server = getOneLSPClientServer( doc ); |
nothing calls this directly
no test coverage detected