Class ConfigDocument.CommentPlacement

java.lang.Object
com.ultikits.ultitools.config.document.ConfigDocument.CommentPlacement
Enclosing class:
ConfigDocument

private static final class ConfigDocument.CommentPlacement extends Object
The two comment placements adjusted on read (see the class description).
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static void
    adjust(org.yaml.snakeyaml.nodes.MappingNode root)
     
    private static int
    column(org.yaml.snakeyaml.nodes.Node node)
     
    private static int
    contentColumn(org.yaml.snakeyaml.nodes.Node node)
     
    private static boolean
    isBlockScalar(org.yaml.snakeyaml.nodes.ScalarNode scalar)
     
    private static org.yaml.snakeyaml.nodes.Node
    lastChild(org.yaml.snakeyaml.nodes.Node node)
     
    private static List<org.yaml.snakeyaml.comments.CommentLine>
    moveTrailing(List<org.yaml.snakeyaml.comments.CommentLine> comments, int ownColumn, org.yaml.snakeyaml.nodes.Node previous)
    Moves the leading comment lines indented deeper than ownColumn to the end of the deepest block mapping in previous whose keys start at the line's column, and returns the lines that stay.
    private static List<org.yaml.snakeyaml.comments.CommentLine>
    prepend(List<org.yaml.snakeyaml.comments.CommentLine> first, List<org.yaml.snakeyaml.comments.CommentLine> rest)
    first followed by rest (which may be null).
    private static void
    reclaim(org.yaml.snakeyaml.nodes.ScalarNode scalar, org.yaml.snakeyaml.nodes.MappingNode root, org.yaml.snakeyaml.nodes.Node following)
     
    private static void
    reclaimAfterBlockScalars(org.yaml.snakeyaml.nodes.Node node, org.yaml.snakeyaml.nodes.MappingNode root, org.yaml.snakeyaml.nodes.Node following, Set<org.yaml.snakeyaml.nodes.Node> seen)
    #592: SnakeYAML 2.2's scanner reads every comment line with a column above 0 that follows a multi-line block scalar (| or >) as an in-line comment of that scalar, which the emitter then writes at column 0 - and the key below reads as uncommented.
    private static void
    relocate(org.yaml.snakeyaml.nodes.Node node, Set<org.yaml.snakeyaml.nodes.Node> seen)
     
    private static org.yaml.snakeyaml.nodes.MappingNode
    sectionAt(org.yaml.snakeyaml.nodes.Node node, int column)
    The block mapping along the last-child chain of node whose keys start at column.
    private static void
    splitHeader(org.yaml.snakeyaml.nodes.MappingNode root)
    Bukkit's adjustNodeComments: the first key's comments up to the last blank line are the header.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CommentPlacement

      private CommentPlacement()
  • Method Details

    • adjust

      static void adjust(org.yaml.snakeyaml.nodes.MappingNode root)
    • reclaimAfterBlockScalars

      private static void reclaimAfterBlockScalars(org.yaml.snakeyaml.nodes.Node node, org.yaml.snakeyaml.nodes.MappingNode root, org.yaml.snakeyaml.nodes.Node following, Set<org.yaml.snakeyaml.nodes.Node> seen)
      #592: SnakeYAML 2.2's scanner reads every comment line with a column above 0 that follows a multi-line block scalar (| or >) as an in-line comment of that scalar, which the emitter then writes at column 0 - and the key below reads as uncommented. Each such line (any in-line comment starting on a line after the scalar's own first line; a comment on the indicator line, |- # note, is the key's and is untouched) is given back, as a block comment with its original position, to the node that follows it in the file: the next key or list item at the same level, or for the last value of a section the next one further out, or for the last value of the document the document's end. That is exactly where SnakeYAML puts a comment after a plain value, so relocate(org.yaml.snakeyaml.nodes.Node, java.util.Set<org.yaml.snakeyaml.nodes.Node>) then applies the same deeper-indentation rule to both.
      Parameters:
      node - the node to walk
      root - the document's top-level mapping (receives the lines after the document's last value)
      following - the node read right after node's subtree, null at the end of the document
      seen - nodes already walked (an alias is walked once)
    • reclaim

      private static void reclaim(org.yaml.snakeyaml.nodes.ScalarNode scalar, org.yaml.snakeyaml.nodes.MappingNode root, org.yaml.snakeyaml.nodes.Node following)
    • isBlockScalar

      private static boolean isBlockScalar(org.yaml.snakeyaml.nodes.ScalarNode scalar)
    • prepend

      private static List<org.yaml.snakeyaml.comments.CommentLine> prepend(List<org.yaml.snakeyaml.comments.CommentLine> first, List<org.yaml.snakeyaml.comments.CommentLine> rest)
      first followed by rest (which may be null).
    • splitHeader

      private static void splitHeader(org.yaml.snakeyaml.nodes.MappingNode root)
      Bukkit's adjustNodeComments: the first key's comments up to the last blank line are the header.
    • relocate

      private static void relocate(org.yaml.snakeyaml.nodes.Node node, Set<org.yaml.snakeyaml.nodes.Node> seen)
    • moveTrailing

      private static List<org.yaml.snakeyaml.comments.CommentLine> moveTrailing(List<org.yaml.snakeyaml.comments.CommentLine> comments, int ownColumn, org.yaml.snakeyaml.nodes.Node previous)
      Moves the leading comment lines indented deeper than ownColumn to the end of the deepest block mapping in previous whose keys start at the line's column, and returns the lines that stay. A moved line is attached to the end of that mapping's last value: SnakeYAML's emitter writes comments that follow a value at the indentation of the mapping holding it.
    • sectionAt

      private static org.yaml.snakeyaml.nodes.MappingNode sectionAt(org.yaml.snakeyaml.nodes.Node node, int column)
      The block mapping along the last-child chain of node whose keys start at column.
    • contentColumn

      private static int contentColumn(org.yaml.snakeyaml.nodes.Node node)
    • lastChild

      private static org.yaml.snakeyaml.nodes.Node lastChild(org.yaml.snakeyaml.nodes.Node node)
    • column

      private static int column(org.yaml.snakeyaml.nodes.Node node)