本文整理汇总了Golang中golang.org/x/tools/refactor/satisfy.Finder类的典型用法代码示例。如果您正苦于以下问题:Golang Finder类的具体用法?Golang Finder怎么用?Golang Finder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Finder类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: satisfy
// satisfy returns the set of interface satisfaction constraints.
func (r *Unexporter) satisfy() map[satisfy.Constraint]bool {
if r.satisfyConstraints == nil {
// Compute on demand: it's expensive.
var f satisfy.Finder
for _, info := range r.packages {
f.Find(&info.Info, info.Files)
}
r.satisfyConstraints = f.Result
}
return r.satisfyConstraints
}
示例2: calculateConstraints
func calculateConstraints(u *Unexporter) {
constraints := make(map[satisfy.Constraint]map[*types.Package]bool)
for _, info := range u.prog.Imported {
var finder satisfy.Finder
finder.Find(&info.Info, info.Files)
for constraint := range finder.Result {
if _, ok := constraints[constraint]; !ok {
constraints[constraint] = make(map[*types.Package]bool)
}
constraints[constraint][info.Pkg] = true
}
}
u.f = constraints
}
示例3: findAssignments
// findAssignments returns the set of types to or from which type T is
// assigned in the program syntax.
func (r *renamer) findAssignments(T types.Type) map[types.Type]bool {
if r.satisfyConstraints == nil {
// Compute on demand: it's expensive.
var f satisfy.Finder
for _, info := range r.packages {
f.Find(&info.Info, info.Files)
}
r.satisfyConstraints = f.Result
}
result := make(map[types.Type]bool)
for key := range r.satisfyConstraints {
// key = (lhs, rhs) where lhs is always an interface.
if types.Identical(key.RHS, T) {
result[key.LHS] = true
}
if isInterface(T) && types.Identical(key.LHS, T) {
// must check both sides
result[key.RHS] = true
}
}
return result
}