Documentation
¶
Overview ¶
Package source helps deal with Go source code.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ScopedQualifier ¶
type ScopedQualifier struct{ Scope, Qual string }
ScopedQualifier is a simple pair of strings: a scope and a qualifying identifier (a package name).
type StringSet ¶
type StringSet map[string]struct{}
StringSet stores an unordered set of strings.
func NewStringSet ¶
NewStringSet creates a StringSet with some elements.
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
Type represents a genericised type. Examples: $T, []$T, chan $T, map[$K]$V, struct { F $T }, and so on. It only understands types, it does not support genericised type _declarations_. Each type parameter may belong to a different scope after refinement, but each Type is constructed initially within a single scope.
func MustNewType ¶
MustNewType is NewType but where all errors cause a panic.
func NewType ¶
NewType parses a generic type string into a Type. All parameters and selector expressions are assumed to belong to the one given scope.
func (*Type) Refine ¶
func (p *Type) Refine(in TypeInferenceMap) (bool, error)
Refine fills in type parameters according to the provided map. It returns true if the refinement had any effect. If a parameter is not in the input map, it is left unrefined. If no parameters are in the input map, it does nothing.
func (*Type) RenameQualifier ¶
RenameQualifier looks for qualified identifiers from the given scope and if the X is an ident matching oldx, then it is renamed to newx. This is useful for renaming an import.
func (*Type) ScopedQualifiers ¶
func (p *Type) ScopedQualifiers() map[ScopedQualifier]struct{}
ScopedQualifiers returns a new set with all the qualifiers used in qualified identifiers, and their originating scope.
type TypeInferenceMap ¶
TypeInferenceMap (TypeParam -> *Type) holds inferences made about type parameters.s
func (TypeInferenceMap) ApplyDefault ¶
func (m TypeInferenceMap) ApplyDefault(t *Type)
ApplyDefault sets all keys associated with a nil type to a given default type.
func (TypeInferenceMap) Infer ¶
func (m TypeInferenceMap) Infer(p, q *Type) error
Infer attempts to add inferences to the map `m` such that `p.Refine(m)` and `q.Refine(m)` are similar. It returns an error if this is impossible.
func (TypeInferenceMap) Note ¶
func (m TypeInferenceMap) Note(t *Type)
Note ensures type params from t are keys in the map.