// pascalCase combines the given words using PascalCase.
//
// If allowAllCaps is true, when an all-caps word that is not a known
// abbreviation is encountered, it is left unchanged. Otherwise, it is
// Titlecased.
960603
func pascalCase(allowAllCaps bool, words ...string) string {
	for i, chunk := range words {
		if len(chunk) == 0 {
			// foo__bar
			continue
		}

		// known initalism
		init := strings.ToUpper(chunk)
		if _, ok := commonInitialisms[init]; ok {
			words[i] = init
			continue
		}

		// Was SCREAMING_SNAKE_CASE and not a known initialism so Titlecase it.
		if isAllCaps(chunk) && !allowAllCaps {
			// A single ALLCAPS word does not count as SCREAMING_SNAKE_CASE.
			// There must be at least one underscore.
			words[i] = strings.Title(strings.ToLower(chunk))
			continue
		}

		// Just another word, but could already be camelCased somehow, so just
		// change the first letter.
		head, headIndex := utf8.DecodeRuneInString(chunk)
		words[i] = string(unicode.ToUpper(head)) + string(chunk[headIndex:])
	}

	return strings.Join(words, "")
}
504091
func (config *Config) GetPluginCaseInsensitive(pluginName string) (Plugin, bool) {
	for name, plugin := range config.pluginsConfig.Plugins {
		if strings.EqualFold(name, pluginName) {
			return plugin, true
		}
	}

	return Plugin{}, false
}
536036
func (rs *Ruleset) Titleize(word string) string {
	words := splitAtCaseChangeWithTitlecase(word)
	result := strings.Join(words, " ")

	var acronymWords []string
	for index, word := range words {
		if len(word) == 1 {
			acronymWords = append(acronymWords, word)
		}

		if len(word) > 1 || index == len(words)-1 || len(acronymWords) > 1 {
			acronym := strings.Join(acronymWords, "")
			if !rs.isAcronym(acronym) {
				acronymWords = acronymWords[:len(acronymWords)]
				continue
			}

			result = strings.Replace(result, strings.Join(acronymWords, " "), acronym, 1)
			acronymWords = []string{}
		}
	}

	return result
}
50738
func SnakeCase(name string) string {
	for u, l := range toLower {
		name = strings.Replace(name, u, l, -1)
	}
	var b bytes.Buffer
	var lastUnderscore bool
	ln := len(name)
	if ln == 0 {
		return ""
	}
	b.WriteRune(unicode.ToLower(rune(name[0])))
	for i := 1; i < ln; i++ {
		r := rune(name[i])
		nextIsLower := false
		if i < ln-1 {
			n := rune(name[i+1])
			nextIsLower = unicode.IsLower(n) && unicode.IsLetter(n)
		}
		if unicode.IsUpper(r) {
			if !lastUnderscore && nextIsLower {
				b.WriteRune('_')
				lastUnderscore = true
			}
			b.WriteRune(unicode.ToLower(r))
		} else {
			b.WriteRune(r)
			lastUnderscore = false
		}
	}
	return b.String()
}
1117054
func ToSnakeCase(s string) string {
	s = ToCamelCase(s)
	runes := []rune(s)
	length := len(runes)
	var out []rune
	for i := 0; i < length; i++ {
		out = append(out, unicode.ToLower(runes[i]))
		if i+1 < length && (unicode.IsUpper(runes[i+1]) && unicode.IsLower(runes[i])) {
			out = append(out, '_')
		}
	}

	return string(out)
}
528607
func ToDashCase(str string) string {
	if len(str) == 0 {
		return ""
	}

	buf := &bytes.Buffer{}
	var prev, r0, r1 rune
	var size int

	r0 = '-'

	for len(str) > 0 {
		prev = r0
		r0, size = utf8.DecodeRuneInString(str)
		str = str[size:]

		switch {
		case r0 == utf8.RuneError:
			buf.WriteByte(byte(str[0]))

		case unicode.IsUpper(r0):
			if prev != '-' {
				buf.WriteRune('-')
			}

			buf.WriteRune(unicode.ToLower(r0))

			if len(str) == 0 {
				break
			}

			r0, size = utf8.DecodeRuneInString(str)
			str = str[size:]

			if !unicode.IsUpper(r0) {
				buf.WriteRune(r0)
				break
			}

			// find next non-upper-case character and insert `_` properly.
			// it's designed to convert `HTTPServer` to `http_server`.
			// if there are more than 2 adjacent upper case characters in a word,
			// treat them as an abbreviation plus a normal word.
			for len(str) > 0 {
				r1 = r0
				r0, size = utf8.DecodeRuneInString(str)
				str = str[size:]

				if r0 == utf8.RuneError {
					buf.WriteRune(unicode.ToLower(r1))
					buf.WriteByte(byte(str[0]))
					break
				}

				if !unicode.IsUpper(r0) {
					if r0 == '_' || r0 == ' ' || r0 == '-' {
						r0 = '-'

						buf.WriteRune(unicode.ToLower(r1))
					} else {
						buf.WriteRune('-')
						buf.WriteRune(unicode.ToLower(r1))
						buf.WriteRune(r0)
					}

					break
				}

				buf.WriteRune(unicode.ToLower(r1))
			}

			if len(str) == 0 || r0 == '-' {
				buf.WriteRune(unicode.ToLower(r0))
				break
			}

		default:
			if r0 == ' ' || r0 == '_' {
				r0 = '-'
			}

			buf.WriteRune(r0)
		}
	}

	return buf.String()
}
452938
func (s *DeleteByQueryService) LowercaseExpandedTerms(lowercaseExpandedTerms bool) *DeleteByQueryService {
	s.lowercaseExpandedTerms = &lowercaseExpandedTerms
	return s
}
834017
func PascalCaseTypeName(tip TypeInBody) string {
	methodName := commons.SnackCaseServerMethodName(tip.Endpoint.Method.DisplayName, tip.Endpoint.Verb, tip.Endpoint.Resource)
	suffix := commons.ReqBodySuffix
	if tip.ReqResp == HTTPResponse {
		suffix = commons.RespBodySuffix
	}
	return casee.ToPascalCase(methodName + suffix)
}
40059
func (g *Group) Case(cases ...Code) *Statement {
	s := Case(cases...)
	g.items = append(g.items, s)
	return s
}
1336040
func NewCase(t *testing.T, path string) Case {
	c := Case{T: t}
	c.In = newFile(&c, path)
	c.Out = newFile(&c, path+Extension)
	return c
}
552938
func UpperCamelCase(str string) string {
	pieces := split(str)

	for index, s := range pieces {
		pieces[index] = fmt.Sprintf(`%v%v`, strings.ToUpper(string(s[0])), strings.ToLower(s[1:]))
	}

	return strings.Join(pieces, ``)
}
579996
func (v *VerbalExpression) WithAnyCase(sensitive bool) *VerbalExpression {
	if sensitive {
		return v.addmodifier(IGNORE_CASE)
	}
	return v.removemodifier(IGNORE_CASE)
}
853462
func pluralCase(n *ast.MsgPluralNode, singular bool) ast.ParentNode {
	if singular {
		return n.Cases[0].Body
	}
	return n.Default
}
1164022
func IsPascalCase(s string) bool {
	if isFirstRuneDigit(s) {
		return false
	} else {
		return isMadeByAlphanumeric(s) && isFirstRuneUpper(s)
	}
}
205902
func (n *lowercaseSingularNamer) Name(t *types.Type) string {
	return strings.ToLower(t.Name.Name)
}
1006078
func goifyToCamelCase(val string) string {
	if len(val) == 0 {
		return ""
	}
	var b bytes.Buffer
	var prev rune
	for i, v := range val {
		if unicode.IsUpper(v) && unicode.IsUpper(prev) {
			b.WriteRune(unicode.ToLower(v))
		} else {
			if unicode.IsUpper(prev) {
				if i != 0 {
					b.Truncate(i - 1)
					b.WriteRune(unicode.ToUpper(prev))
				}
			}
			b.WriteRune(v)
		}
		prev = v
	}
	return b.String()
}
120464
func (b *Base) UseCamelCase() Serializer {
	return b.ConvertKeys(func(k string) string {
		return xstrings.FirstRuneToLower(xstrings.ToCamelCase(xstrings.ToSnakeCase(k)))
	})
}