Class Doc.Level

  • Enclosing class:
    Doc

    static final class Doc.Level
    extends Doc
    A Level inside a Doc.
    • Field Detail

      • plusIndent

        private final Indent plusIndent
      • docs

        private final java.util.List<Doc> docs
      • oneLine

        boolean oneLine
        True if the entire Doc.Level fits on one line.
      • splits

        java.util.List<java.util.List<Doc>> splits
        Groups of Docs that are children of the current Doc.Level, separated by Doc.Breaks.
    • Constructor Detail

      • Level

        private Level​(Indent plusIndent)
    • Method Detail

      • make

        static Doc.Level make​(Indent plusIndent)
        Factory method for Levels.
        Parameters:
        plusIndent - the extra indent inside the Level
        Returns:
        the new Level
      • add

        void add​(Doc doc)
        Add a Doc to the Level.
        Parameters:
        doc - the Doc to add
      • computeWidth

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

        java.lang.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<java.lang.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
        maxWidth - the maximum line width
        state - the current output state
        Returns:
        the new output state
      • splitByBreaks

        private static void splitByBreaks​(java.util.List<Doc> docs,
                                          java.util.List<java.util.List<Doc>> splits,
                                          java.util.List<Doc.Break> breaks)
      • computeBreakAndSplit

        private static Doc.State computeBreakAndSplit​(CommentsHelper commentsHelper,
                                                      int maxWidth,
                                                      Doc.State state,
                                                      java.util.Optional<Doc.Break> optBreakDoc,
                                                      java.util.List<Doc> split)
        Lay out a Break-separated group of Docs in the current Level.
      • 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
      • writeFilled

        private void writeFilled​(Output output)
      • getWidth

        static int getWidth​(java.util.List<Doc> docs)
        Get the width of a sequence of Docs.
        Parameters:
        docs - the Docs
        Returns:
        the width
      • union

        private static com.google.common.collect.Range<java.lang.Integer> union​(com.google.common.collect.Range<java.lang.Integer> x,
                                                                                com.google.common.collect.Range<java.lang.Integer> y)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object