Ejemplo n.º 1
0
    def UpdateWithNewDiagnosticsForFile(self, filepath, diagnostics):
        if not self._user_options['show_diagnostics_ui']:
            return

        bufnr = vimsupport.GetBufferNumberForFilename(filepath)
        if bufnr in self._buffers and vimsupport.BufferIsVisible(bufnr):
            # Note: We only update location lists, etc. for visible buffers, because
            # otherwise we default to using the current location list and the results
            # are that non-visible buffer errors clobber visible ones.
            self._buffers[bufnr].UpdateWithNewDiagnostics(diagnostics, True)
        else:
            # The project contains errors in file "filepath", but that file is not
            # open in any buffer. This happens for Language Server Protocol-based
            # completers, as they return diagnostics for the entire "project"
            # asynchronously (rather than per-file in the response to the parse
            # request).
            #
            # There are a number of possible approaches for
            # this, but for now we simply ignore them. Other options include:
            # - Use the QuickFix list to report project errors?
            # - Use a special buffer for project errors
            # - Put them in the location list of whatever the "current" buffer is
            # - Store them in case the buffer is opened later
            # - add a :YcmProjectDiags command
            # - Add them to errror/warning _counts_ but not any actual location list
            #   or other
            # - etc.
            #
            # However, none of those options are great, and lead to their own
            # complexities. So for now, we just ignore these diagnostics for files not
            # open in any buffer.
            pass
Ejemplo n.º 2
0
def _GetKeptAndNewSigns( placed_signs, buffer_number_to_line_to_diags,
                         next_sign_id ):
  new_signs = []
  kept_signs = []
  for buffer_number, line_to_diags in iteritems(
                                            buffer_number_to_line_to_diags ):
    if not vimsupport.BufferIsVisible( buffer_number ):
      continue

    for line, diags in iteritems( line_to_diags ):
      # Only one sign is visible by line.
      first_diag = diags[ 0 ]
      sign = _DiagSignPlacement( next_sign_id,
                                 line,
                                 buffer_number,
                                 _DiagnosticIsError( first_diag ) )
      if sign not in placed_signs:
        new_signs.append( sign )
        next_sign_id += 1
      else:
        # We use .index here because `sign` contains a new id, but
        # we need the sign with the old id to unplace it later on.
        # We won't be placing the new sign.
        kept_signs.append( placed_signs[ placed_signs.index( sign ) ] )
  return new_signs, kept_signs, next_sign_id
Ejemplo n.º 3
0
def _UpdateSigns(buffer_number_to_line_to_diags, next_sign_id):
    vimsupport.UnplaceAllSignsInBuffer(vim.current.buffer.number)
    for buffer_number, line_to_diags in buffer_number_to_line_to_diags.iteritems(
    ):
        if not vimsupport.BufferIsVisible(buffer_number):
            continue

        vimsupport.UnplaceAllSignsInBuffer(buffer_number)
        for line, diags in line_to_diags.iteritems():
            for diag in diags:
                vimsupport.PlaceSign(next_sign_id, line, buffer_number,
                                     _DiagnosticIsError(diag))
                next_sign_id += 1
    return next_sign_id
Ejemplo n.º 4
0
def _GetKeptAndNewSigns(placed_signs, buffer_number_to_line_to_diags,
                        next_sign_id):
    new_signs = []
    kept_signs = []
    for buffer_number, line_to_diags in buffer_number_to_line_to_diags.iteritems(
    ):
        if not vimsupport.BufferIsVisible(buffer_number):
            continue

        for line, diags in line_to_diags.iteritems():
            for diag in diags:
                sign = _DiagSignPlacement(next_sign_id, line, buffer_number,
                                          _DiagnosticIsError(diag))
                if sign not in placed_signs:
                    new_signs += [sign]
                    next_sign_id += 1
                else:
                    # We use .index here because `sign` contains a new id, but
                    # we need the sign with the old id to unplace it later on.
                    # We won't be placing the new sign.
                    kept_signs += [placed_signs[placed_signs.index(sign)]]
    return new_signs, kept_signs, next_sign_id