| 647 | } |
| 648 | |
| 649 | static std::vector<LSPDiagnostic> parseDiagnostics( const json& result ) { |
| 650 | std::vector<LSPDiagnostic> ret; |
| 651 | for ( const auto& vdiag : result ) { |
| 652 | const auto& diag = vdiag; |
| 653 | auto range = parseRange( diag.at( MEMBER_RANGE ) ); |
| 654 | auto severity = static_cast<LSPDiagnosticSeverity>( diag.value<int>( "severity", 0 ) ); |
| 655 | std::string code; |
| 656 | if ( diag.contains( "code" ) ) { |
| 657 | if ( diag["code"].is_number_integer() ) |
| 658 | code = String::toString( diag["code"].get<int>() ); |
| 659 | else |
| 660 | code = diag.value( "code", "" ); |
| 661 | } |
| 662 | |
| 663 | auto source = diag.value( "source", "" ); |
| 664 | auto message = diag.value( MEMBER_MESSAGE, "" ); |
| 665 | std::vector<LSPDiagnosticRelatedInformation> relatedInfoList; |
| 666 | if ( diag.contains( "relatedInformation" ) ) { |
| 667 | const auto& relatedInfo = diag.at( "relatedInformation" ); |
| 668 | for ( const auto& related : relatedInfo ) { |
| 669 | auto relLocation = parseLocation( related.at( MEMBER_LOCATION ) ); |
| 670 | auto relMessage = related.value( MEMBER_MESSAGE, "" ); |
| 671 | relatedInfoList.push_back( { relLocation, relMessage } ); |
| 672 | } |
| 673 | } |
| 674 | json data; |
| 675 | if ( diag.contains( "data" ) ) |
| 676 | data = diag["data"]; |
| 677 | ret.push_back( { std::move( range ), |
| 678 | std::move( severity ), |
| 679 | std::move( code ), |
| 680 | std::move( source ), |
| 681 | std::move( message ), |
| 682 | std::move( relatedInfoList ), |
| 683 | {}, |
| 684 | std::move( data ) } ); |
| 685 | } |
| 686 | return ret; |
| 687 | } |
| 688 | |
| 689 | static std::vector<LSPCodeAction> parseCodeAction( const json& result ) { |
| 690 | std::vector<LSPCodeAction> ret; |
no test coverage detected