func substituteRule(r *rule.Rule, substitutions map[string]string, info rule.KindInfo) {
	for attr := range info.SubstituteAttrs {
		if expr := r.Attr(attr); expr != nil {
			expr = rule.MapExprStrings(expr, func(s string) string {
				if rename, ok := substitutions[strings.TrimPrefix(s, ":")]; ok {
					return ":" + rename
				} else {
					return s
				}
			})
			r.SetAttr(attr, expr)
		}
	}
}
func substituteRule(r *rule.Rule, substitutions map[string]string, info rule.KindInfo) {
	for attr := range info.SubstituteAttrs {
		if expr := r.Attr(attr); expr != nil {
			expr = rule.MapExprStrings(expr, func(s string) string {
				if rename, ok := substitutions[strings.TrimPrefix(s, ":")]; ok {
					return ":" + rename
				} else {
					return s
				}
			})
			r.SetAttr(attr, expr)
		}
	}
}
func substituteRule ( r * rule . Rule , substitutions map [ string ] string , info rule . KindInfo ) { for attr := range info . SubstituteAttrs { if expr := r . Attr ( attr ) ; expr != nil { expr = rule . MapExprStrings ( expr , func ( s string ) string { if rename , ok := substitutions [ strings . TrimPrefix ( s , " " ) ] ; ok { return " " + rename } else { return s } } ) r . SetAttr ( attr , expr ) } } }
// substituteRule replaces local labels (those beginning with ":", referring to
// targets in the same package) according to a substitution map. This is used
// to update generated rules before merging when the corresponding existing
// rules have different names. If substituteRule replaces a string, it returns
// a new expression; it will not modify the original expression.
substituteRule replaces local labels ( those beginning with : referring to targets in the same package ) according to a substitution map . This is used to update generated rules before merging when the corresponding existing rules have different names . If substituteRule replaces a string it returns a new expression ; it will not modify the original expression .