Documentation
¶
Index ¶
- Variables
- func Extras() template.FuncMap
- type FieldInfo
- type FieldVarOrFunc
- type FunctionCallInfo
- type InMemoryPackageOpts
- type PackageWithTemplateFiles
- func (r *PackageWithTemplateFiles) AddStruct(name string, fieldMap map[string]types.Type) *types.Named
- func (r *PackageWithTemplateFiles) AddTemplateFile(name string, content string)
- func (r *PackageWithTemplateFiles) AddTypes(types []*types.TypeName)
- func (me *PackageWithTemplateFiles) LoadTypeByPath(ctx context.Context, path string) (types.Object, error)
- type Registry
- func (r *Registry) AddInMemoryPackageForTesting(ctx context.Context, path string) *PackageWithTemplateFiles
- func (r *Registry) AddPackage(pkg *PackageWithTemplateFiles)
- func (r *Registry) GetFieldType(structType *types.Struct, fieldName string) (types.Type, error)
- func (r *Registry) GetPackage(ctx context.Context, packageName string) (*types.Package, error)
- func (r *Registry) GetTemplateFile(name string) (string, *PackageWithTemplateFiles, bool)
- func (r *Registry) GetTypes(ctx context.Context, pkgPath string) (map[string]types.Object, error)
- func (r *Registry) TypeExists(typePath string) bool
- type TemplateMethodInfo
- type TypeHintDefinition
Constants ¶
This section is empty.
Variables ¶
var BuiltinTemplateMethods = generateBuiltinTemplateMethods()
BuiltinTemplateMethods contains all the built-in Go template methods
Functions ¶
Types ¶
type FieldInfo ¶
type FieldInfo struct { Name string Type FieldVarOrFunc // Reflect reflect.Type FormattedTypeString string Parent *TypeHintDefinition }
FieldInfo represents information about a struct field
func GenerateFieldInfoFromPosition ¶
func GenerateFieldInfoFromPosition(ctx context.Context, typeInfo *TypeHintDefinition, pos position.RawPosition) (*FieldInfo, error)
ValidateField validates a field access on a type
func (*FieldInfo) NestedMultiLineTypeString ¶
NestedMultiLineTypeString returns a multi-line string representation of the type hierarchy
type FieldVarOrFunc ¶
func (FieldVarOrFunc) Obj ¶
func (f FieldVarOrFunc) Obj() types.Object
func (FieldVarOrFunc) String ¶
func (f FieldVarOrFunc) String() string
func (FieldVarOrFunc) Type ¶
func (f FieldVarOrFunc) Type() types.Type
func (FieldVarOrFunc) Underlying ¶
func (f FieldVarOrFunc) Underlying() types.Type
type FunctionCallInfo ¶
type InMemoryPackageOpts ¶
type PackageWithTemplateFiles ¶
func LoadPackageTypesFromFs ¶
func (*PackageWithTemplateFiles) AddTemplateFile ¶
func (r *PackageWithTemplateFiles) AddTemplateFile(name string, content string)
func (*PackageWithTemplateFiles) AddTypes ¶
func (r *PackageWithTemplateFiles) AddTypes(types []*types.TypeName)
func (*PackageWithTemplateFiles) LoadTypeByPath ¶
type Registry ¶
type Registry struct { // Types maps fully qualified type paths to their package information Packages []*PackageWithTemplateFiles // Error encountered during type resolution, if any Err error }
Registry manages Go package and type information
func AnalyzePackage ¶
AnalyzePackage implements PackageAnalyzer
func NewEmptyRegistry ¶
func NewEmptyRegistry() *Registry
func NewRegistry ¶
func NewRegistry(pkgWithTemplateFilesList []*PackageWithTemplateFiles) *Registry
NewRegistry creates a new Registry
func (*Registry) AddInMemoryPackageForTesting ¶
func (r *Registry) AddInMemoryPackageForTesting(ctx context.Context, path string) *PackageWithTemplateFiles
func (*Registry) AddPackage ¶
func (r *Registry) AddPackage(pkg *PackageWithTemplateFiles)
func (*Registry) GetFieldType ¶
GetFieldType returns the type of a field in a struct type
func (*Registry) GetPackage ¶
GetPackage returns a package by name
func (*Registry) GetTemplateFile ¶
func (r *Registry) GetTemplateFile(name string) (string, *PackageWithTemplateFiles, bool)
func (*Registry) TypeExists ¶
TypeExists checks if a type exists in the registry
type TemplateMethodInfo ¶
TemplateMethodInfo represents information about a template method
func GenerateFunctionCallInfoFromPosition ¶
func GenerateFunctionCallInfoFromPosition(ctx context.Context, pos position.RawPosition) (*TemplateMethodInfo, error)
func GetBuiltinMethod ¶
func GetBuiltinMethod(name string) *TemplateMethodInfo
GetBuiltinMethod returns a built-in template method by name
type TypeHintDefinition ¶
type TypeHintDefinition struct { // Reflect reflect.Type Fields map[string]*FieldInfo MyFieldInfo FieldInfo MyType *types.Named }
TypeHintDefinition represents information about a Go type