Class LspTypeInformationPresenter.LspTypeInformationReporter

All Implemented Interfaces:
TreeVisitor<Void,Void>
Enclosing class:
LspTypeInformationPresenter

protected class LspTypeInformationPresenter.LspTypeInformationReporter extends AbstractTypeInformationPresenter.TypeInformationReporter
Type information reporter that uses a format suitable for the LSP server.
  • Field Details

    • sourcePositions

      protected final SourcePositions sourcePositions
      Computes positions of a sub-tree.
  • Method Details

    • reportTreeType

      protected void reportTreeType(Tree tree, AnnotatedTypeMirror type, TypeOccurrenceKind occurrenceKind)
      Reports a diagnostic message indicating the range corresponding to the given tree has the given type. Specifically, the message has key "lsp.type.information", and it contains the name of the checker, the given occurrenceKind, the given type, and the computed message range for the tree. If the tree is an artificial tree, this does not report anything.
      Specified by:
      reportTreeType in class AbstractTypeInformationPresenter.TypeInformationReporter
      Parameters:
      tree - the tree that is used to find the corresponding range to report
      type - the type that we are going to display
      occurrenceKind - the kind of the given type
    • computeTypeOccurrenceRange

      protected @Nullable TypeOccurrenceRange computeTypeOccurrenceRange(Tree tree)
      Computes the 0-based inclusive message range for the given tree.

      Note that the range sometimes don't cover the entire source code of the tree. For example, in "int a = 0", we have a variable tree "int a", but we only want to report the range of the identifier "a". This customizes the positions where we want the type information to show.

      Parameters:
      tree - the tree for which we want to compute the message range
      Returns:
      a message range corresponds to the tree