generator

package
v0.0.0-...-2279c88 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2018 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NodeByName

func NodeByName(nodes []ast.Node, name string) ast.Node

TODO: Much the same as the NamedLookup function

Types

type ConnectionDefinition

type ConnectionDefinition struct {
	Name     *ast.Name
	Loc      *ast.Location
	NodeType ast.Node
}

func (ConnectionDefinition) GetKind

func (con ConnectionDefinition) GetKind() string

func (ConnectionDefinition) GetLoc

func (con ConnectionDefinition) GetLoc() *ast.Location

func (ConnectionDefinition) GetName

func (con ConnectionDefinition) GetName() *ast.Name

type Generator

type Generator struct {
	Code     string
	Schema   string
	Template *template.Template
	Ast      *ast.Document
	Config   ProjectConfig
	LangConf LanguageConfig
	Nodes    astNodes

	TmplConf map[string]string
}

Generator represents the code generator main object

func New

func New(config string) (*Generator, error)

New creates a new Generator instance

func (*Generator) Generate

func (gen *Generator) Generate()

Generate starts the code generation process

func (*Generator) NamedLookup

func (gen *Generator) NamedLookup(name string) ast.Node

TODO: Find a better name for the NamedLookup function

type LanguageConfig

type LanguageConfig struct {

	// Language specific syntax config
	Language struct {
		Scalars map[string]string
		Root    []string
	}

	// This is passed to the generators Cfg variable
	Config map[string]string

	// Main templates, each template in this list is executed in it's own
	// go routine
	Templates []string

	// Program/command used for formatting the output code
	Formatter struct {
		CMD  string
		Args []string
	}
}

LanguageConfig defines the language specific implementation information

func (LanguageConfig) IsRoot

func (lang LanguageConfig) IsRoot(val string) bool

type MutationType

type MutationType string
const (
	MutationInput   MutationType = "Input"
	MutationPayload MutationType = "Payload"
)

type OutputFileBuffer

type OutputFileBuffer struct {
	Path   string
	Buffer *bytes.Buffer
}

func (*OutputFileBuffer) GetBuffer

func (out *OutputFileBuffer) GetBuffer() *bytes.Buffer

type ProjectConfig

type ProjectConfig struct {
	// TODO Support a globbing system
	Schemas  []string
	Language string
	Output   map[string]string
}

ProjectConfig contains the granate.yaml information

type TemplateFileFuncs

type TemplateFileFuncs struct {
	BufferStack   *utils.Lifo
	SwapBuffer    *utils.SwapBuffer
	LocalTemplate *template.Template
	// contains filtered or unexported fields
}

func (*TemplateFileFuncs) End

func (tmpl *TemplateFileFuncs) End() string

func (*TemplateFileFuncs) LineNumbers

func (tmpl *TemplateFileFuncs) LineNumbers() int

func (*TemplateFileFuncs) Start

func (tmpl *TemplateFileFuncs) Start(path string) string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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