ainsp

package
v0.12.5 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2020 License: MIT Imports: 14 Imported by: 3

Documentation

Overview

Package ainsp is a Go ast library for aah framework, it does inspect and discovers the Go `struct` which embeds particular type `struct`.

For e.g.: `aahframework.org/{aah.Context, ws.Context}`, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindFieldIndexes

func FindFieldIndexes(targetTyp reflect.Type, searchTyp reflect.Type) [][]int

FindFieldIndexes method does breadth-first search on struct anonymous field to find given type `struct` discover index positions.

For e.g.: `aah.Context`, `ws.Context`, etc.

Types

type Method

type Method struct {
	Name       string
	Parameters []*Parameter
}

Method holds single method information of target.

type Parameter

type Parameter struct {
	Name string
	Type reflect.Type
	Kind reflect.Kind
}

Parameter holds parameter information of method.

type Program

type Program struct {
	Path              string
	Packages          []*packageInfo
	RegisteredActions map[string]map[string]uint8
}

Program holds all details loaded from the Go source code for given Import Path.

func Inspect

func Inspect(dir, importPath string, excludes ess.Excludes, registeredActions map[string]map[string]uint8) (*Program, []error)

Inspect method processes the Go source code for the given directory and its sub-directories.

func (*Program) CreateImportPaths

func (prg *Program) CreateImportPaths(types []*typeInfo, importPaths map[string]string) map[string]string

CreateImportPaths method returns unique package alias with import path.

func (*Program) FindTypeByEmbeddedType

func (prg *Program) FindTypeByEmbeddedType(qualifiedTypeName string) []*typeInfo

FindTypeByEmbeddedType method returns all the typeInfo that has directly or indirectly embedded by given type name. Type name must be fully qualified type name. E.g.: aahframework.org/aah.Controller

type Target

type Target struct {
	Name            string
	FqName          string
	NoSuffixName    string
	Namespace       string
	Type            reflect.Type
	Methods         map[string]*Method
	EmbeddedIndexes [][]int
}

Target struct holds info about targeted controller, websocket, etc.

func (*Target) Lookup

func (t *Target) Lookup(methodName string) *Method

Lookup method returns method info for given name (case insensitive) otherwise nil.

type TargetRegistry

type TargetRegistry struct {
	Registry   map[string]*Target
	SearchType reflect.Type
}

TargetRegistry struct holds registered information and provides lookup. Such as aah application controllers, websockets, etc.

func (*TargetRegistry) Add

func (tr *TargetRegistry) Add(t interface{}, methods []*Method)

Add method adds given target struct and its methods after processing.

func (*TargetRegistry) Lookup

func (tr *TargetRegistry) Lookup(fqName string) *Target

Lookup method returns `Target` info from registry for given `fqName` (fully qualified name) otherwise nil.

It does exact match or exact suffix match.

Jump to

Keyboard shortcuts

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