Documentation
¶
Index ¶
- type Label
- type Labeler
- func (l *Labeler) FieldID(field *types.Var, idx int, structlbl Label) (Label, bool)
- func (l *Labeler) FileLabel() Label
- func (l *Labeler) FreshID() Label
- func (l *Labeler) GlobalID(key string) Label
- func (l *Labeler) LocalID(nd interface{}) Label
- func (l *Labeler) LookupObjectID(object types.Object, typelbl Label) (Label, bool)
- func (l *Labeler) MethodID(method types.Object, recvlbl Label) (Label, bool)
- func (l *Labeler) ReceiverObjectID(object types.Object, methlbl Label) (Label, bool)
- func (l *Labeler) ScopeID(scope *types.Scope, pkg *types.Package) Label
- func (l *Labeler) ScopedObjectID(object types.Object, typelbl Label) (Label, bool)
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Label ¶
type Label struct {
// contains filtered or unexported fields
}
Label represents a label
var InvalidLabel Label
InvalidLabel represents an uninitialized or otherwise invalid label
type Labeler ¶
type Labeler struct { TypeLabels map[types.Type]Label // labels associated with types // contains filtered or unexported fields }
Labeler is used to represent labels for a file. It is used to write associate objects with labels.
func (*Labeler) FieldID ¶
FieldID associates a label with the given field and returns it, together with a flag indicating whether the field already had a label associated with it; the field must belong to `structlbl`, since that label is used to construct the label of the field. When the field name is the blank identifier `_`, `idx` is used to generate a unique name.
func (*Labeler) FileLabel ¶
FileLabel returns the label for the file with which the trap writer is associated
func (*Labeler) LookupObjectID ¶
LookupObjectID looks up the label associated with the given object and returns it; if the object does not have a label yet, it tries to construct one based on its scope and/or name, and otherwise returns InvalidLabel
func (*Labeler) MethodID ¶
MethodID associates a label with the given method and returns it, together with a flag indicating whether the method already had a label associated with it; the method must belong to `recvlbl`, since that label is used to construct the label of the method
func (*Labeler) ReceiverObjectID ¶
ReceiverObjectID associates a label with the given object and returns it, together with a flag indicating whether the object already had a label associated with it; the object must be the receiver of `methlbl`, since that label is used to construct the label of the object
func (*Labeler) ScopedObjectID ¶
ScopedObjectID associates a label with the given object and returns it, together with a flag indicating whether the object already had a label associated with it; the object must have a scope, since the scope's label is used to construct the label of the object.
There is a special case for variables that are method receivers. When this is detected, we must construct a special label, as the variable can be reached from several files via the method. As the type label is required to construct the receiver object id, it is also required here.
type Writer ¶
type Writer struct { Labeler *Labeler Package *packages.Package // contains filtered or unexported fields }
A Writer provides methods for writing data to a TRAP file
func NewWriter ¶
NewWriter creates a TRAP file for the given path and returns a writer for writing to it