Documentation ¶
Overview ¶
Package compiler provides support functions to generated compiler code.
Index ¶
- func ConvertInterfaceArrayToStringArray(interfaceArray []interface{}) []string
- func DescribeMap(in interface{}, indent string) string
- func FetchFile(fileurl string) ([]byte, error)
- func HandleExtension(context *Context, in interface{}, extensionName string) (bool, *any.Any, error)
- func InvalidKeysInMap(m yaml.MapSlice, allowedKeys []string, allowedPatterns []*regexp.Regexp) []string
- func MapHasKey(m yaml.MapSlice, key string) bool
- func MapValueForKey(m yaml.MapSlice, key string) interface{}
- func MissingKeysInMap(m yaml.MapSlice, requiredKeys []string) []string
- func NewErrorGroupOrNil(errors []error) error
- func PluralProperties(count int) string
- func ReadBytesForFile(filename string) ([]byte, error)
- func ReadInfoForRef(basefile string, ref string) (interface{}, error)
- func ReadInfoFromBytes(filename string, bytes []byte) (interface{}, error)
- func SortedKeysForMap(m yaml.MapSlice) []string
- func StringArrayContainsValue(array []string, value string) bool
- func StringArrayContainsValues(array []string, values []string) bool
- func StringValue(item interface{}) (value string, ok bool)
- func UnpackMap(in interface{}) (yaml.MapSlice, bool)
- type Context
- type Error
- type ErrorGroup
- type ExtensionHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertInterfaceArrayToStringArray ¶
func ConvertInterfaceArrayToStringArray(interfaceArray []interface{}) []string
ConvertInterfaceArrayToStringArray converts an array of interfaces to an array of strings, if possible.
func DescribeMap ¶
DescribeMap describes a map (for debugging purposes).
func FetchFile ¶
FetchFile gets a specified file from the local filesystem or a remote location.
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 ¶
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 ¶
MissingKeysInMap identifies which keys from a list of required keys are not in a map.
func NewErrorGroupOrNil ¶
NewErrorGroupOrNil returns a new ErrorGroup for a slice of errors or nil if the slice is empty.
func PluralProperties ¶
PluralProperties returns the string "properties" pluralized.
func ReadBytesForFile ¶
ReadBytesForFile reads the bytes of a file.
func ReadInfoForRef ¶
ReadInfoForRef reads a file and return the fragment needed to resolve a $ref.
func ReadInfoFromBytes ¶
ReadInfoFromBytes unmarshals a file as a yaml.MapSlice.
func SortedKeysForMap ¶
func SortedKeysForMap(m yaml.MapSlice) []string
SortedKeysForMap returns the sorted keys of a yaml.MapSlice.
func StringArrayContainsValue ¶
StringArrayContainsValue returns true if a string array contains a specified value.
func StringArrayContainsValues ¶
StringArrayContainsValues returns true if a string array contains all of a list of specified values.
func StringValue ¶
StringValue returns the string value of an item.
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 ¶
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
type Error ¶
Error represents compiler errors and their location in the document.
type ErrorGroup ¶
type ErrorGroup struct {
Errors []error
}
ErrorGroup is a container for groups of Error values.
func (*ErrorGroup) Error ¶
func (group *ErrorGroup) Error() string