golang

package
v0.0.2-rc1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Annotation

type Annotation string

Annotation represents an annotation

const (
	// AnnotationGenerate represents the annotation for tgenerated code
	AnnotationGenerate Annotation = "stride:generate"
	// AnnotationDefine represents the annotation for user-defined code
	AnnotationDefine Annotation = "stride:define"
	// AnnotationNotice represents the annotation for note
	AnnotationNotice Annotation = "NOTE:"
)

func (Annotation) Comment

func (n Annotation) Comment(text string) string

Comment formats the annotation as comment

func (Annotation) Find

func (n Annotation) Find(decorations dst.Decorations) (string, bool)

Find returns the name of the annotation of exists in the decorations

func (Annotation) In

func (n Annotation) In(decorations dst.Decorations, term string) bool

In returns true if the annotation with given name exists in the decorations list

func (Annotation) Key

func (n Annotation) Key(text ...string) string

Key formats the annotation as key

type ArrayType

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

ArrayType builds an array type

func NewArrayType

func NewArrayType(name string) *ArrayType

NewArrayType creates a new ArrayType

func (*ArrayType) Commentf

func (b *ArrayType) Commentf(pattern string, args ...interface{})

Commentf adds a comment

func (*ArrayType) Element

func (b *ArrayType) Element(name string) *ArrayType

Element sets the element

func (*ArrayType) Name

func (b *ArrayType) Name() string

Name returns the type name

func (*ArrayType) Node

func (b *ArrayType) Node() *dst.GenDecl

Node returns the node

type ConstBlockType

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

ConstBlockType builds a var block type

func NewConstBlockType

func NewConstBlockType() *ConstBlockType

NewConstBlockType creates a new ConstBlcokType

func (*ConstBlockType) AddConst

func (b *ConstBlockType) AddConst(name, kind, value string)

AddConst defines a var

func (*ConstBlockType) Commentf

func (b *ConstBlockType) Commentf(pattern string, args ...interface{})

Commentf adds a comment

func (*ConstBlockType) Node

func (b *ConstBlockType) Node() *dst.GenDecl

Node returns the node

type ControllerGenerator

type ControllerGenerator struct {
	Path       string
	Mode       ControllerGeneratorMode
	Controller *codedom.ControllerDescriptor
	Reporter   contract.Reporter
}

ControllerGenerator builds a controller

func (*ControllerGenerator) Generate

func (g *ControllerGenerator) Generate() *File

Generate generates a file

type ControllerGeneratorMode

type ControllerGeneratorMode byte

ControllerGeneratorMode determines the mode of this generator

const (
	// ControllerGeneratorModeSchema generates the schema for the controller
	ControllerGeneratorModeSchema ControllerGeneratorMode = 0
	// ControllerGeneratorModeAPI generates the api for the controller
	ControllerGeneratorModeAPI ControllerGeneratorMode = 1
	// ControllerGeneratorModeSpec generates the spec for the controller
	ControllerGeneratorModeSpec ControllerGeneratorMode = 2
)

type File

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

File represents the generated file

func NewFile

func NewFile(name string) *File

NewFile creates a new file

func OpenFile

func OpenFile(name string) (*File, error)

OpenFile opens a file

func ReadFile

func ReadFile(name string, reader io.Reader) (*File, error)

ReadFile reads the file from reader

func (*File) AddFunction

func (f *File) AddFunction(data string) error

AddFunction adds a function

func (*File) AddImport

func (f *File) AddImport(name string)

AddImport adds an import

func (*File) AddNode

func (f *File) AddNode(node Node)

AddNode adds a node to the file

func (*File) Merge

func (f *File) Merge(source *File) error

Merge merges the files

func (*File) Name

func (f *File) Name() string

Name returns the name of the file

func (*File) Node

func (f *File) Node() *dst.File

Node returns the node

func (*File) ReadFrom

func (f *File) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads the content from a file

func (*File) Sync

func (f *File) Sync() error

Sync syncs the content to the file system

func (*File) WriteTo

func (f *File) WriteTo(w io.Writer) (int64, error)

WriteTo writes to a file

type FileGenerator

type FileGenerator interface {
	// Generate generates the file
	Generate() *File
}

FileGenerator is a file generator

type Generator

type Generator struct {
	Path     string
	Reporter contract.Reporter
}

Generator generates the source code

func (*Generator) Generate

func (g *Generator) Generate(spec *codedom.SpecDescriptor) error

Generate generates the source code

type LiteralType

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

LiteralType builds a literal type

func NewLiteralType

func NewLiteralType(name string) *LiteralType

NewLiteralType creates a new literal type builder

func (*LiteralType) Commentf

func (b *LiteralType) Commentf(pattern string, args ...interface{})

Commentf adds a comment

func (*LiteralType) Element

func (b *LiteralType) Element(name string) *LiteralType

Element sets the element

func (*LiteralType) Name

func (b *LiteralType) Name() string

Name returns the type name

func (*LiteralType) Node

func (b *LiteralType) Node() *dst.GenDecl

Node returns the node

type MainGenerator

type MainGenerator struct {
	Path     string
	Reporter contract.Reporter
}

MainGenerator builds the main

func (*MainGenerator) Generate

func (g *MainGenerator) Generate() *File

Generate generates a file

type Merger

type Merger struct {
	Target *File
	Source *File
}

Merger merges files

func (*Merger) Merge

func (m *Merger) Merge() error

Merge merges the files

type Node

type Node interface {
	Node() *dst.GenDecl
}

Node returns the node

type Range

type Range struct {
	Start int
	End   int
}

Range represents the range

type SchemaGenerator

type SchemaGenerator struct {
	Path       string
	Collection codedom.TypeDescriptorCollection
	Reporter   contract.Reporter
}

SchemaGenerator generates a contract

func (*SchemaGenerator) Generate

func (g *SchemaGenerator) Generate() *File

Generate generates the file

type ServerGenerator

type ServerGenerator struct {
	Path        string
	Controllers codedom.ControllerDescriptorCollection
	Reporter    contract.Reporter
}

ServerGenerator builds a server

func (*ServerGenerator) Generate

func (g *ServerGenerator) Generate() *File

Generate generates a file

type SpecGenerator

type SpecGenerator struct {
	Path     string
	Reporter contract.Reporter
}

SpecGenerator builds the main

func (*SpecGenerator) Generate

func (g *SpecGenerator) Generate() *File

Generate generates a file

type StructType

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

StructType builds a struct

func NewStructType

func NewStructType(name string) *StructType

NewStructType creates a new struct type builder

func (*StructType) AddField

func (b *StructType) AddField(name, kind string, tags ...*codedom.TagDescriptor)

AddField defines a field

func (*StructType) Commentf

func (b *StructType) Commentf(pattern string, args ...interface{})

Commentf adds a comment

func (*StructType) HasFields

func (b *StructType) HasFields() bool

HasFields return true if the struct has fields

func (*StructType) Name

func (b *StructType) Name() string

Name returns the type name

func (*StructType) Node

func (b *StructType) Node() *dst.GenDecl

Node returns the node

type Writer

type Writer io.Writer

Writer represents a writer

Jump to

Keyboard shortcuts

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