func inferProtoMode(c *config.Config, rel string, f *rule.File) {
	pc := GetProtoConfig(c)
	if pc.Mode != DefaultMode || pc.ModeExplicit {
		return
	}
	if pc.GoPrefix == wellKnownTypesGoPrefix {
		pc.Mode = LegacyMode
		return
	}
	if path.Base(rel) == "vendor" {
		pc.Mode = DisableMode
		return
	}
	if f == nil {
		return
	}
	mode := DefaultMode
outer:
	for _, l := range f.Loads {
		name := l.Name()
		if name == "@io_bazel_rules_go//proto:def.bzl" {
			break
		}
		if name == "@io_bazel_rules_go//proto:go_proto_library.bzl" {
			mode = LegacyMode
			break
		}
		for _, sym := range l.Symbols() {
			if sym == "go_proto_library" {
				mode = DisableMode
				break outer
			}
		}
	}
	if mode == DefaultMode || pc.Mode == mode || c.ShouldFix && mode == LegacyMode {
		return
	}
	pc.Mode = mode
}
func inferProtoMode(c *config.Config, rel string, f *rule.File) {
	pc := GetProtoConfig(c)
	if pc.Mode != DefaultMode || pc.ModeExplicit {
		return
	}
	if pc.GoPrefix == wellKnownTypesGoPrefix {
		pc.Mode = LegacyMode
		return
	}
	if path.Base(rel) == "vendor" {
		pc.Mode = DisableMode
		return
	}
	if f == nil {
		return
	}
	mode := DefaultMode
outer:
	for _, l := range f.Loads {
		name := l.Name()
		if name == "@io_bazel_rules_go//proto:def.bzl" {
			break
		}
		if name == "@io_bazel_rules_go//proto:go_proto_library.bzl" {
			mode = LegacyMode
			break
		}
		for _, sym := range l.Symbols() {
			if sym == "go_proto_library" {
				mode = DisableMode
				break outer
			}
		}
	}
	if mode == DefaultMode || pc.Mode == mode || c.ShouldFix && mode == LegacyMode {
		return
	}
	pc.Mode = mode
}
// inferProtoMode sets ProtoConfig.Mode based on the directory name and the
// contents of f. If the proto mode is set explicitly, this function does not
// change it. If this is a vendor directory, or go_proto_library is loaded from
// another file, proto rule generation is disabled.
//
// TODO(jayconrod): this logic is archaic, now that rules are generated by
// separate language extensions. Proto rule generation should be independent
// from Go.