| 687 | } |
| 688 | |
| 689 | static std::vector<LSPCodeAction> parseCodeAction( const json& result ) { |
| 690 | std::vector<LSPCodeAction> ret; |
| 691 | const auto& codeActions = result; |
| 692 | for ( auto& action : codeActions ) { |
| 693 | // entry could be Command or CodeAction |
| 694 | if ( !action.contains( MEMBER_COMMAND ) || !action.at( MEMBER_COMMAND ).is_string() ) { |
| 695 | // CodeAction |
| 696 | auto title = action.at( MEMBER_TITLE ).get<std::string>(); |
| 697 | auto kind = action.value( MEMBER_KIND, "" ); |
| 698 | auto command = action.contains( MEMBER_COMMAND ) |
| 699 | ? parseCommand( action.at( MEMBER_COMMAND ) ) |
| 700 | : LSPCommand{}; |
| 701 | auto edit = action.contains( MEMBER_EDIT ) |
| 702 | ? parseWorkSpaceEdit( action.at( MEMBER_EDIT ) ) |
| 703 | : LSPWorkspaceEdit{}; |
| 704 | auto diagnostics = action.contains( MEMBER_DIAGNOSTICS ) |
| 705 | ? parseDiagnostics( action.at( MEMBER_DIAGNOSTICS ) ) |
| 706 | : std::vector<LSPDiagnostic>{}; |
| 707 | auto isPreferred = action.value( "isPreferred", false ); |
| 708 | LSPCodeAction _action = { title, kind, diagnostics, edit, command, isPreferred }; |
| 709 | ret.push_back( _action ); |
| 710 | } else { |
| 711 | // Command |
| 712 | auto command = parseCommand( action ); |
| 713 | ret.push_back( { command.title, std::string(), {}, {}, command } ); |
| 714 | } |
| 715 | } |
| 716 | return ret; |
| 717 | } |
| 718 | |
| 719 | static std::vector<LSPDiagnosticsCodeAction> parseDiagnosticsCodeAction( const json& result ) { |
| 720 | std::vector<LSPDiagnosticsCodeAction> ret; |
no test coverage detected