registry

package
v0.0.0-...-a12b2c8 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2016 License: MIT Imports: 14 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DEFAULT_PARAM = "&"
)

Variables

View Source
var (
	ROOTS = filepath.SplitList(os.Getenv("GOPATH"))
)

Functions

func GenerateAnnotationValue

func GenerateAnnotationValue(a *AnnotatedEntry, packageName string, foundImports []string) (string, []string)

Returns annotated entry annotations descriptor and list of all annotations packages in it Parameters: - annotated entry - full package name - list of imports in the entry source

func GenerateRegistry

func GenerateRegistry(path, pck, outName string)

Generates the code for register a set of annotations within provided package. Parameters: - path - the folder where package source files are located; - pck - the shoirt package name; - outName - name of output source file; if it is empty then <package>_annotations.go will be used

func GetFieldAnnotations

func GetFieldAnnotations(s interface{}, fieldName string) []interface{}

Returns annotations bundle for specified field of provided object type. Object instance or its reflect.Type is passed as the first parameter. Field name is passed as the second parameter. If no annotation defined for given type or specified field is not annotated or no such field exist then nil is returned

func GetFuncAnnotation

func GetFuncAnnotation(s interface{}) []interface{}

Returns annotations bundle for provided func type. Func instance or its reflect.Type is passed as the parameter. If no annotation defined for given type then nil is returned

func GetMethodAnnotations

func GetMethodAnnotations(s interface{}, methodName string) []interface{}

Returns annotations bundle for specified method of provided object type. Object instance or its reflect.Type is passed as the first parameter. Method name is passed as the second parameter. If no annotation defined for given type then nil is returned

func GetStructAnnotations

func GetStructAnnotations(s interface{}) []interface{}

Returns annotations bundle for provided struct type. Object instance or its reflect.Type is passed as the parameter. If no annotation defined for given type then nil is returned

func Map

func Map(s string, a Annotations)

Maps annotations bundle to provided string. Usually string contains the type and the name of annotated entry

func MapType

func MapType(i interface{}, a Annotations)

Maps annotation bundle to the type and name of provided object

Types

type AnnotatedEntry

type AnnotatedEntry struct {
	Type            string // type name of annotated entry of func/method name
	FullPackage     string // full package name of annotated entry
	Name            string // the name of annotated struct/func/interface/method
	AnnotationsData        // related annotation data
}

Full description of annotated entry

func ParseFile

func ParseFile(path, file string) ([]AnnotatedEntry, []string, string)

Parses provided source file and extract annotations for all objects (structures, interfaces, methods, functions) as annotated entries. Also it returns all found imports and full package name of the parsed file

type AnnotationDoc

type AnnotationDoc struct {
	Name    string
	Content map[string]interface{}
}

Annotation properties extracted from the comments

func FindAnnotations

func FindAnnotations(doc string) []AnnotationDoc

Returns objects for all found annotations in provided comment Objects contain only the map of attribute names and associated values

type Annotations

type Annotations struct {
	Self    []interface{}
	Fields  map[string][]interface{}
	Methods map[string][]interface{}
}

The annotations bundle stored in Registry for each entry. It is automatically generated and consists of structs representing custom annotations

type AnnotationsData

type AnnotationsData struct {
	Self    []AnnotationDoc            // annotations related to struct/func/interface name
	Fields  map[string][]AnnotationDoc // annotations related to struct field
	Methods map[string][]AnnotationDoc // annotations related to struct methods
}

Bundle of annotations related to object in source code

Jump to

Keyboard shortcuts

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