def _HandleFixitResponse(self): if not len(self._response['fixits']): vimsupport.EchoText("No fixits found for current line") else: chunks = self._response['fixits'][0]['chunks'] vimsupport.ReplaceChunksList(chunks) vimsupport.EchoTextVimWidth("FixIt applied " + str(len(chunks)) + " changes")
def _EchoDiagnosticForLine( self, line_num ): buffer_num = vim.current.buffer.number diags = self._buffer_number_to_line_to_diags[ buffer_num ][ line_num ] if not diags: if self._diag_message_needs_clearing: # Clear any previous diag echo vimsupport.EchoText( '', False ) self._diag_message_needs_clearing = False return vimsupport.EchoTextVimWidth( diags[ 0 ][ 'text' ] ) self._diag_message_needs_clearing = True
def _EchoDiagnosticForLine(self, line_num): buffer_num = vim.current.buffer.number diags = self._buffer_number_to_line_to_diags[buffer_num][line_num] if not diags: if self._diag_message_needs_clearing: # Clear any previous diag echo vimsupport.EchoText('', False) self._diag_message_needs_clearing = False return text = diags[0]['text'] if diags[0].get('fixit_available', False): text += ' (FixIt)' vimsupport.EchoTextVimWidth(text) self._diag_message_needs_clearing = True
def _HandleFixitResponse(self): if not len(self._response['fixits']): vimsupport.EchoText("No fixits found for current line") else: fixit = self._response['fixits'][0] # We need to track the difference in length, but ensuring we apply fixes # in ascending order of insertion point. fixit['chunks'].sort(key=lambda chunk: (str(chunk['range'][ 'start']['line_num']) + ',' + str(chunk['range']['start'][ 'column_num']))) # Remember the line number we're processing. Negative line number means we # haven't processed any lines yet (by nature of being not equal to any # real line number). last_line = -1 # Counter of changes applied, so the user has a mental picture of the # undo history this change is creating. num_fixed = 0 line_delta = 0 for chunk in fixit['chunks']: if chunk['range']['start']['line_num'] != last_line: # If this chunk is on a different line than the previous chunk, # then ignore previous deltas (as offsets won't have changed). last_line = chunk['range']['end']['line_num'] char_delta = 0 (new_line_delta, new_char_delta) = vimsupport.ReplaceChunk( chunk['range']['start'], chunk['range']['end'], chunk['replacement_text'], line_delta, char_delta) line_delta += new_line_delta char_delta += new_char_delta num_fixed = num_fixed + 1 vimsupport.EchoTextVimWidth("FixIt applied " + str(num_fixed) + " changes")