Documentation ¶
Index ¶
- Constants
- func CleanTagName(rawTagName string) string
- func ExtractComments(rawCommentGroup *ast.CommentGroup) []string
- func ExtractSliceValues(items []ast.Expr) []string
- func GetMapValueType(item ast.Expr) string
- func SliceValuesToPrettyList(raw []string) string
- type ImportedEntityDetails
- type ScannedStruct
- type ScannedStructField
- type ScannedType
- func BasicTypeLiteralParser(d *ast.Ident, item *ast.BasicLit) ScannedType
- func CompositeLiteralMapParser(d *ast.Ident, mapElements []ast.Expr, item *ast.CompositeLit) ScannedType
- func CompositeLiteralSliceParser(d *ast.Ident, sliceType string, item *ast.CompositeLit) ScannedType
- func IdentifierParser(d *ast.Ident, item *ast.Ident) *ScannedType
Constants ¶
const ( MapType = 1 VarType = 2 ConstType = 3 StructType = 4 SliceType = 5 )
The below constants represent the InternalType for a scanned type this is used in the translators to determine more easily the type of object we are performing operations on.
Variables ¶
This section is empty.
Functions ¶
func CleanTagName ¶
func ExtractComments ¶
func ExtractComments(rawCommentGroup *ast.CommentGroup) []string
ExtractComments will transform a *ast.CommentGroup into a []string which makes it more accessible and usable.
func ExtractSliceValues ¶
ExtractSliceValues will return the values of a []ast.Expr in the form of a []string for ease of use.
func GetMapValueType ¶
GetMapValueType will return the type of a map's value fields.
func SliceValuesToPrettyList ¶
SliceValuesToPrettyList will turn a normal []string into a line & comma separated string, for pretty display of a slice's values.
Types ¶
type ImportedEntityDetails ¶
ImportedEntityDetails represents the details of an imported item. With that information an attempt of an import can be re-created in the translators.
type ScannedStruct ¶
type ScannedStruct struct { Doc []string `json:"doc"` Name string `json:"name"` Fields []ScannedStructField `json:"fields"` InternalType int `json:"internalType"` }
ScannedStruct represents the details of a scanned struct.
type ScannedStructField ¶
type ScannedStructField struct { Name string `json:"name"` Kind string `json:"kind"` Tag string `json:"tag"` Doc []string `json:"doc"` ImportDetails *ImportedEntityDetails `json:"imported_entity"` }
ScannedStructField represents the details of a field inside a scanned struct.
func ImportedStructFieldParser ¶
func ImportedStructFieldParser(field *ast.Field) ScannedStructField
ImportedStructFieldParser will transform a field of a struct that contains an imported entity into a program readable ScannedStructField.
func SimpleStructFieldParser ¶
func SimpleStructFieldParser(field *ast.Field) ScannedStructField
ImportedStructFieldParser will transform a field of a struct that contains a basic entity into a program readable ScannedStructField.
type ScannedType ¶
type ScannedType struct { Name string `json:"name"` Kind string `json:"kind"` Value interface{} `json:"value"` Doc []string `json:"doc"` InternalType int `json:"internalType"` }
ScannedType represents a basic entity to be translated. More specifically const and var items.
func BasicTypeLiteralParser ¶
func BasicTypeLiteralParser(d *ast.Ident, item *ast.BasicLit) ScannedType
BasicTypeLiteralParser will try to extract the type of a basic literal type, whether const or var.
func CompositeLiteralMapParser ¶
func CompositeLiteralMapParser(d *ast.Ident, mapElements []ast.Expr, item *ast.CompositeLit) ScannedType
CompositeLiteralSliceParser will extract a map ScannedType from the valid corresponding composite literal declaration.
func CompositeLiteralSliceParser ¶
func CompositeLiteralSliceParser(d *ast.Ident, sliceType string, item *ast.CompositeLit) ScannedType
CompositeLiteralSliceParser will extract a slice ScannedType from the valid corresponding composite literal declaration.
func IdentifierParser ¶
func IdentifierParser(d *ast.Ident, item *ast.Ident) *ScannedType
IdentifierParser will try to extract the type of an identifier, like booleans. This will return a pointer to a ScannedType, thus the result should be checked for nil.