MCPcopy Create free account
hub / github.com/ycm-core/YouCompleteMe / GetTextPropertyForDiag

Function GetTextPropertyForDiag

python/ycm/vimsupport.py:279–313  ·  view source on GitHub ↗
( buffer_number, line_number, diag )

Source from the content-addressed store, hash-verified

277
278
279def 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
316def GetTextProperties( buffer_number ):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected