| 1393 | } |
| 1394 | |
| 1395 | void LSPClientPlugin::onRegister( UICodeEditor* editor ) { |
| 1396 | Lock l( mDocMutex ); |
| 1397 | mDocs.insert( editor->getDocumentRef().get() ); |
| 1398 | |
| 1399 | for ( auto& kb : mKeyBindings ) { |
| 1400 | if ( !kb.second.empty() ) |
| 1401 | editor->getKeyBindings().addKeybindString( kb.second, kb.first ); |
| 1402 | } |
| 1403 | |
| 1404 | if ( editor->hasDocument() ) { |
| 1405 | auto& doc = editor->getDocument(); |
| 1406 | |
| 1407 | doc.setCommand( "lsp-go-to-definition", [this]( TextDocument::Client* client ) { |
| 1408 | getAndGoToLocation( static_cast<UICodeEditor*>( client ), "textDocument/definition" ); |
| 1409 | } ); |
| 1410 | |
| 1411 | doc.setCommand( "lsp-rename-symbol-under-cursor", [this]( TextDocument::Client* client ) { |
| 1412 | renameSymbol( static_cast<UICodeEditor*>( client ) ); |
| 1413 | } ); |
| 1414 | |
| 1415 | doc.setCommand( "lsp-go-to-declaration", [this]( TextDocument::Client* client ) { |
| 1416 | getAndGoToLocation( static_cast<UICodeEditor*>( client ), "textDocument/declaration" ); |
| 1417 | } ); |
| 1418 | |
| 1419 | doc.setCommand( "lsp-go-to-implementation", [this]( TextDocument::Client* client ) { |
| 1420 | getAndGoToLocation( static_cast<UICodeEditor*>( client ), |
| 1421 | "textDocument/implementation" ); |
| 1422 | } ); |
| 1423 | |
| 1424 | doc.setCommand( "lsp-go-to-type-definition", [this]( TextDocument::Client* client ) { |
| 1425 | getAndGoToLocation( static_cast<UICodeEditor*>( client ), |
| 1426 | "textDocument/typeDefinition" ); |
| 1427 | } ); |
| 1428 | |
| 1429 | doc.setCommand( "lsp-switch-header-source", [this]( TextDocument::Client* client ) { |
| 1430 | switchSourceHeader( static_cast<UICodeEditor*>( client ) ); |
| 1431 | } ); |
| 1432 | |
| 1433 | doc.setCommand( "lsp-symbol-info", [this]( TextDocument::Client* client ) { |
| 1434 | getSymbolInfo( static_cast<UICodeEditor*>( client ) ); |
| 1435 | } ); |
| 1436 | |
| 1437 | doc.setCommand( "lsp-symbol-references", [this]( TextDocument::Client* client ) { |
| 1438 | mClientManager.getSymbolReferences( |
| 1439 | static_cast<UICodeEditor*>( client )->getDocumentRef() ); |
| 1440 | } ); |
| 1441 | |
| 1442 | doc.setCommand( "lsp-symbol-code-action", [this]( TextDocument::Client* client ) { |
| 1443 | codeAction( static_cast<UICodeEditor*>( client ) ); |
| 1444 | } ); |
| 1445 | |
| 1446 | doc.setCommand( "lsp-memory-usage", [this]( TextDocument::Client* client ) { |
| 1447 | mClientManager.memoryUsage( static_cast<UICodeEditor*>( client )->getDocumentRef() ); |
| 1448 | } ); |
| 1449 | |
| 1450 | doc.setCommand( "lsp-refresh-semantic-highlighting", |
| 1451 | [this]( TextDocument::Client* client ) { |
| 1452 | mClientManager.requestSemanticHighlighting( |
nothing calls this directly
no test coverage detected