compiler

package
v0.0.0-...-d88c8b5 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package compiler provides support functions to generated compiler code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearCaches

func ClearCaches()

func ClearFileCache

func ClearFileCache()

func ClearInfoCache

func ClearInfoCache()

func ConvertInterfaceArrayToStringArray

func ConvertInterfaceArrayToStringArray(interfaceArray []interface{}) []string

ConvertInterfaceArrayToStringArray converts an array of interfaces to an array of strings, if possible.

func DescribeMap

func DescribeMap(in interface{}, indent string) string

DescribeMap describes a map (for debugging purposes).

func DisableFileCache

func DisableFileCache()

func DisableInfoCache

func DisableInfoCache()

func EnableFileCache

func EnableFileCache()

func EnableInfoCache

func EnableInfoCache()

func FetchFile

func FetchFile(fileurl string) ([]byte, error)

FetchFile gets a specified file from the local filesystem or a remote location.

func GetInfoCache

func GetInfoCache() map[string]interface{}

func HandleExtension

func HandleExtension(context *Context, in interface{}, extensionName string) (bool, *any.Any, error)

HandleExtension calls a binary extension handler.

func InvalidKeysInMap

func InvalidKeysInMap(m yaml.MapSlice, allowedKeys []string, allowedPatterns []*regexp.Regexp) []string

InvalidKeysInMap returns keys in a map that don't match a list of allowed keys and patterns.

func MapHasKey

func MapHasKey(m yaml.MapSlice, key string) bool

MapHasKey returns true if a yaml.MapSlice contains a specified key.

func MapValueForKey

func MapValueForKey(m yaml.MapSlice, key string) interface{}

MapValueForKey gets the value of a map value for a specified key.

func MissingKeysInMap

func MissingKeysInMap(m yaml.MapSlice, requiredKeys []string) []string

MissingKeysInMap identifies which keys from a list of required keys are not in a map.

func NewErrorGroupOrNil

func NewErrorGroupOrNil(errors []error) error

NewErrorGroupOrNil returns a new ErrorGroup for a slice of errors or nil if the slice is empty.

func PluralProperties

func PluralProperties(count int) string

PluralProperties returns the string "properties" pluralized.

func ReadBytesForFile

func ReadBytesForFile(filename string) ([]byte, error)

ReadBytesForFile reads the bytes of a file.

func ReadInfoForRef

func ReadInfoForRef(basefile string, ref string) (interface{}, error)

ReadInfoForRef reads a file and return the fragment needed to resolve a $ref.

func ReadInfoFromBytes

func ReadInfoFromBytes(filename string, bytes []byte) (interface{}, error)

ReadInfoFromBytes unmarshals a file as a yaml.MapSlice.

func RemoveFromFileCache

func RemoveFromFileCache(fileurl string)

func RemoveFromInfoCache

func RemoveFromInfoCache(filename string)

func SortedKeysForMap

func SortedKeysForMap(m yaml.MapSlice) []string

SortedKeysForMap returns the sorted keys of a yaml.MapSlice.

func StringArrayContainsValue

func StringArrayContainsValue(array []string, value string) bool

StringArrayContainsValue returns true if a string array contains a specified value.

func StringArrayContainsValues

func StringArrayContainsValues(array []string, values []string) bool

StringArrayContainsValues returns true if a string array contains all of a list of specified values.

func StringValue

func StringValue(item interface{}) (value string, ok bool)

StringValue returns the string value of an item.

func UnpackMap

func UnpackMap(in interface{}) (yaml.MapSlice, bool)

UnpackMap gets a yaml.MapSlice if possible.

Types

type Context

type Context struct {
	Parent            *Context
	Name              string
	ExtensionHandlers *[]ExtensionHandler
}

Context contains state of the compiler as it traverses a document.

func NewContext

func NewContext(name string, parent *Context) *Context

NewContext returns a new object representing the compiler state

func NewContextWithExtensions

func NewContextWithExtensions(name string, parent *Context, extensionHandlers *[]ExtensionHandler) *Context

NewContextWithExtensions returns a new object representing the compiler state

func (*Context) Description

func (context *Context) Description() string

Description returns a text description of the compiler state

type Error

type Error struct {
	Context *Context
	Message string
}

Error represents compiler errors and their location in the document.

func NewError

func NewError(context *Context, message string) *Error

NewError creates an Error.

func (*Error) Error

func (err *Error) Error() string

Error returns the string value of an Error.

type ErrorGroup

type ErrorGroup struct {
	Errors []error
}

ErrorGroup is a container for groups of Error values.

func (*ErrorGroup) Error

func (group *ErrorGroup) Error() string

type ExtensionHandler

type ExtensionHandler struct {
	Name string
}

ExtensionHandler describes a binary that is called by the compiler to handle specification extensions.

Jump to

Keyboard shortcuts

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