types

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(mainNode ast.Node, roots map[string]ast.Node, vars map[string]map[ast.Node]*common.Variable, importFunc ImportFunc, ec *utils.ErrCollector)

Check finds type problems in a given program. It require passing some previously processed data: * root nodes of all (transitively) imported Jsonnet files * resolution of variables in all files * importFunc which allows resolving imports

func Describe

func Describe(t *TypeDesc) string

Describe provides incomplete, but human-readable representation of a type.

Types

type ImportFunc

type ImportFunc func(currentPath, importedPath string) ast.Node

ImportFunc should provide an AST node from a given location. If a node is not available it should return nil.$

type TypeDesc

type TypeDesc struct {
	Bool         bool
	Number       bool
	String       bool
	Null         bool
	FunctionDesc *functionDesc
	ObjectDesc   *objectDesc
	ArrayDesc    *arrayDesc
}

TypeDesc is a representation of a type. This is (way) richer than the basic Jsonnet type system with seven types.

func (*TypeDesc) Any

func (t *TypeDesc) Any() bool

Any returns whether all values are allowed (i.e. we know nothing about it).

func (*TypeDesc) AnyArray

func (t *TypeDesc) AnyArray() bool

AnyArray returns whether the types contain all arrays.

func (*TypeDesc) AnyFunction

func (t *TypeDesc) AnyFunction() bool

AnyFunction returns whether the types contain all functions.

func (*TypeDesc) AnyObject

func (t *TypeDesc) AnyObject() bool

AnyObject returns whether the type contains all objects.

func (*TypeDesc) Array

func (t *TypeDesc) Array() bool

Array returns whether the types contains an array.

func (*TypeDesc) Function

func (t *TypeDesc) Function() bool

Function returns whether the types contains a function.

func (*TypeDesc) Object

func (t *TypeDesc) Object() bool

Object returns whether the types contains an object.

func (*TypeDesc) Void

func (t *TypeDesc) Void() bool

Void returns whether the type is empty (no values are possible).

Jump to

Keyboard shortcuts

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