Class Doc

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static com.google.common.collect.Range<java.lang.Integer> EMPTY_RANGE  
      private com.google.common.base.Supplier<java.lang.String> flat  
      private static com.google.common.collect.DiscreteDomain<java.lang.Integer> INTEGERS  
      static int MAX_LINE_WIDTH
      The maximum supported line width.
      private com.google.common.base.Supplier<com.google.common.collect.Range<java.lang.Integer>> range  
      private com.google.common.base.Supplier<java.lang.Integer> width  
    • Constructor Summary

      Constructors 
      Constructor Description
      Doc()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract Doc.State computeBreaks​(CommentsHelper commentsHelper, int maxWidth, Doc.State state)
      Make breaking decisions for a Doc.
      (package private) abstract java.lang.String computeFlat()
      Compute the Doc's flat value.
      (package private) abstract com.google.common.collect.Range<java.lang.Integer> computeRange()
      Compute the Doc's Range of Input.Tokens.
      (package private) abstract int computeWidth()
      Compute the Doc's width.
      (package private) java.lang.String getFlat()
      Return a Doc's flat-string value; not defined (and never called) if the Doc contains forced breaks.
      (package private) int getWidth()
      Return the width of a Doc.
      (package private) com.google.common.collect.Range<java.lang.Integer> range()
      Return the Range of a Doc.
      abstract void write​(Output output)
      Write a Doc to an Output, after breaking decisions have been made.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MAX_LINE_WIDTH

        public static final int MAX_LINE_WIDTH
        The maximum supported line width.

        This can be used as a sentinel/threshold for Docs that break unconditionally.

        The value was selected to be obviously too large for any practical line, but small enough to prevent accidental overflow.

        See Also:
        Constant Field Values
      • EMPTY_RANGE

        private static final com.google.common.collect.Range<java.lang.Integer> EMPTY_RANGE
      • INTEGERS

        private static final com.google.common.collect.DiscreteDomain<java.lang.Integer> INTEGERS
      • width

        private final com.google.common.base.Supplier<java.lang.Integer> width
      • flat

        private final com.google.common.base.Supplier<java.lang.String> flat
      • range

        private final com.google.common.base.Supplier<com.google.common.collect.Range<java.lang.Integer>> range
    • Constructor Detail

      • Doc

        public Doc()
    • Method Detail

      • getWidth

        final int getWidth()
        Return the width of a Doc.
        Returns:
        the width
      • getFlat

        final java.lang.String getFlat()
        Return a Doc's flat-string value; not defined (and never called) if the Doc contains forced breaks.
        Returns:
        the flat-string value
      • range

        final com.google.common.collect.Range<java.lang.Integer> range()
        Return the Range of a Doc.
        Returns:
        the Doc's Range
      • computeWidth

        abstract int computeWidth()
        Compute the Doc's width.
        Returns:
        the width
      • computeFlat

        abstract java.lang.String computeFlat()
        Compute the Doc's flat value. Not defined (and never called) if contains forced breaks.
        Returns:
        the flat value
      • computeRange

        abstract com.google.common.collect.Range<java.lang.Integer> computeRange()
        Compute the Doc's Range of Input.Tokens.
        Returns:
        the Range
      • computeBreaks

        public abstract Doc.State computeBreaks​(CommentsHelper commentsHelper,
                                                int maxWidth,
                                                Doc.State state)
        Make breaking decisions for a Doc.
        Parameters:
        maxWidth - the maximum line width
        state - the current output state
        Returns:
        the new output state
      • write

        public abstract void write​(Output output)
        Write a Doc to an Output, after breaking decisions have been made.