events

package
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEventTypeOneof

func IsEventTypeOneof(field *types.Field) bool

IsEventTypeOneof returns true iff the field is a oneof and is marked with option (mir.event_type) = true.

func IsoriginRequest

func IsoriginRequest(field *types.Field) bool

IsoriginRequest returns true iff the field is marked with [(mir.origin_request) = true].

func IsoriginResponse

func IsoriginResponse(field *types.Field) bool

IsoriginResponse returns true iff the field is marked with [(mir.origin_response) = true].

func OmitInEventConstructor

func OmitInEventConstructor(field *types.Field) bool

OmitInEventConstructor returns true iff the field is marked with [(mir.omit_in_event_constructor) = true].

func OutputDir

func OutputDir(sourceDir string) string

func PackageName

func PackageName(sourcePackagePath string) string

func PackagePath

func PackagePath(sourcePackagePath string) string

Types

type EventNode

type EventNode struct {
	// contains filtered or unexported fields
}

EventNode represents a node in the tree corresponding to the hierarchy of events.

func (*EventNode) AllConstructorParameters

func (node *EventNode) AllConstructorParameters() params.FunctionParamList

AllConstructorParameters returns the accumulated parameters for the constructor function. The parameters include all the fields of all the ancestors in the hierarchy except those marked with [(mir.omit_in_event_constructors) = true] and the Type oneofs.

func (*EventNode) Children

func (node *EventNode) Children() []*EventNode

Children returns the children events in the hierarchy. NB: It may happen that an event class has no children.

func (*EventNode) Constructor

func (node *EventNode) Constructor() *jen.Statement

Constructor returns the code corresponding to the constructor function for this event.

func (*EventNode) IsEvent

func (node *EventNode) IsEvent() bool

IsEvent returns true if this is not an event class (see IsEventClass).

func (*EventNode) IsEventClass

func (node *EventNode) IsEventClass() bool

IsEventClass returns true iff the message has a oneof field marked with [(mir.event_type) = true].

func (*EventNode) IsRoot

func (node *EventNode) IsRoot() bool

IsRoot returns true if this is the root of the event hierarchy.

func (*EventNode) Message

func (node *EventNode) Message() *types.Message

Message returns the message for this event.

func (*EventNode) Name

func (node *EventNode) Name() string

Name returns the name of the event. Same as ev.Message().Name().

func (*EventNode) OneofOption

func (node *EventNode) OneofOption() *types.OneofOption

OneofOption returns the option in the parent's Type oneof. If nil, IsRoot() must be true.

func (*EventNode) OriginRequest

func (node *EventNode) OriginRequest() *Origin

OriginRequest returns a field marked with [(mir.origin_request) = true] (if any).

func (*EventNode) OriginResponse

func (node *EventNode) OriginResponse() *Origin

OriginResponse returns a field marked with [(mir.origin_response) = true] (if any).

func (*EventNode) Parent

func (node *EventNode) Parent() *EventNode

Parent returns the parent node in the hierarchy.

func (*EventNode) ThisNodeConstructorParameters

func (node *EventNode) ThisNodeConstructorParameters() params.ConstructorParamList

ThisNodeConstructorParameters returns a suffix of AllConstructorParameters() that corresponds to the fields only of this in the hierarchy, without the parameters accumulated from the ancestors.

func (*EventNode) TypeOneof

func (node *EventNode) TypeOneof() *types.Oneof

TypeOneof returns the Type oneof field of the message (if present).

type Origin

type Origin struct {
	// The field marked with [(mir.origin_request) = true] or [(mir.origin_response) = true].
	Field *types.Field

	// Same as Field.Type.(*types.Message).
	Message *types.Message

	// The field "Module" of the origin type.
	ModuleField *types.Field

	// The oneof "Type" of the origin type.
	TypeOneof *types.Oneof
}

Origin represents a field marked with [(mir.origin_request) = true] or [(mir.origin_response) = true]. The field must be of a message type with a field "Module" and a oneof "Type".

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func DefaultParser

func DefaultParser() *Parser

DefaultParser returns a singleton Parser. It must not be accessed concurrently.

func (*Parser) ParseEventHierarchy

func (p *Parser) ParseEventHierarchy(eventRootMsg *types.Message) (root *EventNode, err error)

ParseEventHierarchy extracts the information about the whole event hierarchy by its root.

func (*Parser) ParseOrigin

func (p *Parser) ParseOrigin(field *types.Field) (*Origin, error)

func (*Parser) TypesParser

func (p *Parser) TypesParser() *types.Parser

TypesParser returns the types.Parser used to parse the types in the event hierarchy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL