本文整理匯總了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
}