// CamelCaseFieldMask updates the given FieldMask by converting all of its paths to CamelCase, using the same heuristic
// that's used for naming protobuf fields in Go.
347981
func CamelCaseFieldMask(mask *field_mask.FieldMask) {
	if mask == nil || mask.Paths == nil {
		return
	}

	var newPaths []string
	for _, path := range mask.Paths {
		lowerCasedParts := strings.Split(path, ".")
		var camelCasedParts []string
		for _, part := range lowerCasedParts {
			camelCasedParts = append(camelCasedParts, generator.CamelCase(part))
		}
		newPaths = append(newPaths, strings.Join(camelCasedParts, "."))
	}

	mask.Paths = newPaths
}
1236606
func (m *Mapper) FieldMap(v reflect.Value) map[string]reflect.Value {
	v = reflect.Indirect(v)
	mustBe(v, reflect.Struct)

	r := map[string]reflect.Value{}
	tm := m.TypeMap(v.Type())
	for tagName, fi := range tm.Names {
		r[tagName] = FieldByIndexes(v, fi.Index)
	}
	return r
}
36096
func (m *Envelope) Field(fieldpath []string) (string, bool) {
	if len(fieldpath) == 0 {
		return "", false
	}

	switch fieldpath[0] {
	// unhandled: timestamp
	case "namespace":
		return string(m.Namespace), len(m.Namespace) > 0
	case "topic":
		return string(m.Topic), len(m.Topic) > 0
	case "event":
		decoded, err := github_com_containerd_typeurl.UnmarshalAny(m.Event)
		if err != nil {
			return "", false
		}

		adaptor, ok := decoded.(interface{ Field([]string) (string, bool) })
		if !ok {
			return "", false
		}
		return adaptor.Field(fieldpath[1:])
	}
	return "", false
}
1251697
func (s *SqlInjectionMatchTuple) SetFieldToMatch(v *FieldToMatch) *SqlInjectionMatchTuple {
	s.FieldToMatch = v
	return s
}
1061916
func (r *printRun) FieldMask() (*field_mask.FieldMask, error) {
	if r.id {
		if r.all || r.properties || r.steps {
			return nil, fmt.Errorf("-id is mutually exclusive with -A, -p and -steps")
		}
		return proto.Clone(idFieldMask).(*field_mask.FieldMask), nil
	}

	if r.all {
		if r.properties || r.steps {
			return nil, fmt.Errorf("-A is mutually exclusive with -p and -steps")
		}
		return proto.Clone(completeBuildFieldMask).(*field_mask.FieldMask), nil
	}

	ret := &field_mask.FieldMask{
		Paths: []string{
			"builder",
			"create_time",
			"created_by",
			"end_time",
			"id",
			"input.experimental",
			"input.gerrit_changes",
			"input.gitiles_commit",
			"number",
			"start_time",
			"status",
			"status_details",
			"summary_markdown",
			"tags",
			"update_time",
		},
	}

	if r.properties {
		ret.Paths = append(ret.Paths, "input.properties", "output.properties")
	}

	if r.steps {
		ret.Paths = append(ret.Paths, "steps")
	}

	return ret, nil
}
1126549
func (c *DefaultIndexingChain) perField(name string) *PerField {
	hashPos := util.Hashstr(name) & c.hashMask
	fp := c.fieldHash[hashPos]
	for fp != nil && fp.fieldInfo.Name != name {
		fp = fp.next
	}
	return fp
}
510810
func (s *EncryptionEntity) SetFieldPatterns(v *FieldPatterns) *EncryptionEntity {
	s.FieldPatterns = v
	return s
}
1258148
func Fields(predicate Predicate) []Field {
	var acc fieldsAccumulator
	acc.Index = make(map[Field]struct{})
	acc.Slice = make([]Field, 0, 4)
	predicate.Accept(&acc)
	return acc.Slice
}
724916
func (d *Context) GetTypeMask(index int) uint {
	return uint(C.duk_get_type_mask(d.duk_context, C.duk_idx_t(index)))
}
263388
func (s *_ABitOfEverythingServer) PatchWithFieldMaskInBody(ctx context.Context, request *examples.UpdateV2Request) (*empty.Empty, error) {
	// low-effort attempt to modify the field mask to only include paths for the ABE struct. Since this is only for the
	// integration tests, this narrow implementaion is fine.
	if request.UpdateMask != nil {
		var shifted []string
		for _, path := range request.UpdateMask.GetPaths() {
			shifted = append(shifted, strings.TrimPrefix(path, "Abe."))
		}
		request.UpdateMask.Paths = shifted
	}

	return s.UpdateV2(ctx, request)
}
707046
func HTTP2HeaderFieldPrefix(name, valuePrefix string) Matcher {
	return func(r io.Reader) bool {
		return matchHTTP2Field(ioutil.Discard, r, name, func(gotValue string) bool {
			return strings.HasPrefix(gotValue, valuePrefix)
		})
	}
}
1357914
func NewTcpFlagsField(tcpFlag uint16, tcpFlagMask *uint16) *MatchField {
	f := new(MatchField)
	f.Class = OXM_CLASS_OPENFLOW_BASIC
	f.Field = OXM_FIELD_TCP_FLAGS
	f.HasMask = false

	tcpFlagField := new(TcpFlagsField)
	tcpFlagField.TcpFlags = tcpFlag
	f.Value = tcpFlagField
	f.Length = uint8(tcpFlagField.Len())

	// Add the mask
	if tcpFlagMask != nil {
		mask := new(TcpFlagsField)
		mask.TcpFlags = *tcpFlagMask
		f.Mask = mask
		f.HasMask = true
		f.Length += uint8(mask.Len())
	}

	return f
}
1113112
func camelCaseName(name string) (should string) {
	name = strings.Title(name)

	// Fast path for simple cases: "_" and all lowercase.
	if name == "_" {
		return name
	}
	allLower := true
	for _, r := range name {
		if !unicode.IsLower(r) {
			allLower = false
			break
		}
	}
	if allLower {
		return name
	}

	// Split camelCase at any lower->upper transition, and split on underscores.
	// Check each word for common initialisms.
	runes := []rune(name)
	w, i := 0, 0 // index of start of word, scan
	for i+1 <= len(runes) {
		eow := false // whether we hit the end of a word
		if i+1 == len(runes) {
			eow = true
		} else if runes[i+1] == '_' {
			// underscore; shift the remainder forward over any run of underscores
			eow = true
			n := 1
			for i+n+1 < len(runes) && runes[i+n+1] == '_' {
				n++
			}

			// Leave at most one underscore if the underscore is between two digits
			if i+n+1 < len(runes) && unicode.IsDigit(runes[i]) && unicode.IsDigit(runes[i+n+1]) {
				n--
			}

			copy(runes[i+1:], runes[i+n+1:])
			runes = runes[:len(runes)-n]
		} else if unicode.IsLower(runes[i]) && !unicode.IsLower(runes[i+1]) {
			// lower->non-lower
			eow = true
		}
		i++
		if !eow {
			continue
		}

		// [w,i) is a word.
		word := string(runes[w:i])
		if u := usesInitialism(word); u != "" {
			// Keep consistent case, which is lowercase only at the start.
			if w == 0 && unicode.IsLower(runes[w]) {
				u = strings.ToLower(u)
			}
			// All the common initialisms are ASCII,
			// so we can replace the bytes exactly.
			copy(runes[w:], []rune(u))
		} else if w > 0 && strings.ToLower(word) == word {
			// already all lowercase, and not the first word, so uppercase the first character.
			runes[w] = unicode.ToUpper(runes[w])
		}
		w = i
	}
	return string(runes)
}
55009
func (s *UpdateByQueryService) FielddataFields(fielddataFields ...string) *UpdateByQueryService {
	s.fielddataFields = append(s.fielddataFields, fielddataFields...)
	return s
}
30452
func maskTrailingDash(name string) string {
	if strings.HasSuffix(name, "-") {
		return name[:len(name)-2] + "a"
	}
	return name
}
158750
func maskResourceWithPrefix(resource corev1.ResourceName, prefix string) corev1.ResourceName {
	return corev1.ResourceName(fmt.Sprintf("%s%s", prefix, string(resource)))
}
113561
func fieldName(x Expr) *Ident {
	switch t := x.(type) {
	case *Ident:
		return t
	case *SelectorExpr:
		if _, ok := t.X.(*Ident); ok {
			return t.Sel
		}
	case *StarExpr:
		return fieldName(t.X)
	}
	return nil
}