languages

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgumentMapping

type ArgumentMapping struct {
	Direct             *DirectArgMapping
	Runtime            *RuntimeArgMapping
	Builder            *BuilderArgMapping
	BuilderDisjunction []BuilderChoiceMapping
	Array              *ArrayArgMapping
	Map                *MapArgMapping
	Disjunction        *DisjunctionArgMapping

	// TODO: used? necessary?
	Guards []MappingGuard
}

type ArrayArgMapping

type ArrayArgMapping struct {
	For       ast.Path
	ForType   ast.Type
	ForArg    *ArgumentMapping
	ValueAs   ast.Path
	ValueType ast.Type
}

type BuilderArgMapping

type BuilderArgMapping struct {
	ValuePath   ast.Path
	ValueType   ast.Type
	BuilderPkg  string
	BuilderName string
}

mapping between a JSON value and an argument delegated to a builder

type BuilderChoiceMapping

type BuilderChoiceMapping struct {
	Guards  []MappingGuard
	Builder BuilderArgMapping
}

type Config

type Config struct {
	// Debug turns on or off the debugging mode.
	Debug bool

	// Types indicates whether types should be generated or not.
	Types bool

	// Builders indicates whether builders should be generated or not.
	Builders bool

	// Converters indicates whether converters should be generated or not.
	Converters bool

	// APIReference indicates whether an API reference should be generated or not.
	APIReference bool
}

Config represents global configuration options, to be used by all jennies.

type Context

type Context struct {
	Schemas  ast.Schemas
	Builders ast.Builders
}

func GenerateBuilderNilChecks

func GenerateBuilderNilChecks(language Language, context Context) (Context, error)

func (*Context) BuildersForType added in v0.0.8

func (context *Context) BuildersForType(typeDef ast.Type) ast.Builders

func (*Context) IsArrayOfKinds

func (context *Context) IsArrayOfKinds(def ast.Type, kinds ...ast.Kind) bool

func (*Context) IsDisjunctionOfBuilders

func (context *Context) IsDisjunctionOfBuilders(def ast.Type) bool

func (*Context) IsMapOfKinds

func (context *Context) IsMapOfKinds(def ast.Type, kinds ...ast.Kind) bool

func (*Context) LocateObject

func (context *Context) LocateObject(pkg string, name string) (ast.Object, bool)

func (*Context) LocateObjectByRef

func (context *Context) LocateObjectByRef(ref ast.RefType) (ast.Object, bool)

func (Context) PackagesForVariant added in v0.0.9

func (context Context) PackagesForVariant(variant string) []string

func (*Context) ResolveRefs

func (context *Context) ResolveRefs(def ast.Type) ast.Type

func (*Context) ResolveToBuilder

func (context *Context) ResolveToBuilder(def ast.Type) bool

func (*Context) ResolveToComposableSlot

func (context *Context) ResolveToComposableSlot(def ast.Type) (ast.Type, bool)

func (*Context) ResolveToStruct

func (context *Context) ResolveToStruct(def ast.Type) bool

func (Context) SchemasForVariant added in v0.0.17

func (context Context) SchemasForVariant(variant string) []*ast.Schema

type ConversionMapping

type ConversionMapping struct {
	// for i, panel := range input.Panels { WithPanel(panel) }
	RepeatFor   ast.Path // `input.Panels`
	RepeatAs    string   // `panel`
	RepeatIndex string   // `i`

	Options []OptionMapping
}

type Converter

type Converter struct {
	Package string

	BuilderName string
	Input       ConverterInput

	// FIXME: assuming we only have direct mappings here is... *optimistic*.
	ConstructorArgs []DirectArgMapping

	Mappings []ConversionMapping
}

type ConverterGenerator

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

func NewConverterGenerator

func NewConverterGenerator(nullableTypes NullableConfig) *ConverterGenerator

func (*ConverterGenerator) FromBuilder

func (generator *ConverterGenerator) FromBuilder(context Context, builder ast.Builder) Converter

type ConverterInput

type ConverterInput struct {
	ArgName string
	TypeRef ast.RefType
}

type DirectArgMapping

type DirectArgMapping struct {
	ValuePath ast.Path // direct mapping between a JSON value and an argument
	ValueType ast.Type
}

type DisjunctionArgMapping

type DisjunctionArgMapping struct {
	Branches []DisjunctionBranchArgMapping
}

type DisjunctionBranchArgMapping

type DisjunctionBranchArgMapping struct {
	Type ast.Type
	Of   *DirectArgMapping
	Arg  *ArgumentMapping
}

type Language

type Language interface {
	Name() string
	Jennies(config Config) *codejen.JennyList[Context]
	CompilerPasses() compiler.Passes
}

type Languages

type Languages map[string]Language

func (Languages) AsLanguageRefs

func (languages Languages) AsLanguageRefs() []string

type MapArgMapping

type MapArgMapping struct {
	For       ast.Path
	ForType   ast.Type
	ForArg    *ArgumentMapping
	ValueAs   ast.Path
	IndexType ast.Type
	ValueType ast.Type
}

type MappingGuard

type MappingGuard struct {
	Path  ast.Path
	Op    ast.Op
	Value any
}

func (MappingGuard) String

func (guard MappingGuard) String() string

type NullableConfig

type NullableConfig struct {
	Kinds              []ast.Kind
	ProtectArrayAppend bool
	AnyIsNullable      bool
}

func (NullableConfig) TypeIsNullable

func (nullableConfig NullableConfig) TypeIsNullable(typeDef ast.Type) bool

type NullableKindsProvider

type NullableKindsProvider interface {
	NullableKinds() NullableConfig
}

type OptionMapping

type OptionMapping struct {
	Option ast.Option // option in the builder

	Guards []MappingGuard
	Args   []ArgumentMapping
}

func (OptionMapping) ArgumentGuards

func (optMapping OptionMapping) ArgumentGuards() []MappingGuard

type RuntimeArgMapping

type RuntimeArgMapping struct {
	FuncName string
	Args     []*DirectArgMapping
}

Jump to

Keyboard shortcuts

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