astutil

package
v0.0.0-...-3518944 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2017 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package astutil constains some small utilities for working with Go syntax trees.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Calls

func Calls(fset *token.FileSet, f *ast.File, fn string) ([]*ast.CallExpr, error)

Calls returns the calls to a given function or method specified as a qualified name (e.g. gnd.la/i18n.T or gnd.la/app.Context.T).

func Ident

func Ident(node ast.Expr) string

func Importer

func Importer(imports map[string]*ast.Object, path string) (*ast.Object, error)

func Imports

func Imports(f *ast.File, pkg string) (string, bool)

Imports return whetever the given ast.File imports the package named pkg. It also returns its local imported name.

func New

func New(p *build.Package, mode parser.Mode) (*token.FileSet, *ast.Package, error)

func ObjectName

func ObjectName(obj *ast.Object) (pkg string, typ string)

ObjectName returns the object package and type name for the given ast.Object.

func ParseFiles

func ParseFiles(fset *token.FileSet, abspath string, names []string, mode parser.Mode) (map[string]*ast.File, error)

func Selector

func Selector(expr ast.Expr) (x string, sel string)

func StringLiteral

func StringLiteral(f *token.FileSet, n ast.Expr) (string, *token.Position)

Types

type String

type String struct {
	Value    string
	Position *token.Position
}

func Strings

func Strings(fset *token.FileSet, f *ast.File, typ string) ([]*String, error)

Strings returns a list of string declarations of the given type (as a qualified name).

func TagFields

func TagFields(fset *token.FileSet, f *ast.File, tagField string) ([]*String, error)

func (*String) Context

func (s *String) Context() string

func (*String) Plural

func (s *String) Plural() string

func (*String) Singular

func (s *String) Singular() string

Jump to

Keyboard shortcuts

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