Class ConfigDocument.CommentPlacement
java.lang.Object
com.ultikits.ultitools.config.document.ConfigDocument.CommentPlacement
- Enclosing class:
ConfigDocument
The two comment placements adjusted on read (see the class description).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static voidadjust(org.yaml.snakeyaml.nodes.MappingNode root) private static intcolumn(org.yaml.snakeyaml.nodes.Node node) private static intcontentColumn(org.yaml.snakeyaml.nodes.Node node) private static booleanisBlockScalar(org.yaml.snakeyaml.nodes.ScalarNode scalar) private static org.yaml.snakeyaml.nodes.NodelastChild(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 thanownColumnto the end of the deepest block mapping inpreviouswhose 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) firstfollowed byrest(which may benull).private static voidreclaim(org.yaml.snakeyaml.nodes.ScalarNode scalar, org.yaml.snakeyaml.nodes.MappingNode root, org.yaml.snakeyaml.nodes.Node following) private static voidreclaimAfterBlockScalars(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 voidprivate static org.yaml.snakeyaml.nodes.MappingNodesectionAt(org.yaml.snakeyaml.nodes.Node node, int column) The block mapping along the last-child chain ofnodewhose keys start atcolumn.private static voidsplitHeader(org.yaml.snakeyaml.nodes.MappingNode root) Bukkit'sadjustNodeComments: the first key's comments up to the last blank line are the header.
-
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, sorelocate(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 walkroot- the document's top-level mapping (receives the lines after the document's last value)following- the node read right afternode's subtree,nullat the end of the documentseen- 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) firstfollowed byrest(which may benull). -
splitHeader
private static void splitHeader(org.yaml.snakeyaml.nodes.MappingNode root) Bukkit'sadjustNodeComments: 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 thanownColumnto the end of the deepest block mapping inpreviouswhose 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 ofnodewhose keys start atcolumn. -
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)
-