Documentation
¶
Index ¶
- Constants
- Variables
- func ExpressionsEqual(a, b Expression) bool
- func GetPrimitiveWidth(t PrimitiveDefinition) int
- func GetProtocolSchemaString(protocol *ProtocolDefinition, symbolTable SymbolTable) string
- func IsGeneric(t TypeDefinition) bool
- func IsIntegralPrimitive(prim PrimitiveDefinition) bool
- func IsIntegralType(t Type) bool
- func IsSignedPrimitive(prim PrimitiveDefinition) bool
- func MkTypeSyntaxRewriter[TContext any](writer TypeSyntaxWriter[TContext]) func(typeOrTypeDef Node, context TContext) string
- func PatternsEqual(a, b Pattern) bool
- func TypeContainsGenericTypeParameter(node Type) bool
- func TypeDefinitionsEqual(a, b TypeDefinition) bool
- func TypeHasNullOption(node Type) bool
- func TypeToShortSyntax(t Type, qualified bool) string
- func TypesEqual(a, b Type) bool
- func UnmarshalFieldsOrProtocolStepsYAML[T fieldOrProtocolStep](elements *[]*T, value *yaml.Node) error
- func Visit(root Node, visitorFunc VisitorFunc)
- func VisitWithContext[T any](root Node, context T, visitor VisitorWithContextFunc[T])
- type AliasRemoved
- type Array
- type ArrayDimension
- type ArrayDimensions
- type BinaryExpression
- type BinaryOperator
- type CompatibilityChange
- type ComputedField
- type ComputedFieldScope
- type ComputedFields
- type DeclarationPattern
- type DefinitionChange
- type DefinitionChangeIncompatible
- type DefinitionMeta
- type DefinitionPair
- type Dimensionality
- type DiscardPattern
- type EnumChange
- type EnumDefinition
- type EnumValue
- type EnumValues
- type Environment
- type EvolutionContext
- type Expression
- type Field
- type Fields
- type FloatingPointLiteralExpression
- type FunctionCallExpression
- type GeneralizedType
- func ToGeneralizedType(t Type) *GeneralizedType
- func ToUnionOfUnderlyingTypes(t *GeneralizedType) *GeneralizedType
- func UnmarshalArrayYAML(value *yaml.Node) (*GeneralizedType, error)
- func UnmarshalMapYAML(value *yaml.Node) (*GeneralizedType, error)
- func UnmarshalStreamYAML(value *yaml.Node) (*GeneralizedType, error)
- func UnmarshalUnionYAML(value *yaml.Node) (*GeneralizedType, error)
- func UnmarshalVectorYAML(value *yaml.Node) (*GeneralizedType, error)
- type GenericTypeParameter
- type IntegerLiteralExpression
- type Map
- type MarshaledBytes
- type MemberAccessExpression
- type MemberAccessKind
- type NamedType
- type NamedTypeChange
- type Namespace
- type Node
- type NodeMeta
- type Pattern
- type PrimitiveDefinition
- type PrimitiveKind
- type ProtocolChange
- type ProtocolDefinition
- type ProtocolRemoved
- type ProtocolSchema
- type ProtocolStep
- type ProtocolSteps
- type RecordChange
- type RecordDefinition
- type Rewriter
- type RewriterFunc
- type RewriterWithContext
- type RewriterWithContextFunc
- type SimpleType
- type SinkWarningOrError
- type Stream
- type StringLiteralExpression
- type SubscriptArgument
- type SubscriptExpression
- type SwitchCase
- type SwitchExpression
- type SymbolTable
- type Type
- type TypeCase
- type TypeCases
- type TypeChange
- type TypeChangeComplexToComplex
- type TypeChangeDefinitionChanged
- type TypeChangeIncompatible
- type TypeChangeNumberToNumber
- type TypeChangeNumberToString
- type TypeChangeOptionalToScalar
- type TypeChangeOptionalToUnion
- type TypeChangeOptionalTypeChanged
- type TypeChangeScalarToOptional
- type TypeChangeScalarToUnion
- type TypeChangeStepAdded
- type TypeChangeStreamTypeChanged
- type TypeChangeStringToNumber
- type TypeChangeUnionToOptional
- type TypeChangeUnionToScalar
- type TypeChangeUnionTypesetChanged
- type TypeChangeVectorTypeChanged
- type TypeConversionExpression
- type TypeDefinition
- type TypeDefinitions
- type TypePair
- type TypePattern
- type TypeSyntaxWriter
- type UnaryExpression
- type UnaryOperator
- type ValidationPass
- type Vector
- type Visitor
- type VisitorFunc
- type VisitorWithContext
- type VisitorWithContextFunc
Constants ¶
const ( IncompatibleDefinitions = "definitions are incompatible" IncompatibleTypeParameters = "type parameters do not match" IncompatibleBaseDefinitions = "base definitions are incompatible" )
const ( Bool = "bool" Int8 = "int8" Uint8 = "uint8" Int16 = "int16" Uint16 = "uint16" Int32 = "int32" Uint32 = "uint32" Int64 = "int64" Uint64 = "uint64" Size = "size" Float32 = "float32" Float64 = "float64" ComplexFloat32 = "complexfloat32" ComplexFloat64 = "complexfloat64" String = "string" Date = "date" Time = "time" DateTime = "datetime" )
const ( FunctionSize = "size" FunctionDimensionIndex = "dimensionIndex" FunctionDimensionCount = "dimensionCount" )
Variables ¶
var ( TokenTypeString = expressionLexer.Symbols()["String"] TokenTypeFloat = expressionLexer.Symbols()["Float"] TokenTypeInt = expressionLexer.Symbols()["Int"] TokenTypeAs = expressionLexer.Symbols()["As"] TokenTypeIdent = expressionLexer.Symbols()["Ident"] TokenTypeOpenParen = expressionLexer.Symbols()["OpenParen"] TokenTypeCloseParen = expressionLexer.Symbols()["CloseParen"] TokenTypeComma = expressionLexer.Symbols()["Comma"] TokenTypeOpenBracket = expressionLexer.Symbols()["OpenBracket"] TokenTypeCloseBracket = expressionLexer.Symbols()["CloseBracket"] TokenTypeDot = expressionLexer.Symbols()["Dot"] TokenTypePow = expressionLexer.Symbols()["Pow"] TokenTypePlus = expressionLexer.Symbols()["Plus"] TokenTypeMinus = expressionLexer.Symbols()["Minus"] TokenTypeStar = expressionLexer.Symbols()["Star"] TokenTypeSlash = expressionLexer.Symbols()["Slash"] TokenTypeColon = expressionLexer.Symbols()["Colon"] TokenTypeUnterminatedString = expressionLexer.Symbols()["UnterminatedString"] )
var ( Zero = big.NewInt(0) MaxInt8 = big.NewInt(math.MaxInt8) MinInt8 = big.NewInt(math.MinInt8) MaxInt16 = big.NewInt(math.MaxInt16) MinInt16 = big.NewInt(math.MinInt16) MaxInt32 = big.NewInt(math.MaxInt32) MinInt32 = big.NewInt(math.MinInt32) MaxInt64 = big.NewInt(math.MaxInt64) MinInt64 = big.NewInt(math.MinInt64) MaxUint8 = big.NewInt(math.MaxUint8) MaxUint16 = big.NewInt(math.MaxUint16) MaxUint32 = big.NewInt(math.MaxUint32) MaxUint64 = func() *big.Int { var i big.Int i.SetUint64(math.MaxUint64) return &i }() MaxSize = MaxUint64 )
var ( Int8Type = &SimpleType{Name: Int8, ResolvedDefinition: PrimitiveInt8} Int16Type = &SimpleType{Name: Int16, ResolvedDefinition: PrimitiveInt16} Int32Type = &SimpleType{Name: Int32, ResolvedDefinition: PrimitiveInt32} Int64Type = &SimpleType{Name: Int64, ResolvedDefinition: PrimitiveInt64} Uint8Type = &SimpleType{Name: Uint8, ResolvedDefinition: PrimitiveUint8} Uint16Type = &SimpleType{Name: Uint16, ResolvedDefinition: PrimitiveUint16} Uint32Type = &SimpleType{Name: Uint32, ResolvedDefinition: PrimitiveUint32} Uint64Type = &SimpleType{Name: Uint64, ResolvedDefinition: PrimitiveUint64} SizeType = &SimpleType{Name: Size, ResolvedDefinition: PrimitiveSize} BoolType = &SimpleType{Name: Bool, ResolvedDefinition: PrimitiveBool} Float32Type = &SimpleType{Name: Float32, ResolvedDefinition: PrimitiveFloat32} Float64Type = &SimpleType{Name: Float64, ResolvedDefinition: PrimitiveFloat64} ComplexFloat32Type = &SimpleType{Name: ComplexFloat32, ResolvedDefinition: PrimitiveComplexFloat32} ComplexFloat64Type = &SimpleType{Name: ComplexFloat64, ResolvedDefinition: PrimitiveComplexFloat64} StringType = &SimpleType{Name: String, ResolvedDefinition: PrimitiveString} )
var ( PrimitiveBool = PrimitiveDefinition(Bool) PrimitiveInt8 = PrimitiveDefinition(Int8) PrimitiveUint8 = PrimitiveDefinition(Uint8) PrimitiveInt16 = PrimitiveDefinition(Int16) PrimitiveUint16 = PrimitiveDefinition(Uint16) PrimitiveInt32 = PrimitiveDefinition(Int32) PrimitiveUint32 = PrimitiveDefinition(Uint32) PrimitiveInt64 = PrimitiveDefinition(Int64) PrimitiveUint64 = PrimitiveDefinition(Uint64) PrimitiveSize = PrimitiveDefinition(Size) PrimitiveFloat32 = PrimitiveDefinition(Float32) PrimitiveFloat64 = PrimitiveDefinition(Float64) PrimitiveComplexFloat32 = PrimitiveDefinition(ComplexFloat32) PrimitiveComplexFloat64 = PrimitiveDefinition(ComplexFloat64) PrimitiveString = PrimitiveDefinition(String) PrimitiveDate = PrimitiveDefinition(Date) PrimitiveTime = PrimitiveDefinition(Time) PrimitiveDateTime = PrimitiveDefinition(DateTime) )
var ErrNoCommonType = errors.New("no common type")
Functions ¶
func ExpressionsEqual ¶
func ExpressionsEqual(a, b Expression) bool
func GetPrimitiveWidth ¶
func GetPrimitiveWidth(t PrimitiveDefinition) int
func GetProtocolSchemaString ¶
func GetProtocolSchemaString(protocol *ProtocolDefinition, symbolTable SymbolTable) string
func IsGeneric ¶
func IsGeneric(t TypeDefinition) bool
func IsIntegralPrimitive ¶
func IsIntegralPrimitive(prim PrimitiveDefinition) bool
func IsIntegralType ¶
func IsSignedPrimitive ¶
func IsSignedPrimitive(prim PrimitiveDefinition) bool
func MkTypeSyntaxRewriter ¶
func MkTypeSyntaxRewriter[TContext any](writer TypeSyntaxWriter[TContext]) func(typeOrTypeDef Node, context TContext) string
func PatternsEqual ¶
func TypeContainsGenericTypeParameter ¶
Returns true if the type is generic (not concrete)
func TypeDefinitionsEqual ¶
func TypeDefinitionsEqual(a, b TypeDefinition) bool
func TypeHasNullOption ¶
Returns true if the type is Optional
func TypeToShortSyntax ¶
func TypesEqual ¶
func VisitWithContext ¶
func VisitWithContext[T any](root Node, context T, visitor VisitorWithContextFunc[T])
Visits a Node tree from the given root, threading a context parameter throughout.
Types ¶
type AliasRemoved ¶
type AliasRemoved struct {
DefinitionPair
}
type Array ¶
type Array struct {
NodeMeta
Dimensions *ArrayDimensions `json:"dimensions,omitempty"`
}
func (*Array) HasKnownNumberOfDimensions ¶
type ArrayDimension ¶
type ArrayDimension struct {
NodeMeta
Comment string `json:"comment,omitempty"`
Name *string `json:"name,omitempty"`
Length *uint64 `json:"length,omitempty"`
}
func (*ArrayDimension) UnmarshalYAML ¶
func (dimension *ArrayDimension) UnmarshalYAML(value *yaml.Node) error
type ArrayDimensions ¶
type ArrayDimensions []*ArrayDimension
func (ArrayDimensions) MarshalJSON ¶
func (dims ArrayDimensions) MarshalJSON() ([]byte, error)
type BinaryExpression ¶
type BinaryExpression struct {
NodeMeta
Left Expression `json:"left"`
Operator BinaryOperator `json:"op"`
Right Expression `json:"right"`
ResolvedType Type `json:"-"`
}
func (*BinaryExpression) GetResolvedType ¶
func (b *BinaryExpression) GetResolvedType() Type
func (*BinaryExpression) IsReference ¶
func (b *BinaryExpression) IsReference() bool
func (*BinaryExpression) MarshalJSON ¶
func (e *BinaryExpression) MarshalJSON() ([]byte, error)
type BinaryOperator ¶
type BinaryOperator int
const ( BinaryOpAdd BinaryOperator = iota BinaryOpSub BinaryOpMul BinaryOpDiv BinaryOpPow )
func (*BinaryOperator) MarshalJSON ¶
func (op *BinaryOperator) MarshalJSON() ([]byte, error)
func (BinaryOperator) Precedence ¶
func (o BinaryOperator) Precedence() int
type CompatibilityChange ¶
type CompatibilityChange struct {
DefinitionPair
}
type ComputedField ¶
type ComputedField struct {
NodeMeta
Name string `json:"name"`
Comment string `json:"comment,omitempty"`
Expression Expression `json:"expression"`
}
type ComputedFieldScope ¶
type ComputedFieldScope struct {
Record *RecordDefinition
RewrittenFields map[*ComputedField]*ComputedField
CurrentFields []*ComputedField
Variables []*DeclarationPattern
}
type ComputedFields ¶
type ComputedFields []*ComputedField
func (*ComputedFields) UnmarshalYAML ¶
func (computedFields *ComputedFields) UnmarshalYAML(value *yaml.Node) error
type DeclarationPattern ¶
type DeclarationPattern struct {
TypePattern
Identifier string `json:"identifier"`
}
type DefinitionChange ¶
type DefinitionChange interface {
PreviousDefinition() TypeDefinition
LatestDefinition() TypeDefinition
}
type DefinitionChangeIncompatible ¶
type DefinitionChangeIncompatible struct {
DefinitionPair
Reason string
}
type DefinitionMeta ¶
type DefinitionMeta struct {
NodeMeta
Name string `json:"name"`
Namespace string `json:"-"`
TypeParameters []*GenericTypeParameter `json:"typeParameters,omitempty"`
TypeArguments []Type `json:"typeArguments,omitempty"`
Comment string `json:"comment,omitempty"`
}
---------------------------------------------------------------------------- DefinitionMeta
func (*DefinitionMeta) GetQualifiedName ¶
func (meta *DefinitionMeta) GetQualifiedName() string
func (*DefinitionMeta) UnmarshalYAML ¶
func (meta *DefinitionMeta) UnmarshalYAML(value *yaml.Node) error
type DefinitionPair ¶
type DefinitionPair struct {
Old TypeDefinition
New TypeDefinition
}
func (*DefinitionPair) LatestDefinition ¶
func (tc *DefinitionPair) LatestDefinition() TypeDefinition
func (*DefinitionPair) PreviousDefinition ¶
func (tc *DefinitionPair) PreviousDefinition() TypeDefinition
type Dimensionality ¶
type Dimensionality interface {
Node
// contains filtered or unexported methods
}
type DiscardPattern ¶
type DiscardPattern struct {
NodeMeta
}
type EnumChange ¶
type EnumChange struct {
DefinitionPair
BaseTypeChange TypeChange
ValuesAdded []string
ValuesRemoved []string
ValuesChanged []string
}
type EnumDefinition ¶
type EnumDefinition struct {
*DefinitionMeta `yaml:"-,inline"`
BaseType Type `json:"base,omitempty"`
IsFlags bool `json:"-"`
Values EnumValues `json:"values"`
}
---------------------------------------------------------------------------- Enums
func (*EnumDefinition) GetDefinitionMeta ¶
func (e *EnumDefinition) GetDefinitionMeta() *DefinitionMeta
func (*EnumDefinition) GetZeroValue ¶
func (e *EnumDefinition) GetZeroValue() *EnumValue
func (*EnumDefinition) UnmarshalYAML ¶
func (enum *EnumDefinition) UnmarshalYAML(value *yaml.Node) error
type EnumValues ¶
type EnumValues []*EnumValue
func UnmarshalEnumValues ¶
func UnmarshalEnumValues(flags bool, value *yaml.Node) (*EnumValues, error)
type Environment ¶
type Environment struct {
Namespaces []*Namespace `json:"namespaces"`
SymbolTable SymbolTable `json:"-"`
}
---------------------------------------------------------------------------- Environment + Namespace
func Validate ¶
func Validate(namespaces []*Namespace) (*Environment, error)
func ValidateEvolution ¶
func ValidateEvolution(latest *Environment, predecessors []*Environment, versionLabels []string) (*Environment, []string, error)
func (*Environment) GetNodeMeta ¶
func (n *Environment) GetNodeMeta() *NodeMeta
func (*Environment) GetTopLevelNamespace ¶
func (n *Environment) GetTopLevelNamespace() *Namespace
type EvolutionContext ¶
type EvolutionContext struct {
BasePairs map[string]map[string]*DefinitionPair
SemanticPairs map[string]map[string]*DefinitionPair
Changes map[string]map[string]DefinitionChange
}
type Expression ¶
type Expression interface {
Node
GetResolvedType() Type
IsReference() bool
// contains filtered or unexported methods
}
func ParseExpression ¶
func ParseExpression(input string, lineOffset, columnOffet int) (Expression, error)
func UnmarshalExpression ¶
func UnmarshalExpression(value *yaml.Node) (Expression, error)
type Fields ¶
type Fields []*Field
---------------------------------------------------------------------------- Fields
type FloatingPointLiteralExpression ¶
func (*FloatingPointLiteralExpression) GetResolvedType ¶
func (e *FloatingPointLiteralExpression) GetResolvedType() Type
func (*FloatingPointLiteralExpression) IsReference ¶
func (e *FloatingPointLiteralExpression) IsReference() bool
func (*FloatingPointLiteralExpression) MarshalJSON ¶
func (e *FloatingPointLiteralExpression) MarshalJSON() ([]byte, error)
type FunctionCallExpression ¶
type FunctionCallExpression struct {
NodeMeta
FunctionName string `json:"function"`
Arguments []Expression `json:"arguments"`
ResolvedType Type `json:"-"`
}
func (*FunctionCallExpression) GetResolvedType ¶
func (e *FunctionCallExpression) GetResolvedType() Type
func (*FunctionCallExpression) IsReference ¶
func (e *FunctionCallExpression) IsReference() bool
func (*FunctionCallExpression) MarshalJSON ¶
func (e *FunctionCallExpression) MarshalJSON() ([]byte, error)
type GeneralizedType ¶
type GeneralizedType struct {
NodeMeta
Cases TypeCases
Dimensionality Dimensionality
}
func ToGeneralizedType ¶
func ToGeneralizedType(t Type) *GeneralizedType
func ToUnionOfUnderlyingTypes ¶
func ToUnionOfUnderlyingTypes(t *GeneralizedType) *GeneralizedType
Convert a Union's TypeCases to their respective underlying Types
func UnmarshalArrayYAML ¶
func UnmarshalArrayYAML(value *yaml.Node) (*GeneralizedType, error)
func UnmarshalMapYAML ¶
func UnmarshalMapYAML(value *yaml.Node) (*GeneralizedType, error)
func UnmarshalStreamYAML ¶
func UnmarshalStreamYAML(value *yaml.Node) (*GeneralizedType, error)
func UnmarshalUnionYAML ¶
func UnmarshalUnionYAML(value *yaml.Node) (*GeneralizedType, error)
func UnmarshalVectorYAML ¶
func UnmarshalVectorYAML(value *yaml.Node) (*GeneralizedType, error)
func (*GeneralizedType) MarshalJSON ¶
func (t *GeneralizedType) MarshalJSON() ([]byte, error)
func (*GeneralizedType) ToScalar ¶
func (t *GeneralizedType) ToScalar() Type
type GenericTypeParameter ¶
---------------------------------------------------------------------------- Generics
func (*GenericTypeParameter) GetDefinitionMeta ¶
func (p *GenericTypeParameter) GetDefinitionMeta() *DefinitionMeta
func (*GenericTypeParameter) MarshalJSON ¶
func (t *GenericTypeParameter) MarshalJSON() ([]byte, error)
type IntegerLiteralExpression ¶
func (*IntegerLiteralExpression) GetResolvedType ¶
func (e *IntegerLiteralExpression) GetResolvedType() Type
func (*IntegerLiteralExpression) IsReference ¶
func (e *IntegerLiteralExpression) IsReference() bool
func (*IntegerLiteralExpression) MarshalJSON ¶
func (e *IntegerLiteralExpression) MarshalJSON() ([]byte, error)
type Map ¶
Map implements Dimensionality on a GeneralizedType. The Value type of the map is the Cases of the GeneralizedType.
type MarshaledBytes ¶
type MarshaledBytes []byte
func (MarshaledBytes) MarshalJSON ¶
func (b MarshaledBytes) MarshalJSON() ([]byte, error)
type MemberAccessExpression ¶
type MemberAccessExpression struct {
NodeMeta
Target Expression `json:"target,omitempty"`
Member string `json:"member,omitempty"`
Kind MemberAccessKind `json:"kind"`
ResolvedType Type `json:"-"`
}
func (*MemberAccessExpression) GetResolvedType ¶
func (e *MemberAccessExpression) GetResolvedType() Type
func (*MemberAccessExpression) IsReference ¶
func (e *MemberAccessExpression) IsReference() bool
func (*MemberAccessExpression) MarshalJSON ¶
func (e *MemberAccessExpression) MarshalJSON() ([]byte, error)
type MemberAccessKind ¶
type MemberAccessKind int
const ( MemberAccessUnknown MemberAccessKind = iota MemberAccessField MemberAccessComputedField MemberAccessVariable )
func (*MemberAccessKind) MarshalJSON ¶
func (k *MemberAccessKind) MarshalJSON() ([]byte, error)
type NamedType ¶
type NamedType struct {
*DefinitionMeta
Type `json:"type"`
}
---------------------------------------------------------------------------- Named types (arrays etc.)
func (*NamedType) GetDefinitionMeta ¶
func (nt *NamedType) GetDefinitionMeta() *DefinitionMeta
func (*NamedType) GetNodeMeta ¶
type NamedTypeChange ¶
type NamedTypeChange struct {
DefinitionPair
TypeChange TypeChange
}
type Namespace ¶
type Namespace struct {
Name string `json:"name"`
TypeDefinitions TypeDefinitions `json:"types,omitempty"`
Protocols []*ProtocolDefinition `json:"protocols,omitempty"`
Versions []string `json:"-"`
DefinitionChanges map[string][]DefinitionChange `json:"-"`
References []*Namespace `json:"-"`
IsTopLevel bool `json:"-"`
}
func ParsePackageContents ¶
func ParsePackageContents(pkgInfo *packaging.PackageInfo) (*Namespace, error)
func ParseYamlInDir ¶
Parses all model YAML files, combining them into a single Namespace path can be a single YAML file or a directory containing YAML files
func (*Namespace) GetAllChildReferences ¶
Returns the flattened set of all direct+indirectly referenced namespaces (e.g. imports)
func (*Namespace) GetNodeMeta ¶
type Node ¶
type Node interface {
GetNodeMeta() *NodeMeta
}
---------------------------------------------------------------------------- Node
func Rewrite ¶
func Rewrite(node Node, rewriterFunc RewriterFunc) Node
Rewrites a Node by visiting it from the given root. If the given node in an *Environment, the symbol table will be updated.
func RewriteWithContext ¶
func RewriteWithContext[T any](node Node, context T, rewriter RewriterWithContextFunc[T]) Node
Rewrites a Node by visiting it from the given root, threading a context parameter throughout. If the given node in an *Environment, the symbol table will be updated.
type NodeMeta ¶
type NodeMeta struct {
File string `json:"-"`
Line int `json:"-"`
Column int `json:"-"`
Annotations map[string]any `json:"-"`
}
func (*NodeMeta) GetNodeMeta ¶
type PrimitiveDefinition ¶
type PrimitiveDefinition string
---------------------------------------------------------------------------- Primitive types
func GetPrimitiveType ¶
func GetPrimitiveType(t Type) (primitive PrimitiveDefinition, ok bool)
func (PrimitiveDefinition) GetDefinitionMeta ¶
func (t PrimitiveDefinition) GetDefinitionMeta() *DefinitionMeta
func (PrimitiveDefinition) GetNodeMeta ¶
func (n PrimitiveDefinition) GetNodeMeta() *NodeMeta
type PrimitiveKind ¶
type PrimitiveKind int
const ( PrimitiveKindInteger PrimitiveKind = iota PrimitiveKindFloatingPoint PrimitiveKindComplexFloatingPoint PrimitiveKindOther PrimitiveKindNotPrimitive )
func GetKindIfPrimitive ¶
func GetKindIfPrimitive(t Type) (primitiveKind PrimitiveKind, ok bool)
func GetPrimitiveKind ¶
func GetPrimitiveKind(t PrimitiveDefinition) PrimitiveKind
type ProtocolChange ¶
type ProtocolChange struct {
DefinitionPair
PreviousSchema string
StepsRemoved []*ProtocolStep
StepChanges []TypeChange
StepsReordered []*ProtocolStep
}
type ProtocolDefinition ¶
type ProtocolDefinition struct {
*DefinitionMeta
Sequence ProtocolSteps `json:"sequence"`
Versions map[string]*ProtocolChange `json:"-"`
}
---------------------------------------------------------------------------- Protocols
func (*ProtocolDefinition) GetDefinitionMeta ¶
func (p *ProtocolDefinition) GetDefinitionMeta() *DefinitionMeta
func (*ProtocolDefinition) UnmarshalYAML ¶
func (protocol *ProtocolDefinition) UnmarshalYAML(value *yaml.Node) error
type ProtocolRemoved ¶
type ProtocolRemoved struct {
DefinitionPair
}
type ProtocolSchema ¶
type ProtocolSchema struct {
Protocol *ProtocolDefinition `json:"protocol"`
Types []TypeDefinition `json:"types"`
}
func GetProtocolSchema ¶
func GetProtocolSchema(protocol *ProtocolDefinition, symbolTable SymbolTable) *ProtocolSchema
type ProtocolStep ¶
type ProtocolStep Field
func (*ProtocolStep) IsStream ¶
func (s *ProtocolStep) IsStream() bool
type ProtocolSteps ¶
type ProtocolSteps []*ProtocolStep
func (*ProtocolSteps) UnmarshalYAML ¶
func (steps *ProtocolSteps) UnmarshalYAML(value *yaml.Node) error
type RecordChange ¶
type RecordChange struct {
DefinitionPair
FieldsAdded []*Field
FieldRemoved []bool
FieldChanges []TypeChange
NewFieldIndex []int
}
type RecordDefinition ¶
type RecordDefinition struct {
*DefinitionMeta
Fields Fields `json:"fields"`
ComputedFields ComputedFields `json:"computedFields,omitempty"`
}
---------------------------------------------------------------------------- Records
func (*RecordDefinition) GetDefinitionMeta ¶
func (r *RecordDefinition) GetDefinitionMeta() *DefinitionMeta
func (*RecordDefinition) UnmarshalYAML ¶
func (rec *RecordDefinition) UnmarshalYAML(value *yaml.Node) error
type Rewriter ¶
type Rewriter struct {
// contains filtered or unexported fields
}
func (*Rewriter) DefaultRewrite ¶
type RewriterFunc ¶
type RewriterWithContext ¶
type RewriterWithContext[T any] struct { // contains filtered or unexported fields }
func (*RewriterWithContext[T]) DefaultRewrite ¶
func (rewriter *RewriterWithContext[T]) DefaultRewrite(node Node, context T) Node
func (*RewriterWithContext[T]) Rewrite ¶
func (rewriter *RewriterWithContext[T]) Rewrite(node Node, context T) Node
type RewriterWithContextFunc ¶
type RewriterWithContextFunc[T any] func(node Node, context T, self *RewriterWithContext[T]) Node
type SimpleType ¶
type SimpleType struct {
NodeMeta
Name string
TypeArguments []Type
ResolvedDefinition TypeDefinition
}
func (*SimpleType) MarshalJSON ¶
func (t *SimpleType) MarshalJSON() ([]byte, error)
type SinkWarningOrError ¶
type StringLiteralExpression ¶
func (*StringLiteralExpression) GetResolvedType ¶
func (e *StringLiteralExpression) GetResolvedType() Type
func (*StringLiteralExpression) IsReference ¶
func (e *StringLiteralExpression) IsReference() bool
func (*StringLiteralExpression) MarshalJSON ¶
func (e *StringLiteralExpression) MarshalJSON() ([]byte, error)
type SubscriptArgument ¶
type SubscriptArgument struct {
NodeMeta
Label string `json:"label,omitempty"`
Value Expression `json:"expression"`
}
type SubscriptExpression ¶
type SubscriptExpression struct {
NodeMeta
Target Expression `json:"target,omitempty"`
Arguments []*SubscriptArgument `json:"arguments"`
ResolvedType Type `json:"-"`
}
func (*SubscriptExpression) GetResolvedType ¶
func (e *SubscriptExpression) GetResolvedType() Type
func (*SubscriptExpression) IsReference ¶
func (e *SubscriptExpression) IsReference() bool
func (*SubscriptExpression) MarshalJSON ¶
func (e *SubscriptExpression) MarshalJSON() ([]byte, error)
type SwitchCase ¶
type SwitchCase struct {
NodeMeta
Pattern Pattern `json:"pattern"`
Expression Expression `json:"expression"`
}
type SwitchExpression ¶
type SwitchExpression struct {
NodeMeta
Target Expression `json:"target"`
Cases []*SwitchCase `json:"cases"`
ResolvedType Type `json:"-"`
}
func (*SwitchExpression) GetResolvedType ¶
func (e *SwitchExpression) GetResolvedType() Type
func (*SwitchExpression) IsReference ¶
func (e *SwitchExpression) IsReference() bool
func (*SwitchExpression) MarshalJSON ¶
func (e *SwitchExpression) MarshalJSON() ([]byte, error)
type SymbolTable ¶
type SymbolTable map[string]TypeDefinition
func (SymbolTable) Clone ¶
func (st SymbolTable) Clone() SymbolTable
func (SymbolTable) GetGenericTypeDefinition ¶
func (st SymbolTable) GetGenericTypeDefinition(possiblyGenericType TypeDefinition) TypeDefinition
type Type ¶
type Type interface {
Node
// contains filtered or unexported methods
}
---------------------------------------------------------------------------- Type
func GetCommonType ¶
func GetUnderlyingType ¶
func NormalizeGenericTypeParameters ¶
Returns a type where all generic type parameter references are replaces with type parameters with names "T1", "T2", etc.
type TypeCase ¶
type TypeCase struct {
NodeMeta
Tag string `json:"tag,omitempty"`
ExplicitTag bool `json:"explicitTag,omitempty"`
Type Type `json:"type"`
}
func (*TypeCase) IsNullType ¶
func (*TypeCase) MarshalJSON ¶
type TypeCases ¶
type TypeCases []*TypeCase
func (*TypeCases) HasNullOption ¶
func (*TypeCases) IsOptional ¶
func (TypeCases) MarshalJSON ¶
type TypeChange ¶
type TypeChange interface {
OldType() Type
NewType() Type
Inverse() TypeChange
}
type TypeChangeComplexToComplex ¶
type TypeChangeComplexToComplex struct{ TypePair }
func (*TypeChangeComplexToComplex) Inverse ¶
func (tc *TypeChangeComplexToComplex) Inverse() TypeChange
type TypeChangeDefinitionChanged ¶
type TypeChangeDefinitionChanged struct {
TypePair
DefinitionChange
}
func (*TypeChangeDefinitionChanged) Inverse ¶
func (tc *TypeChangeDefinitionChanged) Inverse() TypeChange
type TypeChangeIncompatible ¶
type TypeChangeIncompatible struct{ TypePair }
func (*TypeChangeIncompatible) Inverse ¶
func (tc *TypeChangeIncompatible) Inverse() TypeChange
type TypeChangeNumberToNumber ¶
type TypeChangeNumberToNumber struct{ TypePair }
func (*TypeChangeNumberToNumber) Inverse ¶
func (tc *TypeChangeNumberToNumber) Inverse() TypeChange
type TypeChangeNumberToString ¶
type TypeChangeNumberToString struct{ TypePair }
func (*TypeChangeNumberToString) Inverse ¶
func (tc *TypeChangeNumberToString) Inverse() TypeChange
type TypeChangeOptionalToScalar ¶
type TypeChangeOptionalToScalar struct{ TypePair }
func (*TypeChangeOptionalToScalar) Inverse ¶
func (tc *TypeChangeOptionalToScalar) Inverse() TypeChange
type TypeChangeOptionalToUnion ¶
func (*TypeChangeOptionalToUnion) Inverse ¶
func (tc *TypeChangeOptionalToUnion) Inverse() TypeChange
type TypeChangeOptionalTypeChanged ¶
type TypeChangeOptionalTypeChanged struct {
TypePair
InnerChange TypeChange
}
func (*TypeChangeOptionalTypeChanged) Inverse ¶
func (tc *TypeChangeOptionalTypeChanged) Inverse() TypeChange
type TypeChangeScalarToOptional ¶
type TypeChangeScalarToOptional struct{ TypePair }
func (*TypeChangeScalarToOptional) Inverse ¶
func (tc *TypeChangeScalarToOptional) Inverse() TypeChange
type TypeChangeScalarToUnion ¶
func (*TypeChangeScalarToUnion) Inverse ¶
func (tc *TypeChangeScalarToUnion) Inverse() TypeChange
type TypeChangeStepAdded ¶
type TypeChangeStepAdded struct{ TypePair }
func (*TypeChangeStepAdded) Inverse ¶
func (tc *TypeChangeStepAdded) Inverse() TypeChange
type TypeChangeStreamTypeChanged ¶
type TypeChangeStreamTypeChanged struct {
TypePair
InnerChange TypeChange
}
func (*TypeChangeStreamTypeChanged) Inverse ¶
func (tc *TypeChangeStreamTypeChanged) Inverse() TypeChange
type TypeChangeStringToNumber ¶
type TypeChangeStringToNumber struct{ TypePair }
func (*TypeChangeStringToNumber) Inverse ¶
func (tc *TypeChangeStringToNumber) Inverse() TypeChange
type TypeChangeUnionToOptional ¶
func (*TypeChangeUnionToOptional) Inverse ¶
func (tc *TypeChangeUnionToOptional) Inverse() TypeChange
type TypeChangeUnionToScalar ¶
func (*TypeChangeUnionToScalar) Inverse ¶
func (tc *TypeChangeUnionToScalar) Inverse() TypeChange
type TypeChangeUnionTypesetChanged ¶
func (*TypeChangeUnionTypesetChanged) Inverse ¶
func (tc *TypeChangeUnionTypesetChanged) Inverse() TypeChange
type TypeChangeVectorTypeChanged ¶
type TypeChangeVectorTypeChanged struct {
TypePair
InnerChange TypeChange
}
func (*TypeChangeVectorTypeChanged) Inverse ¶
func (tc *TypeChangeVectorTypeChanged) Inverse() TypeChange
type TypeConversionExpression ¶
type TypeConversionExpression struct {
NodeMeta
Expression Expression `json:"expression"`
Type Type `json:"type"`
}
func (*TypeConversionExpression) GetResolvedType ¶
func (e *TypeConversionExpression) GetResolvedType() Type
func (*TypeConversionExpression) IsReference ¶
func (e *TypeConversionExpression) IsReference() bool
func (*TypeConversionExpression) MarshalJSON ¶
func (e *TypeConversionExpression) MarshalJSON() ([]byte, error)
type TypeDefinition ¶
type TypeDefinition interface {
Node
GetDefinitionMeta() *DefinitionMeta
}
---------------------------------------------------------------------------- TypeDefinition
func MakeGenericType ¶
func MakeGenericType(genericTypeDefinition TypeDefinition, typeArguments []Type, shallow bool) (TypeDefinition, error)
func UnmarshalTypeDefinition ¶
func UnmarshalTypeDefinition(value *yaml.Node, definitionMeta *DefinitionMeta) (TypeDefinition, error)
type TypeDefinitions ¶
type TypeDefinitions []TypeDefinition
func (*TypeDefinitions) MarshalJSON ¶
func (tc *TypeDefinitions) MarshalJSON() ([]byte, error)
type TypePattern ¶
type TypeSyntaxWriter ¶
type TypeSyntaxWriter[TContext any] func(self TypeSyntaxWriter[TContext], typeOrTypeDef Node, context TContext) string
func (TypeSyntaxWriter[TContext]) ToSyntax ¶
func (writer TypeSyntaxWriter[TContext]) ToSyntax(typeOrTypeDef Node, context TContext) string
type UnaryExpression ¶
type UnaryExpression struct {
NodeMeta
Operator UnaryOperator `json:"op"`
Expression Expression `json:"expression"`
}
func (*UnaryExpression) GetResolvedType ¶
func (e *UnaryExpression) GetResolvedType() Type
func (*UnaryExpression) IsReference ¶
func (e *UnaryExpression) IsReference() bool
func (*UnaryExpression) MarshalJSON ¶
func (e *UnaryExpression) MarshalJSON() ([]byte, error)
type ValidationPass ¶
type ValidationPass func(env *Environment, errorSink *validation.ErrorSink) *Environment
type Visitor ¶
type Visitor struct {
// contains filtered or unexported fields
}
func (Visitor) VisitChildren ¶
type VisitorFunc ¶
type VisitorWithContext ¶
type VisitorWithContext[T any] struct { // contains filtered or unexported fields }
func (VisitorWithContext[T]) Visit ¶
func (visitor VisitorWithContext[T]) Visit(node Node, context T)
func (VisitorWithContext[T]) VisitChildren ¶
func (visitor VisitorWithContext[T]) VisitChildren(node Node, context T)
type VisitorWithContextFunc ¶
type VisitorWithContextFunc[T any] func(self VisitorWithContext[T], node Node, context T)
Source Files
¶
- evolution.go
- evolution_changes.go
- expressionparser.go
- json.go
- protocolschema.go
- rewriter.go
- typefunctions.go
- types.go
- typesyntaxwriter.go
- validation.go
- validation_arrays.go
- validation_computed_fields.go
- validation_enums.go
- validation_maps.go
- validation_topological_sort.go
- validation_type_resolution.go
- validation_unions.go
- visitor.go
- yaml.go