MCPcopy
hub / github.com/swaggo/swag / apply

Method apply

formatter.go:88–102  ·  view source on GitHub ↗
(contents []byte)

Source from the content-addressed store, hash-verified

86type edits []edit
87
88func (edits edits) apply(contents []byte) []byte {
89 // Apply the edits with the highest offset first, so that earlier edits
90 // don't affect the offsets of later edits.
91 sort.Slice(edits, func(i, j int) bool {
92 return edits[i].begin > edits[j].begin
93 })
94
95 for _, edit := range edits {
96 prefix := contents[:edit.begin]
97 suffix := contents[edit.end:]
98 contents = append(prefix, append(edit.replacement, suffix...)...)
99 }
100
101 return contents
102}
103
104// formatFuncDoc reformats the comment lines in commentList, and appends any
105// changes to the edit list.

Callers 1

FormatMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected