astutil

package
v0.0.0-...-797e501 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallMember

func CallMember(recName, fieldName, methodName string, args ...ast.Expr) *ast.CallExpr

func CloneFuncSig

func CloneFuncSig(f *ast.Func) *ast.Func

func FieldByName

func FieldByName(f ast.Node, name string) *ast.Field

func File

func File(n ast.Node) *ast.File

func FindImplementations

func FindImplementations(ctx ast.Node, iface ast.Name) []*ast.Struct

FindImplementations traverses the entire module to find structs which implement the given interface. Note that other types implementing an interface are (not yet) supported.

func FindMod

func FindMod(name token.String, prj *ast.Prj) (*ast.Mod, error)

func FindPkg

func FindPkg(mod *ast.Mod, pkgPath string) *ast.Pkg

FindPkg returns an existing package or nil.

func FullQualifiedName

func FullQualifiedName(n ast.NamedType) string

FullQualifiedName tries to resolve and return the full qualified name (<package>.<Identifier>).

func LastPathSegment

func LastPathSegment(path string) string

func MakeTypeDecl

func MakeTypeDecl(t *adl.TypeDecl) ast.TypeDecl

MakeTypeDecl converts the more unspecific and generic adl type description into the ast model.

func MethodByName

func MethodByName(f ast.Node, name string) *ast.Func

func MkFile

func MkFile(pkg *ast.Pkg, name string) *ast.File

MkFile returns an existing file or creates a new file inside the package.

func MkMod

func MkMod(prj *ast.Prj, modName string) *ast.Mod

MkMod returns or create the module.

func MkPkg

func MkPkg(mod *ast.Mod, pkgPath string) *ast.Pkg

MkPkg returns an existing or create a new package inside mod.

func Mod

func Mod(n ast.Node) *ast.Mod

func Pkg

func Pkg(n ast.Node) *ast.Pkg

func Resolve

func Resolve(ctx ast.Node, name string) ast.Node

Resolve takes the name and walks until it finds whatever declares it. Returns nil if not found.

func ResolveLocal

func ResolveLocal(ctx ast.Node, name string) ast.Node

func TypeDecl

func TypeDecl(n ast.NamedType) ast.TypeDecl

TypeDecl tries to resolve and returns a type declaration from the given named type.

func UseTypeDeclIn

func UseTypeDeclIn(what ast.TypeDecl, where *ast.Pkg) ast.TypeDecl

UseTypeDeclIn does a quite complex job. It looks up the different parts of 'what' and creates a new TypeDecl to be used in another package ('where'). In languages with cycles, import definitions (and qualified names) may even interchange - per generic declaration!

func WrapNode

func WrapNode(n ast.Node) token.Position

WrapNode envelopes the given ast.Node into a token.Node.

Types

This section is empty.

Jump to

Keyboard shortcuts

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