Documentation
¶
Index ¶
- Constants
- func WriteGoFile(outFile *os.File, decls []dst.Decl, packagePath string)
- type AlwaysPredicate
- type AndPredicate
- type ComplexType
- type Config
- type DeepEqualsPredicate
- type EqualsPredicate
- type Expression
- type ExtraParam
- type ForAllPredicate
- type IdentifierExpression
- type IsAttachmentPredicate
- type IsHashableStructPredicate
- type IsIntersectionSubsetPredicate
- type IsParameterizedSubtypePredicate
- type IsResourcePredicate
- type IsStorablePredicate
- type KeyValues
- type MemberExpression
- type NeverPredicate
- type NotPredicate
- type OneOfExpression
- type OrPredicate
- type ParsingError
- type PermitsPredicate
- type Predicate
- type Predicates
- type ReturnCovariantPredicate
- type Rule
- type RulesFile
- type SetContainsPredicate
- type SimpleType
- type SubTypeCheckGenerator
- type SubTypeGenError
- type SubtypePredicate
- type Type
- type TypeAssertionPredicate
- type TypeExpression
Constants ¶
const ( TypePlaceholderSuffix = "Type" TypePlaceholderStorable = "Storable" TypePlaceholderOptional = "Optional" TypePlaceholderReference = "Reference" TypePlaceholderDictionary = "Dictionary" TypePlaceholderVariableSized = "VariableSized" TypePlaceholderConstantSized = "ConstantSized" TypePlaceholderIntersection = "Intersection" TypePlaceholderFunction = "Function" TypePlaceholderComposite = "Composite" TypePlaceholderInterface = "Interface" TypePlaceholderParameterized = "Parameterized" TypePlaceholderConforming = "Conforming" FieldNameReferencedType = "ReferencedType" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AlwaysPredicate ¶
type AlwaysPredicate struct {
// contains filtered or unexported fields
}
AlwaysPredicate represents an always-true condition.
func (AlwaysPredicate) Description ¶
func (p AlwaysPredicate) Description() string
type AndPredicate ¶
type AndPredicate struct {
Predicates []Predicate `yaml:"and"`
// contains filtered or unexported fields
}
AndPredicate represents a logical AND predicate.
func (AndPredicate) Description ¶
func (p AndPredicate) Description() string
type ComplexType ¶
type ComplexType struct {
// contains filtered or unexported fields
}
func (ComplexType) Name ¶
func (t ComplexType) Name() string
type Config ¶
type Config struct {
// Prefixes and the suffixes to be added to the type-placeholder
// to customize the type-names to match the naming conventions.
// e.g: `PrimitiveStaticTypeString` at runtime, vs `StringType` at checking time.
SimpleTypePrefix string
SimpleTypeSuffix string
ComplexTypePrefix string
ComplexTypeSuffix string
// Extra parameters to be added to the generated function signatures,
// other than the common parameters.
// For e.g: runtime generated function takes a `TypeConverter` as an extra argument.
ExtraParams []ExtraParam
// Types to be skipped from generating a subtype-check.
// For e.g: Runtime doesn't have a `StorableType`
SkipTypes map[string]struct{}
// A set indicating what complex types needed to be treated as
// non-pointer types in the generated Go code.
NonPointerTypes map[string]struct{}
// A mapping to customize the generated names.
// For e.g: A field named `Foo` in the `rules.yaml`,
// can be generated as `Bar` in the generated Go code,
// by adding a mapping from `Foo -> Bar`.
NameMapping map[string]string
// List of arguments to be passed on to the `ElementType` method on array-type.
ArrayElementTypeMethodArgs []any
}
type DeepEqualsPredicate ¶
type DeepEqualsPredicate struct {
Source Expression `yaml:"source"`
Target Expression `yaml:"target"`
// contains filtered or unexported fields
}
DeepEqualsPredicate represents a deep equality check, defined with `Equals` method.
func (DeepEqualsPredicate) Append ¶
func (p DeepEqualsPredicate) Append(comments string) description
func (DeepEqualsPredicate) Description ¶
func (p DeepEqualsPredicate) Description() string
type EqualsPredicate ¶
type EqualsPredicate struct {
Source Expression `yaml:"source"`
Target Expression `yaml:"target"`
// contains filtered or unexported fields
}
EqualsPredicate represents an equality check using `==` operator.
func (EqualsPredicate) Description ¶
func (p EqualsPredicate) Description() string
type Expression ¶
type Expression interface {
// contains filtered or unexported methods
}
type ExtraParam ¶
type ForAllPredicate ¶
type ForAllPredicate struct {
Source Expression `yaml:"source"`
Target Expression `yaml:"target"`
Predicate Predicate `yaml:"predicate"`
// contains filtered or unexported fields
}
func (ForAllPredicate) Description ¶
func (p ForAllPredicate) Description() string
type IdentifierExpression ¶
type IdentifierExpression struct {
Name string
}
type IsAttachmentPredicate ¶
type IsAttachmentPredicate struct {
Expression Expression `yaml:"isAttachment"`
// contains filtered or unexported fields
}
IsAttachmentPredicate represents an attachment type check.
func (IsAttachmentPredicate) Append ¶
func (p IsAttachmentPredicate) Append(comments string) description
func (IsAttachmentPredicate) Description ¶
func (p IsAttachmentPredicate) Description() string
type IsHashableStructPredicate ¶
type IsHashableStructPredicate struct {
Expression Expression `yaml:"isHashableStruct"`
// contains filtered or unexported fields
}
IsHashableStructPredicate represents a hashable struct type check.
func (IsHashableStructPredicate) Append ¶
func (p IsHashableStructPredicate) Append(comments string) description
func (IsHashableStructPredicate) Description ¶
func (p IsHashableStructPredicate) Description() string
type IsIntersectionSubsetPredicate ¶
type IsIntersectionSubsetPredicate struct {
Sub Expression `yaml:"sub"`
Super Expression `yaml:"super"`
// contains filtered or unexported fields
}
func (IsIntersectionSubsetPredicate) Append ¶
func (p IsIntersectionSubsetPredicate) Append(comments string) description
func (IsIntersectionSubsetPredicate) Description ¶
func (p IsIntersectionSubsetPredicate) Description() string
type IsParameterizedSubtypePredicate ¶
type IsParameterizedSubtypePredicate struct {
Sub Expression `yaml:"sub"`
Super Expression `yaml:"super"`
// contains filtered or unexported fields
}
func (IsParameterizedSubtypePredicate) Append ¶
func (p IsParameterizedSubtypePredicate) Append(comments string) description
func (IsParameterizedSubtypePredicate) Description ¶
func (p IsParameterizedSubtypePredicate) Description() string
type IsResourcePredicate ¶
type IsResourcePredicate struct {
Expression Expression `yaml:"isResource"`
// contains filtered or unexported fields
}
IsResourcePredicate represents a resource type check.
func (IsResourcePredicate) Append ¶
func (p IsResourcePredicate) Append(comments string) description
func (IsResourcePredicate) Description ¶
func (p IsResourcePredicate) Description() string
type IsStorablePredicate ¶
type IsStorablePredicate struct {
Expression Expression `yaml:"isStorable"`
// contains filtered or unexported fields
}
IsStorablePredicate represents a storable type check.
func (IsStorablePredicate) Append ¶
func (p IsStorablePredicate) Append(comments string) description
func (IsStorablePredicate) Description ¶
func (p IsStorablePredicate) Description() string
type MemberExpression ¶
type MemberExpression struct {
Parent Expression
MemberName string
}
type NeverPredicate ¶
type NeverPredicate struct {
// contains filtered or unexported fields
}
NeverPredicate represents a never-true condition.
func (NeverPredicate) Description ¶
func (p NeverPredicate) Description() string
type NotPredicate ¶
type NotPredicate struct {
Predicate Predicate `yaml:"not"`
// contains filtered or unexported fields
}
NotPredicate represents a logical NOT predicate.
func (NotPredicate) Description ¶
func (p NotPredicate) Description() string
type OneOfExpression ¶
type OneOfExpression struct {
Expressions []Expression
}
type OrPredicate ¶
type OrPredicate struct {
Predicates []Predicate `yaml:"or"`
// contains filtered or unexported fields
}
OrPredicate represents a logical OR predicate.
func (OrPredicate) Description ¶
func (p OrPredicate) Description() string
type ParsingError ¶
func NewParsingError ¶
func NewParsingError(message string, node yaml.Node) ParsingError
func (ParsingError) Error ¶
func (p ParsingError) Error() string
type PermitsPredicate ¶
type PermitsPredicate struct {
Sub Expression `yaml:"sub"`
Super Expression `yaml:"super"`
// contains filtered or unexported fields
}
PermitsPredicate represents a permits check.
func (PermitsPredicate) Description ¶
func (p PermitsPredicate) Description() string
type Predicate ¶
type Predicate interface {
Description() string
// contains filtered or unexported methods
}
Predicate represents different types of predicates in rules.
type Predicates ¶
type Predicates struct {
// contains filtered or unexported fields
}
Predicates is a collection of predicates.
func NewPredicateChain ¶
func NewPredicateChain(predicates []Predicate) *Predicates
type ReturnCovariantPredicate ¶
type ReturnCovariantPredicate struct {
Source Expression `yaml:"source"`
Target Expression `yaml:"target"`
// contains filtered or unexported fields
}
ReturnCovariantPredicate represents a return covariant check.
func (ReturnCovariantPredicate) Append ¶
func (p ReturnCovariantPredicate) Append(comments string) description
func (ReturnCovariantPredicate) Description ¶
func (p ReturnCovariantPredicate) Description() string
type Rule ¶
type Rule struct {
SuperType Type `yaml:"super"`
Predicate Predicate `yaml:"predicate"`
// contains filtered or unexported fields
}
Rule represents a single subtype rule
func (Rule) Description ¶
func (p Rule) Description() string
type RulesFile ¶
type RulesFile struct {
Rules []Rule `yaml:"rules"`
// contains filtered or unexported fields
}
RulesFile represents the entire YAML configuration
func ParseRules ¶
ParseRules reads and parses the YAML rules file
func ParseRulesFromBytes ¶
func (RulesFile) Description ¶
func (p RulesFile) Description() string
type SetContainsPredicate ¶
type SetContainsPredicate struct {
Set Expression `yaml:"set"`
Element Expression `yaml:"element"`
// contains filtered or unexported fields
}
func (SetContainsPredicate) Append ¶
func (p SetContainsPredicate) Append(comments string) description
func (SetContainsPredicate) Description ¶
func (p SetContainsPredicate) Description() string
type SimpleType ¶
type SimpleType struct {
// contains filtered or unexported fields
}
func (SimpleType) Name ¶
func (t SimpleType) Name() string
type SubTypeCheckGenerator ¶
type SubTypeCheckGenerator struct {
// contains filtered or unexported fields
}
func NewSubTypeCheckGenerator ¶
func NewSubTypeCheckGenerator(config Config) *SubTypeCheckGenerator
func (*SubTypeCheckGenerator) GenerateCheckSubTypeWithoutEqualityFunction ¶
func (gen *SubTypeCheckGenerator) GenerateCheckSubTypeWithoutEqualityFunction(rules RulesFile) []dst.Decl
GenerateCheckSubTypeWithoutEqualityFunction generates the complete checkSubTypeWithoutEquality function.
type SubTypeGenError ¶
func (*SubTypeGenError) Error ¶
func (e *SubTypeGenError) Error() string
type SubtypePredicate ¶
type SubtypePredicate struct {
Sub Expression `yaml:"sub"`
Super Expression `yaml:"super"`
// contains filtered or unexported fields
}
SubtypePredicate represents a subtype check.
func (SubtypePredicate) Description ¶
func (p SubtypePredicate) Description() string
type Type ¶
type Type interface {
Name() string
}
Type represents parsed type information using Cadence types
type TypeAssertionPredicate ¶
type TypeAssertionPredicate struct {
Source Expression `yaml:"source"`
Type Type `yaml:"type"`
// contains filtered or unexported fields
}
TypeAssertionPredicate represents a type assertion.
func (TypeAssertionPredicate) Append ¶
func (p TypeAssertionPredicate) Append(comments string) description
func (TypeAssertionPredicate) Description ¶
func (p TypeAssertionPredicate) Description() string
type TypeExpression ¶
type TypeExpression struct {
Type Type
}