Class Doc.Token

java.lang.Object
com.google.googlejavaformat.Doc
com.google.googlejavaformat.Doc.Token
All Implemented Interfaces:
Op
Enclosing class:
Doc

public static final class Doc.Token extends Doc implements Op
A leaf Doc for a token.
  • Field Details

    • token

      private final Input.Token token
    • realOrImaginary

      private final Doc.Token.RealOrImaginary realOrImaginary
    • plusIndentCommentsBefore

      private final Indent plusIndentCommentsBefore
    • breakAndIndentTrailingComment

      private final Optional<Indent> breakAndIndentTrailingComment
  • Constructor Details

  • Method Details

    • tok

      private Input.Tok tok()
    • getPlusIndentCommentsBefore

      Indent getPlusIndentCommentsBefore()
      How much extra to indent comments before the Token.
      Returns:
      the extra indent
    • breakAndIndentTrailingComment

      Optional<Indent> breakAndIndentTrailingComment()
      Force a line break and indent trailing javadoc or block comments.
    • make

      static Op make(Input.Token token, Doc.Token.RealOrImaginary realOrImaginary, Indent plusIndentCommentsBefore, Optional<Indent> breakAndIndentTrailingComment)
      Make a Token.
      Parameters:
      token - the Input.Token to wrap
      realOrImaginary - did this Input.Token appear in the input, or was it generated incorrectly?
      plusIndentCommentsBefore - extra plusIndent for comments just before this token
      Returns:
      the new Token
    • getToken

      Input.Token getToken()
      Return the wrapped Input.Token.
      Returns:
      the Input.Token
    • realOrImaginary

      Doc.Token.RealOrImaginary realOrImaginary()
      Is the token good? That is, does it match an Input.Token?
      Returns:
      whether the @code Token} is good
    • add

      public void add(DocBuilder builder)
      Description copied from interface: Op
      Add an Op to a DocBuilder.
      Specified by:
      add in interface Op
      Parameters:
      builder - the DocBuilder
    • computeWidth

      int computeWidth()
      Description copied from class: Doc
      Compute the Doc's width.
      Specified by:
      computeWidth in class Doc
      Returns:
      the width
    • computeFlat

      String computeFlat()
      Description copied from class: Doc
      Compute the Doc's flat value. Not defined (and never called) if contains forced breaks.
      Specified by:
      computeFlat in class Doc
      Returns:
      the flat value
    • computeRange

      com.google.common.collect.Range<Integer> computeRange()
      Description copied from class: Doc
      Compute the Doc's Range of Input.Tokens.
      Specified by:
      computeRange in class Doc
      Returns:
      the Range
    • computeBreaks

      public Doc.State computeBreaks(CommentsHelper commentsHelper, int maxWidth, Doc.State state)
      Description copied from class: Doc
      Make breaking decisions for a Doc.
      Specified by:
      computeBreaks in class Doc
      Parameters:
      maxWidth - the maximum line width
      state - the current output state
      Returns:
      the new output state
    • write

      public void write(Output output)
      Description copied from class: Doc
      Write a Doc to an Output, after breaking decisions have been made.
      Specified by:
      write in class Doc
    • toString

      public String toString()
      Overrides:
      toString in class Object