func (b *Builder) String() string {
	return b.sb.String()
}
String returns the built snippet string.
package snippet
import (
	"fmt"
	"strings"
)
type Builder struct {
	currentTabStop int
	sb             strings.Builder
}
var replacer = strings.NewReplacer(
	`\`, `\\`,
	`}`, `\}`,
	`$`, `\$`,
)
func (b *Builder) WriteText(s string) {
	replacer.WriteString(&b.sb, s)
}
func (b *Builder) PrependText(s string) {
	rawSnip := b.String()
	b.sb.Reset()
	b.WriteText(s)
	b.sb.WriteString(rawSnip)
}
func (b *Builder) Write(data []byte) (int, error) {
	return b.sb.Write(data)
}
func (b *Builder) WritePlaceholder(fn func(*Builder)) {
	fmt.Fprintf(&b.sb, "${%d:", b.nextTabStop())
	if fn != nil {
		fn(b)
	}
	b.sb.WriteByte('}')
}
func (b *Builder) WriteFinalTabstop() {
	fmt.Fprint(&b.sb, "$0")
}
var choiceReplacer = strings.NewReplacer(
	`\`, `\\`,
	`}`, `\}`,
	`$`, `\$`,
	`|`, `\|`,
	`,`, `\,`,
)
func (b *Builder) WriteChoice(choices []string) {
	fmt.Fprintf(&b.sb, "${%d|", b.nextTabStop())
	for i, c := range choices {
		if i != 0 {
			b.sb.WriteByte(',')
		}
		choiceReplacer.WriteString(&b.sb, c)
	}
	b.sb.WriteString("|}")
}