123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- from ycm import vimsupport
- from ycm.client.event_notification import EventNotification
- from ycm.diagnostic_interface import DiagnosticInterface
- DIAGNOSTIC_UI_FILETYPES = { 'cpp', 'cs', 'c', 'objc', 'objcpp', 'cuda',
- 'javascript', 'typescript', 'typescriptreact' }
- class Buffer:
- def __init__( self, bufnr, user_options, filetypes ):
- self._number = bufnr
- self._parse_tick = 0
- self._handled_tick = 0
- self._parse_request = None
- self._should_resend = False
- self._diag_interface = DiagnosticInterface( bufnr, user_options )
- self.UpdateFromFileTypes( filetypes )
- def FileParseRequestReady( self, block = False ):
- return bool( self._parse_request and
- ( block or self._parse_request.Done() ) )
- def SendParseRequest( self, extra_data ):
-
- if self._parse_request is not None and not self._parse_request.Done():
- self._should_resend = True
- return
- self._should_resend = False
- self._parse_request = EventNotification( 'FileReadyToParse',
- extra_data = extra_data )
- self._parse_request.Start()
-
-
- self._handled_tick -= 1
- self._parse_tick = self._ChangedTick()
- def NeedsReparse( self ):
- return self._parse_tick != self._ChangedTick()
- def ShouldResendParseRequest( self ):
- return ( self._should_resend
- or ( bool( self._parse_request )
- and self._parse_request.ShouldResend() ) )
- def UpdateDiagnostics( self, force = False ):
- if force or not self._async_diags:
- self.UpdateWithNewDiagnostics( self._parse_request.Response() )
- else:
-
-
-
- self._parse_request.Response()
- def UpdateWithNewDiagnostics( self, diagnostics ):
- self._diag_interface.UpdateWithNewDiagnostics( diagnostics )
- def UpdateMatches( self ):
- self._diag_interface.UpdateMatches()
- def PopulateLocationList( self ):
- return self._diag_interface.PopulateLocationList()
- def GetResponse( self ):
- return self._parse_request.Response()
- def IsResponseHandled( self ):
- return self._handled_tick == self._parse_tick
- def MarkResponseHandled( self ):
- self._handled_tick = self._parse_tick
- def OnCursorMoved( self ):
- self._diag_interface.OnCursorMoved()
- def GetErrorCount( self ):
- return self._diag_interface.GetErrorCount()
- def GetWarningCount( self ):
- return self._diag_interface.GetWarningCount()
- def UpdateFromFileTypes( self, filetypes ):
- self._filetypes = filetypes
- self._async_diags = not any( x in DIAGNOSTIC_UI_FILETYPES
- for x in filetypes )
- def _ChangedTick( self ):
- return vimsupport.GetBufferChangedTick( self._number )
- class BufferDict( dict ):
- def __init__( self, user_options ):
- self._user_options = user_options
- def __missing__( self, key ):
-
- new_value = self[ key ] = Buffer(
- key,
- self._user_options,
- vimsupport.GetBufferFiletypes( key ) )
- return new_value
|