( diagnostic )
| 542 | |
| 543 | def ConvertDiagnosticsToQfList( diagnostics ): |
| 544 | def ConvertDiagnosticToQfFormat( diagnostic ): |
| 545 | # See :h getqflist for a description of the dictionary fields. |
| 546 | # Note that, as usual, Vim is completely inconsistent about whether |
| 547 | # line/column numbers are 1 or 0 based in its various APIs. Here, it wants |
| 548 | # them to be 1-based. The documentation states quite clearly that it |
| 549 | # expects a byte offset, by which it means "1-based column number" as |
| 550 | # described in :h getqflist ("the first column is 1"). |
| 551 | location = diagnostic[ 'location' ] |
| 552 | line_num = location[ 'line_num' ] |
| 553 | |
| 554 | # libclang can give us diagnostics that point "outside" the file; Vim borks |
| 555 | # on these. |
| 556 | if line_num < 1: |
| 557 | line_num = 1 |
| 558 | |
| 559 | text = diagnostic[ 'text' ] |
| 560 | if diagnostic.get( 'fixit_available', False ): |
| 561 | text += ' (FixIt available)' |
| 562 | |
| 563 | return { |
| 564 | 'bufnr' : GetBufferNumberForFilename( location[ 'filepath' ], |
| 565 | create_buffer_if_needed = True ), |
| 566 | 'lnum' : line_num, |
| 567 | 'col' : location[ 'column_num' ], |
| 568 | 'text' : text, |
| 569 | 'type' : diagnostic[ 'kind' ][ 0 ], |
| 570 | 'valid' : 1 |
| 571 | } |
| 572 | |
| 573 | return [ ConvertDiagnosticToQfFormat( x ) for x in diagnostics ] |
| 574 |
no test coverage detected