Documentation ¶
Overview ¶
Package methodsets defines an incremental, serializable index of method-set information that allows efficient 'implements' queries across packages of the workspace without using the type checker.
This package provides only the "global" (all workspace) search; the "local" search within a given package uses a different implementation based on type-checker data structures for a single package plus variants; see ../implementation.go. The local algorithm is more precise as it tests function-local types too.
A global index of function-local types is challenging since they may reference other local types, for which we would need to invent stable names, an unsolved problem described in passing in Go issue 57497. The global algorithm also does not index anonymous interface types, even outside function bodies.
Consequently, global results are not symmetric: applying the operation twice may not get you back where you started.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
An Index records the non-empty method sets of all package-level types in a package in a form that permits assignability queries without the type checker.
func NewIndex ¶
NewIndex returns a new index of method-set information for all package-level types in the specified package.
func (*Index) Search ¶
Search reports each type that implements (or is implemented by) the type that produced the search key. If methodID is nonempty, only that method of each type is reported.
The result does not include the error.Error method. TODO(adonovan): give this special case a more systematic treatment.
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
A Key represents the method set of a given type in a form suitable to pass to the (*Index).Search method of many different Indexes.
type Location ¶
A Location records the extent of an identifier in byte-offset form.
Conversion to protocol (UTF-16) form is done by the caller after a search, not during index construction.
type Result ¶
type Result struct { Location Location // location of the type or method // methods only: PkgPath string // path of declaring package (may differ due to embedding) ObjectPath objectpath.Path // path of method within declaring package }
A Result reports a matching type or method in a method-set search.