| 1 | package formatscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/ |
| 2 | |
| 3 | import ( |
| 4 | "stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/" |
| 5 | |
| 6 | "github.com/goccy/go-yaml/astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/" |
| 7 | "github.com/goccy/go-yaml/tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/" |
| 8 | ) |
| 9 | |
| 10 | func FormatNodeWithResolvedAliasscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/FormatNodeWithResolvedAlias().(n astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#, anchorNodeMap map[string]astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#) string { |
| 11 | tk := getFirstTokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/getFirstToken().(n) |
| 12 | if tk == nil { |
| 13 | return "" |
| 14 | } |
| 15 | formatter := newFormatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/newFormatter().(tk, hasCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/hasComment().(n)) |
| 16 | formatter.anchorNodeMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#anchorNodeMap. = anchorNodeMap |
| 17 | return formatter.formatscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#format().(n) |
| 18 | } |
| 19 | |
| 20 | func FormatNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/FormatNode().(n astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#) string { |
| 21 | tk := getFirstTokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/getFirstToken().(n) |
| 22 | if tk == nil { |
| 23 | return "" |
| 24 | } |
| 25 | return newFormatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/newFormatter().(tk, hasCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/hasComment().(n)).formatscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#format().(n) |
| 26 | } |
| 27 | |
| 28 | func FormatFilescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/FormatFile().(file *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Filescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/File#) string { |
| 29 | if len(file.Docsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/File#Docs.) == 0 { |
| 30 | return "" |
| 31 | } |
| 32 | tk := getFirstTokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/getFirstToken().(file.Docsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/File#Docs.[0]) |
| 33 | if tk == nil { |
| 34 | return "" |
| 35 | } |
| 36 | return newFormatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/newFormatter().(tk, hasCommentFilescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/hasCommentFile().(file)).formatFilescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatFile().(file) |
| 37 | } |
| 38 | |
| 39 | func hasCommentFilescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/hasCommentFile().(f *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Filescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/File#) bool { |
| 40 | for _, doc := range f.Docsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/File#Docs. { |
| 41 | if hasCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/hasComment().(doc.Bodyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DocumentNode#Body.) { |
| 42 | return true |
| 43 | } |
| 44 | } |
| 45 | return false |
| 46 | } |
| 47 | |
| 48 | func hasCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/hasComment().(n astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#) bool { |
| 49 | if n == nil { |
| 50 | return false |
| 51 | } |
| 52 | switch nn := n.(type) { |
| 53 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.DocumentNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DocumentNode#: |
| 54 | return hasCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/hasComment().(nn.Bodyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DocumentNode#Body.) |
| 55 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.NullNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/NullNode#: |
| 56 | return nn.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment. != nil |
| 57 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.BoolNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BoolNode#: |
| 58 | return nn.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment. != nil |
| 59 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.IntegerNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/IntegerNode#: |
| 60 | return nn.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment. != nil |
| 61 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.FloatNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/FloatNode#: |
| 62 | return nn.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment. != nil |
| 63 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.StringNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/StringNode#: |
| 64 | return nn.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment. != nil |
| 65 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.InfinityNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/InfinityNode#: |
| 66 | return nn.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment. != nil |
| 67 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.NanNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/NanNode#: |
| 68 | return nn.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment. != nil |
| 69 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.LiteralNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/LiteralNode#: |
| 70 | return nn.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment. != nil |
| 71 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.DirectiveNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DirectiveNode#: |
| 72 | if nn.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment. != nil { |
| 73 | return true |
| 74 | } |
| 75 | for _, value := range nn.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DirectiveNode#Values. { |
| 76 | if hasCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/hasComment().(value) { |
| 77 | return true |
| 78 | } |
| 79 | } |
| 80 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.TagNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/TagNode#: |
| 81 | if nn.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment. != nil { |
| 82 | return true |
| 83 | } |
| 84 | return hasCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/hasComment().(nn.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/TagNode#Value.) |
| 85 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#: |
| 86 | if nn.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment. != nil || nn.FootCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#FootComment. != nil { |
| 87 | return true |
| 88 | } |
| 89 | for _, value := range nn.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#Values. { |
| 90 | if value.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment. != nil || value.FootCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValueNode#FootComment. != nil { |
| 91 | return true |
| 92 | } |
| 93 | if hasCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/hasComment().(value.Keyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValueNode#Key.) { |
| 94 | return true |
| 95 | } |
| 96 | if hasCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/hasComment().(value.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValueNode#Value.) { |
| 97 | return true |
| 98 | } |
| 99 | } |
| 100 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingKeyNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingKeyNode#: |
| 101 | return nn.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment. != nil |
| 102 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MergeKeyNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MergeKeyNode#: |
| 103 | return nn.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment. != nil |
| 104 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.SequenceNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#: |
| 105 | if nn.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment. != nil || nn.FootCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#FootComment. != nil { |
| 106 | return true |
| 107 | } |
| 108 | for _, entry := range nn.Entriesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#Entries. { |
| 109 | if entry.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment. != nil || entry.HeadCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceEntryNode#HeadComment. != nil || entry.LineCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceEntryNode#LineComment. != nil { |
| 110 | return true |
| 111 | } |
| 112 | if hasCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/hasComment().(entry.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceEntryNode#Value.) { |
| 113 | return true |
| 114 | } |
| 115 | } |
| 116 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.AnchorNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#: |
| 117 | if nn.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment. != nil { |
| 118 | return true |
| 119 | } |
| 120 | if hasCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/hasComment().(nn.Namescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#Name.) || hasCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/hasComment().(nn.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#Value.) { |
| 121 | return true |
| 122 | } |
| 123 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.AliasNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AliasNode#: |
| 124 | if nn.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment. != nil { |
| 125 | return true |
| 126 | } |
| 127 | if hasCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/hasComment().(nn.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AliasNode#Value.) { |
| 128 | return true |
| 129 | } |
| 130 | } |
| 131 | return false |
| 132 | } |
| 133 | |
| 134 | func getFirstTokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/getFirstToken().(n astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#) *tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token# { |
| 135 | if n == nil { |
| 136 | return nil |
| 137 | } |
| 138 | switch nn := n.(type) { |
| 139 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.DocumentNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DocumentNode#: |
| 140 | if nn.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DocumentNode#Start. != nil { |
| 141 | return nn.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DocumentNode#Start. |
| 142 | } |
| 143 | return getFirstTokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/getFirstToken().(nn.Bodyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DocumentNode#Body.) |
| 144 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.NullNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/NullNode#: |
| 145 | return nn.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/NullNode#Token. |
| 146 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.BoolNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BoolNode#: |
| 147 | return nn.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BoolNode#Token. |
| 148 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.IntegerNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/IntegerNode#: |
| 149 | return nn.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/IntegerNode#Token. |
| 150 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.FloatNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/FloatNode#: |
| 151 | return nn.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/FloatNode#Token. |
| 152 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.StringNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/StringNode#: |
| 153 | return nn.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/StringNode#Token. |
| 154 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.InfinityNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/InfinityNode#: |
| 155 | return nn.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/InfinityNode#Token. |
| 156 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.NanNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/NanNode#: |
| 157 | return nn.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/NanNode#Token. |
| 158 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.LiteralNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/LiteralNode#: |
| 159 | return nn.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/LiteralNode#Start. |
| 160 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.DirectiveNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DirectiveNode#: |
| 161 | return nn.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DirectiveNode#Start. |
| 162 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.TagNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/TagNode#: |
| 163 | return nn.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/TagNode#Start. |
| 164 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#: |
| 165 | if nn.IsFlowStylescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#IsFlowStyle. { |
| 166 | return nn.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#Start. |
| 167 | } |
| 168 | if len(nn.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#Values.) == 0 { |
| 169 | return nn.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#Start. |
| 170 | } |
| 171 | return getFirstTokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/getFirstToken().(nn.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#Values.[0].Keyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValueNode#Key.) |
| 172 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingKeyNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingKeyNode#: |
| 173 | return nn.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingKeyNode#Start. |
| 174 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MergeKeyNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MergeKeyNode#: |
| 175 | return nn.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MergeKeyNode#Token. |
| 176 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.SequenceNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#: |
| 177 | return nn.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#Start. |
| 178 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.AnchorNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#: |
| 179 | return nn.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#Start. |
| 180 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.AliasNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AliasNode#: |
| 181 | return nn.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AliasNode#Start. |
| 182 | } |
| 183 | return nil |
| 184 | } |
| 185 | |
| 186 | type Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter# struct { |
| 187 | existsCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#existsComment. bool |
| 188 | tokenToOriginMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#tokenToOriginMap. map[*tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#]string |
| 189 | anchorNodeMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#anchorNodeMap. map[string]astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node# |
| 190 | } |
| 191 | |
| 192 | func newFormatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/newFormatter().(tk *tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#, existsComment bool) *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter# { |
| 193 | tokenToOriginMap := make(map[*tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#]string) |
| 194 | for tk.Prevscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Prev. != nil { |
| 195 | tk = tk.Prevscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Prev. |
| 196 | } |
| 197 | tokenToOriginMap[tk] = tk.Originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Origin. |
| 198 | |
| 199 | var origin string |
| 200 | for tk.Nextscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Next. != nil { |
| 201 | tk = tk.Nextscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Next. |
| 202 | if tk.Typescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Type. == tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.CommentTypescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/CommentType. { |
| 203 | origin += stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.21.0 strings/Repeat().("\n", stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/.Countscip-go gomod github.com/golang/go/src go1.21.0 strings/Count().(normalizeNewLineCharsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/normalizeNewLineChars().(tk.Originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Origin.), "\n")) |
| 204 | continue |
| 205 | } |
| 206 | origin += tk.Originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Origin. |
| 207 | tokenToOriginMap[tk] = origin |
| 208 | origin = "" |
| 209 | } |
| 210 | return &Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#{ |
| 211 | existsCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#existsComment.: existsComment, |
| 212 | tokenToOriginMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#tokenToOriginMap.: tokenToOriginMap, |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | func getIndentNumByFirstLineTokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/getIndentNumByFirstLineToken().(tk *tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#) int { |
| 217 | defaultIndent := tk.Positionscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Position..Columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Position#Column. - 1 |
| 218 | |
| 219 | // key: value |
| 220 | // ^ |
| 221 | // next |
| 222 | if tk.Typescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Type. == tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.SequenceEntryTypescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/SequenceEntryType. { |
| 223 | // If the current token is the sequence entry. |
| 224 | // the indent is calculated from the column value of the current token. |
| 225 | return defaultIndent |
| 226 | } |
| 227 | |
| 228 | // key: value |
| 229 | // ^ |
| 230 | // next |
| 231 | if tk.Nextscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Next. != nil && tk.Nextscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Next..Typescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Type. == tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.MappingValueTypescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/MappingValueType. { |
| 232 | // If the current token is the key in the mapping-value, |
| 233 | // the indent is calculated from the column value of the current token. |
| 234 | return defaultIndent |
| 235 | } |
| 236 | |
| 237 | if tk.Prevscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Prev. == nil { |
| 238 | return defaultIndent |
| 239 | } |
| 240 | prev := tk.Prevscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Prev. |
| 241 | |
| 242 | // key: value |
| 243 | // ^ |
| 244 | // prev |
| 245 | if prev.Typescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Type. == tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.MappingValueTypescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/MappingValueType. { |
| 246 | // If the current token is the value in the mapping-value, |
| 247 | // the indent is calculated from the column value of the key two steps back. |
| 248 | if prev.Prevscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Prev. == nil { |
| 249 | return defaultIndent |
| 250 | } |
| 251 | return prev.Prevscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Prev..Positionscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Position..Columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Position#Column. - 1 |
| 252 | } |
| 253 | |
| 254 | // - value |
| 255 | // ^ |
| 256 | // prev |
| 257 | if prev.Typescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Type. == tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.SequenceEntryTypescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/SequenceEntryType. { |
| 258 | // If the value is not a mapping-value and the previous token was a sequence entry, |
| 259 | // the indent is calculated using the column value of the sequence entry token. |
| 260 | return prev.Positionscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Position..Columnscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Position#Column. - 1 |
| 261 | } |
| 262 | |
| 263 | return defaultIndent |
| 264 | } |
| 265 | |
| 266 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#format().(n astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#) string { |
| 267 | return f.trimSpacePrefixscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#trimSpacePrefix().( |
| 268 | f.trimIndentSpacescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#trimIndentSpace().( |
| 269 | getIndentNumByFirstLineTokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/getIndentNumByFirstLineToken().(getFirstTokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/getFirstToken().(n)), |
| 270 | f.trimNewLineCharPrefixscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#trimNewLineCharPrefix().(f.formatNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatNode().(n)), |
| 271 | ), |
| 272 | ) |
| 273 | } |
| 274 | |
| 275 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatFilescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatFile().(file *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Filescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/File#) string { |
| 276 | if len(file.Docsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/File#Docs.) == 0 { |
| 277 | return "" |
| 278 | } |
| 279 | var ret string |
| 280 | for _, doc := range file.Docsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/File#Docs. { |
| 281 | ret += f.formatDocumentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatDocument().(doc) |
| 282 | } |
| 283 | return ret |
| 284 | } |
| 285 | |
| 286 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(tk *tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#) string { |
| 287 | if tk == nil { |
| 288 | return "" |
| 289 | } |
| 290 | if f.existsCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#existsComment. { |
| 291 | return tk.Originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Origin. |
| 292 | } |
| 293 | return f.tokenToOriginMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#tokenToOriginMap.[tk] |
| 294 | } |
| 295 | |
| 296 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatDocumentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatDocument().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.DocumentNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DocumentNode#) string { |
| 297 | return f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DocumentNode#Start.) + f.formatNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatNode().(n.Bodyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DocumentNode#Body.) + f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Endscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DocumentNode#End.) |
| 298 | } |
| 299 | |
| 300 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatNullscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatNull().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.NullNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/NullNode#) string { |
| 301 | return f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/NullNode#Token.) + f.formatCommentGroupscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatCommentGroup().(n.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment.) |
| 302 | } |
| 303 | |
| 304 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatStringscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatString().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.StringNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/StringNode#) string { |
| 305 | return f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/StringNode#Token.) + f.formatCommentGroupscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatCommentGroup().(n.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment.) |
| 306 | } |
| 307 | |
| 308 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatIntegerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatInteger().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.IntegerNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/IntegerNode#) string { |
| 309 | return f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/IntegerNode#Token.) + f.formatCommentGroupscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatCommentGroup().(n.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment.) |
| 310 | } |
| 311 | |
| 312 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatFloatscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatFloat().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.FloatNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/FloatNode#) string { |
| 313 | return f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/FloatNode#Token.) + f.formatCommentGroupscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatCommentGroup().(n.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment.) |
| 314 | } |
| 315 | |
| 316 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatBoolscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatBool().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.BoolNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BoolNode#) string { |
| 317 | return f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BoolNode#Token.) + f.formatCommentGroupscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatCommentGroup().(n.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment.) |
| 318 | } |
| 319 | |
| 320 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatInfinityscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatInfinity().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.InfinityNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/InfinityNode#) string { |
| 321 | return f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/InfinityNode#Token.) + f.formatCommentGroupscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatCommentGroup().(n.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment.) |
| 322 | } |
| 323 | |
| 324 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatNanscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatNan().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.NanNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/NanNode#) string { |
| 325 | return f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/NanNode#Token.) + f.formatCommentGroupscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatCommentGroup().(n.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment.) |
| 326 | } |
| 327 | |
| 328 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatLiteralscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatLiteral().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.LiteralNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/LiteralNode#) string { |
| 329 | return f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/LiteralNode#Start.) + f.formatCommentGroupscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatCommentGroup().(n.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment.) + f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/LiteralNode#Value..Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/StringNode#Token.) |
| 330 | } |
| 331 | |
| 332 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatMergeKeyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatMergeKey().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MergeKeyNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MergeKeyNode#) string { |
| 333 | return f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MergeKeyNode#Token.) |
| 334 | } |
| 335 | |
| 336 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatMappingValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatMappingValue().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingValueNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValueNode#) string { |
| 337 | return f.formatCommentGroupscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatCommentGroup().(n.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment.) + |
| 338 | f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Keyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValueNode#Key..GetTokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#GetToken.()) + ":" + f.formatCommentGroupscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatCommentGroup().(n.Keyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValueNode#Key..GetCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#GetComment.()) + f.formatNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatNode().(n.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValueNode#Value.) + |
| 339 | f.formatCommentGroupscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatCommentGroup().(n.FootCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValueNode#FootComment.) |
| 340 | } |
| 341 | |
| 342 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatDirectivescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatDirective().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.DirectiveNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DirectiveNode#) string { |
| 343 | ret := f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DirectiveNode#Start.) + f.formatNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatNode().(n.Namescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DirectiveNode#Name.) |
| 344 | for _, val := range n.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DirectiveNode#Values. { |
| 345 | ret += f.formatNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatNode().(val) |
| 346 | } |
| 347 | return ret |
| 348 | } |
| 349 | |
| 350 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatMappingscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatMapping().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#) string { |
| 351 | var ret string |
| 352 | if n.IsFlowStylescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#IsFlowStyle. { |
| 353 | ret = f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#Start.) |
| 354 | } |
| 355 | ret += f.formatCommentGroupscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatCommentGroup().(n.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment.) |
| 356 | for _, value := range n.Valuesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#Values. { |
| 357 | if value.CollectEntryscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValueNode#CollectEntry. != nil { |
| 358 | ret += f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(value.CollectEntryscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValueNode#CollectEntry.) |
| 359 | } |
| 360 | ret += f.formatMappingValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatMappingValue().(value) |
| 361 | } |
| 362 | if n.IsFlowStylescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#IsFlowStyle. { |
| 363 | ret += f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Endscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#End.) |
| 364 | } |
| 365 | return ret |
| 366 | } |
| 367 | |
| 368 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatTagscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatTag().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.TagNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/TagNode#) string { |
| 369 | return f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/TagNode#Start.) + f.formatNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatNode().(n.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/TagNode#Value.) |
| 370 | } |
| 371 | |
| 372 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatMappingKeyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatMappingKey().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingKeyNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingKeyNode#) string { |
| 373 | return f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingKeyNode#Start.) + f.formatNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatNode().(n.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingKeyNode#Value.) |
| 374 | } |
| 375 | |
| 376 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatSequencescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatSequence().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.SequenceNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#) string { |
| 377 | var ret string |
| 378 | if n.IsFlowStylescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#IsFlowStyle. { |
| 379 | ret = f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#Start.) |
| 380 | } |
| 381 | if n.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment. != nil { |
| 382 | // add head comment. |
| 383 | ret += f.formatCommentGroupscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatCommentGroup().(n.Commentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BaseNode#Comment.) |
| 384 | } |
| 385 | for _, entry := range n.Entriesscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#Entries. { |
| 386 | ret += f.formatNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatNode().(entry) |
| 387 | } |
| 388 | if n.IsFlowStylescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#IsFlowStyle. { |
| 389 | ret += f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Endscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#End.) |
| 390 | } |
| 391 | ret += f.formatCommentGroupscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatCommentGroup().(n.FootCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#FootComment.) |
| 392 | return ret |
| 393 | } |
| 394 | |
| 395 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatSequenceEntryscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatSequenceEntry().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.SequenceEntryNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceEntryNode#) string { |
| 396 | return f.formatCommentGroupscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatCommentGroup().(n.HeadCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceEntryNode#HeadComment.) + f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceEntryNode#Start.) + f.formatCommentGroupscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatCommentGroup().(n.LineCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceEntryNode#LineComment.) + f.formatNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatNode().(n.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceEntryNode#Value.) |
| 397 | } |
| 398 | |
| 399 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatAnchor().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.AnchorNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#) string { |
| 400 | return f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#Start.) + f.formatNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatNode().(n.Namescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#Name.) + f.formatNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatNode().(n.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#Value.) |
| 401 | } |
| 402 | |
| 403 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatAliasscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatAlias().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.AliasNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AliasNode#) string { |
| 404 | if f.anchorNodeMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#anchorNodeMap. != nil { |
| 405 | anchorName := n.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AliasNode#Value..GetTokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#GetToken.().Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Value. |
| 406 | node := f.anchorNodeMapscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#anchorNodeMap.[anchorName] |
| 407 | if node != nil { |
| 408 | formatted := f.formatNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatNode().(node) |
| 409 | // If formatted text contains newline characters, indentation needs to be considered. |
| 410 | if stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/.Containsscip-go gomod github.com/golang/go/src go1.21.0 strings/Contains().(formatted, "\n") { |
| 411 | // If the first character is not a newline, the first line should be output without indentation. |
| 412 | isIgnoredFirstLine := !stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.21.0 strings/HasPrefix().(formatted, "\n") |
| 413 | formatted = f.addIndentSpacescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#addIndentSpace().(n.GetTokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AliasNode#GetToken().().Positionscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Position..IndentNumscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Position#IndentNum., formatted, isIgnoredFirstLine) |
| 414 | } |
| 415 | return formatted |
| 416 | } |
| 417 | } |
| 418 | return f.originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#origin().(n.Startscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AliasNode#Start.) + f.formatNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatNode().(n.Valuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AliasNode#Value.) |
| 419 | } |
| 420 | |
| 421 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatNode().(n astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.Nodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/Node#) string { |
| 422 | switch nn := n.(type) { |
| 423 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.DocumentNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DocumentNode#: |
| 424 | return f.formatDocumentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatDocument().(nn) |
| 425 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.NullNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/NullNode#: |
| 426 | return f.formatNullscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatNull().(nn) |
| 427 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.BoolNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/BoolNode#: |
| 428 | return f.formatBoolscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatBool().(nn) |
| 429 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.IntegerNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/IntegerNode#: |
| 430 | return f.formatIntegerscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatInteger().(nn) |
| 431 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.FloatNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/FloatNode#: |
| 432 | return f.formatFloatscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatFloat().(nn) |
| 433 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.StringNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/StringNode#: |
| 434 | return f.formatStringscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatString().(nn) |
| 435 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.InfinityNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/InfinityNode#: |
| 436 | return f.formatInfinityscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatInfinity().(nn) |
| 437 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.NanNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/NanNode#: |
| 438 | return f.formatNanscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatNan().(nn) |
| 439 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.LiteralNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/LiteralNode#: |
| 440 | return f.formatLiteralscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatLiteral().(nn) |
| 441 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.DirectiveNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/DirectiveNode#: |
| 442 | return f.formatDirectivescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatDirective().(nn) |
| 443 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.TagNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/TagNode#: |
| 444 | return f.formatTagscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatTag().(nn) |
| 445 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingNode#: |
| 446 | return f.formatMappingscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatMapping().(nn) |
| 447 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingKeyNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingKeyNode#: |
| 448 | return f.formatMappingKeyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatMappingKey().(nn) |
| 449 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MappingValueNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MappingValueNode#: |
| 450 | return f.formatMappingValuescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatMappingValue().(nn) |
| 451 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.MergeKeyNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/MergeKeyNode#: |
| 452 | return f.formatMergeKeyscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatMergeKey().(nn) |
| 453 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.SequenceNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceNode#: |
| 454 | return f.formatSequencescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatSequence().(nn) |
| 455 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.SequenceEntryNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/SequenceEntryNode#: |
| 456 | return f.formatSequenceEntryscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatSequenceEntry().(nn) |
| 457 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.AnchorNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AnchorNode#: |
| 458 | return f.formatAnchorscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatAnchor().(nn) |
| 459 | case *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.AliasNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/AliasNode#: |
| 460 | return f.formatAliasscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatAlias().(nn) |
| 461 | } |
| 462 | return "" |
| 463 | } |
| 464 | |
| 465 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatCommentGroupscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatCommentGroup().(g *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.CommentGroupNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/CommentGroupNode#) string { |
| 466 | if g == nil { |
| 467 | return "" |
| 468 | } |
| 469 | var ret string |
| 470 | for _, cm := range g.Commentsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/CommentGroupNode#Comments. { |
| 471 | ret += f.formatCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatComment().(cm) |
| 472 | } |
| 473 | return ret |
| 474 | } |
| 475 | |
| 476 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatCommentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatComment().(n *astscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/.CommentNodescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/CommentNode#) string { |
| 477 | if n == nil { |
| 478 | return "" |
| 479 | } |
| 480 | return n.Tokenscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/ast`/CommentNode#Token..Originscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/token`/Token#Origin. |
| 481 | } |
| 482 | |
| 483 | // nolint: unused |
| 484 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) formatIndentscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#formatIndent().(col int) string { |
| 485 | if col <= 1 { |
| 486 | return "" |
| 487 | } |
| 488 | return stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.21.0 strings/Repeat().(" ", col-1) |
| 489 | } |
| 490 | |
| 491 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) trimNewLineCharPrefixscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#trimNewLineCharPrefix().(v string) string { |
| 492 | return stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/.TrimLeftFuncscip-go gomod github.com/golang/go/src go1.21.0 strings/TrimLeftFunc().(v, func(r rune) bool { |
| 493 | return r == '\n' || r == '\r' |
| 494 | }) |
| 495 | } |
| 496 | |
| 497 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) trimSpacePrefixscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#trimSpacePrefix().(v string) string { |
| 498 | return stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/.TrimLeftFuncscip-go gomod github.com/golang/go/src go1.21.0 strings/TrimLeftFunc().(v, func(r rune) bool { |
| 499 | return r == ' ' |
| 500 | }) |
| 501 | } |
| 502 | |
| 503 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) trimIndentSpacescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#trimIndentSpace().(trimIndentNum int, v string) string { |
| 504 | if trimIndentNum == 0 { |
| 505 | return v |
| 506 | } |
| 507 | lines := stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/.Splitscip-go gomod github.com/golang/go/src go1.21.0 strings/Split().(normalizeNewLineCharsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/normalizeNewLineChars().(v), "\n") |
| 508 | out := make([]string, 0, len(lines)) |
| 509 | for _, line := range lines { |
| 510 | var cnt int |
| 511 | out = append(out, stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/.TrimLeftFuncscip-go gomod github.com/golang/go/src go1.21.0 strings/TrimLeftFunc().(line, func(r rune) bool { |
| 512 | cnt++ |
| 513 | return r == ' ' && cnt <= trimIndentNum |
| 514 | })) |
| 515 | } |
| 516 | return stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.21.0 strings/Join().(out, "\n") |
| 517 | } |
| 518 | |
| 519 | func (f *Formatterscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#) addIndentSpacescip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/Formatter#addIndentSpace().(indentNum int, v string, isIgnoredFirstLine bool) string { |
| 520 | if indentNum == 0 { |
| 521 | return v |
| 522 | } |
| 523 | indent := stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/.Repeatscip-go gomod github.com/golang/go/src go1.21.0 strings/Repeat().(" ", indentNum) |
| 524 | lines := stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/.Splitscip-go gomod github.com/golang/go/src go1.21.0 strings/Split().(normalizeNewLineCharsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/normalizeNewLineChars().(v), "\n") |
| 525 | out := make([]string, 0, len(lines)) |
| 526 | for idx, line := range lines { |
| 527 | if line == "" || (isIgnoredFirstLine && idx == 0) { |
| 528 | out = append(out, line) |
| 529 | continue |
| 530 | } |
| 531 | out = append(out, indent+line) |
| 532 | } |
| 533 | return stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.21.0 strings/Join().(out, "\n") |
| 534 | } |
| 535 | |
| 536 | // normalizeNewLineChars normalize CRLF and CR to LF. |
| 537 | func normalizeNewLineCharsscip-go gomod github.com/goccy/go-yaml . `github.com/goccy/go-yaml/internal/format`/normalizeNewLineChars().(v string) string { |
| 538 | return stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.21.0 strings/ReplaceAll().(stringsscip-go gomod github.com/golang/go/src go1.21.0 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.21.0 strings/ReplaceAll().(v, "\r\n", "\n"), "\r", "\n") |
| 539 | } |