( buffer_number, line_number, diag )
| 277 | |
| 278 | |
| 279 | def GetTextPropertyForDiag( buffer_number, line_number, diag ): |
| 280 | range = diag[ 'location_extent' ] |
| 281 | start = range[ 'start' ] |
| 282 | end = range[ 'end' ] |
| 283 | start_line = start[ 'line_num' ] |
| 284 | end_line = end[ 'line_num' ] |
| 285 | if start_line == end_line: |
| 286 | length = end[ 'column_num' ] - start[ 'column_num' ] |
| 287 | column = start[ 'column_num' ] |
| 288 | elif start_line == line_number: |
| 289 | # -1 switches to 0-based indexing. |
| 290 | current_line_len = len( vim.buffers[ buffer_number ][ line_number - 1 ] ) |
| 291 | # +2 includes the start columnand accounts for properties at the end of line |
| 292 | # covering \n as well. |
| 293 | length = current_line_len - start[ 'column_num' ] + 2 |
| 294 | column = start[ 'column_num' ] |
| 295 | elif end_line == line_number: |
| 296 | length = end[ 'column_num' ] - 1 |
| 297 | column = 1 |
| 298 | else: |
| 299 | # -1 switches to 0-based indexing. |
| 300 | # +1 accounts for properties at the end of line covering \n as well. |
| 301 | length = len( vim.buffers[ buffer_number ][ line_number - 1 ] ) + 1 |
| 302 | column = 1 |
| 303 | if diag[ 'kind' ] == 'ERROR': |
| 304 | property_name = 'YcmErrorProperty' |
| 305 | else: |
| 306 | property_name = 'YcmWarningProperty' |
| 307 | vim_props = vim.eval( f'prop_list( { line_number }, ' |
| 308 | f'{{ "bufnr": { buffer_number }, ' |
| 309 | f'"types": [ "{ property_name }" ] }} )' ) |
| 310 | return next( filter( |
| 311 | lambda p: column == int( p[ 'col' ] ) and |
| 312 | length == int( p[ 'length' ] ), |
| 313 | vim_props ) ) |
| 314 | |
| 315 | |
| 316 | def GetTextProperties( buffer_number ): |
nothing calls this directly
no outgoing calls
no test coverage detected