codegen

package
v0.0.0-...-1191e93 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayType

type ArrayType struct {
	Type Type
}

func (ArrayType) Generate

func (a ArrayType) Generate(out *Emitter)

func (ArrayType) IsNillable

func (ArrayType) IsNillable() bool

type Constant

type Constant struct {
	Type  Type
	Name  string
	Value interface{}
}

Constant is a "const <name> = <value>".

func (*Constant) Generate

func (c *Constant) Generate(out *Emitter)

func (*Constant) GetName

func (c *Constant) GetName() string

type CustomNameType

type CustomNameType struct {
	Type string
}

func (CustomNameType) Generate

func (p CustomNameType) Generate(out *Emitter)

func (CustomNameType) IsNillable

func (CustomNameType) IsNillable() bool

type Decl

type Decl interface {
	Generate(out *Emitter)
}

type Emitter

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

func NewEmitter

func NewEmitter(maxLineLength uint) *Emitter

func (*Emitter) Bytes

func (e *Emitter) Bytes() []byte

func (*Emitter) Comment

func (e *Emitter) Comment(s string)

func (*Emitter) Indent

func (e *Emitter) Indent(n int)

func (*Emitter) MaxLineLength

func (e *Emitter) MaxLineLength() uint

func (*Emitter) Newline

func (e *Emitter) Newline()

func (*Emitter) Print

func (e *Emitter) Print(format string, args ...interface{})

func (*Emitter) Println

func (e *Emitter) Println(format string, args ...interface{})

func (*Emitter) String

func (e *Emitter) String() string

type EmptyInterfaceType

type EmptyInterfaceType struct{}

func (EmptyInterfaceType) Generate

func (EmptyInterfaceType) Generate(out *Emitter)

func (EmptyInterfaceType) IsNillable

func (EmptyInterfaceType) IsNillable() bool

type File

type File struct {
	FileName string
	Package  Package
}

func (*File) Generate

func (p *File) Generate(out *Emitter)

type Fragment

type Fragment func(*Emitter)

Fragment is an arbitary piece of code.

func (Fragment) Generate

func (f Fragment) Generate(out *Emitter)

type Import

type Import struct {
	Name          string
	QualifiedName string
}

Import is a "type <name> = <definition>".

func (*Import) Generate

func (i *Import) Generate(out *Emitter)

type MapType

type MapType struct {
	KeyType, ValueType Type
}

func (MapType) Generate

func (p MapType) Generate(out *Emitter)

func (MapType) IsNillable

func (MapType) IsNillable() bool

type Method

type Method struct {
	Impl func(*Emitter)
}

Method defines a method and how to generate it.

func (*Method) Generate

func (m *Method) Generate(out *Emitter)

type Named

type Named interface {
	Decl
	GetName() string
}

type NamedType

type NamedType struct {
	Package *Package
	Decl    *TypeDecl
}

func (NamedType) Generate

func (t NamedType) Generate(out *Emitter)

func (NamedType) GetName

func (t NamedType) GetName() string

func (NamedType) IsNillable

func (t NamedType) IsNillable() bool

type NullType

type NullType struct{}

func (NullType) Generate

func (NullType) Generate(out *Emitter)

func (NullType) IsNillable

func (NullType) IsNillable() bool

type Package

type Package struct {
	QualifiedName string
	Comment       string
	Decls         []Decl
	Imports       []Import
}

Package is a "package <name>; <body>".

func (*Package) AddDecl

func (p *Package) AddDecl(t Decl)

func (*Package) AddImport

func (p *Package) AddImport(qualifiedName, alias string)

func (*Package) Generate

func (p *Package) Generate(out *Emitter)

func (*Package) Name

func (p *Package) Name() string

type PointerType

type PointerType struct {
	Type Type
}

func (PointerType) Generate

func (p PointerType) Generate(out *Emitter)

func (PointerType) IsNillable

func (PointerType) IsNillable() bool

type PrimitiveType

type PrimitiveType struct {
	Type string
}

func (PrimitiveType) Generate

func (p PrimitiveType) Generate(out *Emitter)

func (PrimitiveType) IsNillable

func (PrimitiveType) IsNillable() bool

type StructField

type StructField struct {
	Name         string
	Type         Type
	Comment      string
	Tags         string
	JSONName     string
	DefaultValue interface{}
	SchemaType   *schemas.Type
}

func (*StructField) Generate

func (f *StructField) Generate(out *Emitter)

func (*StructField) GetName

func (f *StructField) GetName() string

type StructType

type StructType struct {
	Parents            []Type
	Fields             []StructField
	RequiredJSONFields []string
	Variants           []Type
}

func (*StructType) AddField

func (s *StructType) AddField(f StructField)

func (*StructType) AddParent

func (s *StructType) AddParent(f Type)

func (*StructType) AddVariant

func (s *StructType) AddVariant(f Type)

func (*StructType) Generate

func (s *StructType) Generate(out *Emitter)

func (StructType) IsNillable

func (StructType) IsNillable() bool

type Type

type Type interface {
	Decl
	IsNillable() bool
}

func PrimitiveTypeFromJSONSchemaType

func PrimitiveTypeFromJSONSchemaType(jsType string, pointer bool, intAsInt64 bool) (Type, error)

func WrapTypeInPointer

func WrapTypeInPointer(t Type) Type

type TypeDecl

type TypeDecl struct {
	Name    string
	Type    Type
	Comment string
}

TypeDecl is a "type <name> = <definition>".

func (*TypeDecl) Generate

func (td *TypeDecl) Generate(out *Emitter)

func (*TypeDecl) GetName

func (td *TypeDecl) GetName() string

type Var

type Var struct {
	Type  Type
	Name  string
	Value interface{}
}

Var is a "var <name> = <value>".

func (*Var) Generate

func (v *Var) Generate(out *Emitter)

func (*Var) GetName

func (v *Var) GetName() string

Jump to

Keyboard shortcuts

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