<commit_before>package summer

import "reflect"

func init() {
	PluginRegister(&ProviderPlugin{}, AfterInit)
}

type Provider interface {
	Provide() interface{}
}

type ProviderPlugin struct {

}

func (this *ProviderPlugin)Look(holder *Holder, path string, sf *reflect.StructField) (need reflect.Value) {
	if path == "*" {
		path = sf.Name
	}
	holder.Basket.EachHolder(func(name string, holder *Holder) bool {
		if provider, ok := holder.Stone.(Provider); ok {
			stone := provider.Provide()
			if name == path {
				need = reflect.ValueOf(stone)
				return true
			}
			if reflect.TypeOf(stone) == sf.Type || reflect.TypeOf(stone).AssignableTo(sf.Type) || reflect.TypeOf(stone).ConvertibleTo(sf.Type) {
				need = reflect.ValueOf(stone)
				return true
			}
		}
		return false
	});
	empty := reflect.Value{}
	if need == empty {
		panic("provider not found:" + holder.Class.Name() + "." + sf.Name + " @." + path)
	}
	return need
}
func (this *ProviderPlugin)    Prefix() string {
	return "@"
}
// zIndex represent the sequence of plugins
func (this *ProviderPlugin)    ZIndex() int {
	return 3
}<commit_msg>update for provider<commit_after>package summer

import "reflect"

func init() {
	PluginRegister(&ProviderPlugin{}, AfterInit)
}

type Provider interface {
	Provide() interface{}
}

type ProviderPlugin struct {
}

func (this *ProviderPlugin) Look(holder *Holder, path string, sf *reflect.StructField) (need reflect.Value) {
	if path == "*" {
		path = sf.Name
	}
	holder.Basket.EachHolder(func(name string, holder *Holder) bool {
		if provider, ok := holder.Stone.(Provider); ok {
			stone := provider.Provide()
			if name == path {
				need = reflect.ValueOf(stone)
				return true
			}

		}
		return false
	})
	empty := reflect.Value{}
	if need == empty {
		holder.Basket.EachHolder(func(name string, holder *Holder) bool {
			if provider, ok := holder.Stone.(Provider); ok {
				stone := provider.Provide()
				if reflect.TypeOf(stone) == sf.Type || reflect.TypeOf(stone).AssignableTo(sf.Type) || reflect.TypeOf(stone).ConvertibleTo(sf.Type) {
					need = reflect.ValueOf(stone)
					return true
				}
			}
			return false
		})
	}
	if need == empty {
		panic("provider not found:" + holder.Class.Name() + "." + sf.Name + " @." + path)
	}
	return need
}
func (this *ProviderPlugin) Prefix() string {
	return "@"
}

// zIndex represent the sequence of plugins
func (this *ProviderPlugin) ZIndex() int {
	return 3
}
{'fraction_non_alphanumeric': 0.14450867052023122, 'fraction_numerical': 0.0008257638315441783, 'mean_word_length': 3.7416829745596867, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '64315', 'n_tokens_mistral': 861, 'n_tokens_neox': 777, 'n_words': 204}