當前位置: 首頁>>代碼示例>>Golang>>正文


Golang satisfy.Finder類代碼示例

本文整理匯總了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
}
開發者ID:rakyll,項目名稱:GCSolutions,代碼行數:12,代碼來源:check.go

示例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
}
開發者ID:rakyll,項目名稱:GCSolutions,代碼行數:16,代碼來源:unexporter.go

示例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
}
開發者ID:himanshugpt,項目名稱:evergreen,代碼行數:25,代碼來源:check.go


注:本文中的golang.org/x/tools/refactor/satisfy.Finder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。