visitor

package
v0.4.18 Latest Latest
Warning

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

Go to latest
Published: May 30, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionNoChange = ""
	ActionBreak    = "BREAK"
	ActionSkip     = "SKIP"
	ActionUpdate   = "UPDATE"
)

Variables

View Source
var QueryDocumentKeys = KeyMap{
	"Name":     []string{},
	"Document": []string{"Definitions"},
	"OperationDefinition": []string{
		"Name",
		"VariableDefinitions",
		"Directives",
		"SelectionSet",
	},
	"VariableDefinition": []string{
		"Variable",
		"Type",
		"DefaultValue",
	},
	"Variable":     []string{"Name"},
	"SelectionSet": []string{"Selections"},
	"Field": []string{
		"Alias",
		"Name",
		"Arguments",
		"Directives",
		"SelectionSet",
	},
	"Argument": []string{
		"Name",
		"Value",
	},

	"FragmentSpread": []string{
		"Name",
		"Directives",
	},
	"InlineFragment": []string{
		"TypeCondition",
		"Directives",
		"SelectionSet",
	},
	"FragmentDefinition": []string{
		"Name",
		"TypeCondition",
		"Directives",
		"SelectionSet",
	},

	"IntValue":     []string{},
	"FloatValue":   []string{},
	"StringValue":  []string{},
	"BooleanValue": []string{},
	"EnumValue":    []string{},
	"ListValue":    []string{"Values"},
	"ObjectValue":  []string{"Fields"},
	"ObjectField": []string{
		"Name",
		"Value",
	},

	"Directive": []string{
		"Name",
		"Arguments",
	},

	"Named":   []string{"Name"},
	"List":    []string{"Type"},
	"NonNull": []string{"Type"},

	"ObjectDefinition": []string{
		"Name",
		"Interfaces",
		"Fields",
	},
	"FieldDefinition": []string{
		"Name",
		"Arguments",
		"Type",
	},
	"InputValueDefinition": []string{
		"Name",
		"Type",
		"DefaultValue",
	},
	"InterfaceDefinition": []string{
		"Name",
		"Fields",
	},
	"UnionDefinition": []string{
		"Name",
		"Types",
	},
	"ScalarDefinition": []string{"Name"},
	"EnumDefinition": []string{
		"Name",
		"Values",
	},
	"EnumValueDefinition": []string{"Name"},
	"InputObjectDefinition": []string{
		"Name",
		"Fields",
	},
	"TypeExtensionDefinition": []string{"Definition"},
}

note that the keys are in Capital letters, equivalent to the ast.Node field Names

Functions

func Visit

func Visit(root ast.Node, visitorOpts *VisitorOptions, keyMap KeyMap) interface{}

Types

type KeyMap

type KeyMap map[string][]string

type NamedVisitFuncs

type NamedVisitFuncs struct {
	Kind  VisitFunc // 1) Named visitors triggered when entering a node a specific kind.
	Leave VisitFunc // 2) Named visitors that trigger upon entering and leaving a node of
	Enter VisitFunc // 2) Named visitors that trigger upon entering and leaving a node of
}

type VisitFunc

type VisitFunc func(p VisitFuncParams) (string, interface{})

func GetVisitFn

func GetVisitFn(visitorOpts *VisitorOptions, kind string, isLeaving bool) VisitFunc

GetVisitFn Given a visitor instance, if it is leaving or not, and a node kind, return the function the visitor runtime should call.

type VisitFuncParams

type VisitFuncParams struct {
	Node      interface{}
	Key       interface{}
	Parent    ast.Node
	Path      []interface{}
	Ancestors []ast.Node
}

type VisitorOptions

type VisitorOptions struct {
	KindFuncMap map[string]NamedVisitFuncs
	Enter       VisitFunc // 3) Generic visitors that trigger upon entering and leaving any node.
	Leave       VisitFunc // 3) Generic visitors that trigger upon entering and leaving any node.

	EnterKindMap map[string]VisitFunc // 4) Parallel visitors for entering and leaving nodes of a specific kind
	LeaveKindMap map[string]VisitFunc // 4) Parallel visitors for entering and leaving nodes of a specific kind
}

func VisitInParallel

func VisitInParallel(visitorOptsSlice ...*VisitorOptions) *VisitorOptions

VisitInParallel Creates a new visitor instance which delegates to many visitors to run in parallel. Each visitor will be visited for each node before moving on.

If a prior visitor edits a node, no following visitors will see that node.

func VisitWithTypeInfo

func VisitWithTypeInfo(ttypeInfo typeInfo.TypeInfoI, visitorOpts *VisitorOptions) *VisitorOptions

VisitWithTypeInfo Creates a new visitor instance which maintains a provided TypeInfo instance along with visiting visitor.

Jump to

Keyboard shortcuts

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