asth

package
v0.0.0-...-61d31b1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2018 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Overview

Package asth constains helper functions and types for Go package go/ast.

Index

Constants

View Source
const (
	SendDir ast.ChanDir = ast.SEND
	RecvDir             = ast.RECV
	BothDir             = SendDir | RecvDir
)

Specify all possible direction of a channel type for package go/ast.

Variables

This section is empty.

Functions

func IsBlankIdent

func IsBlankIdent(s string) bool

IsBlankIdent checks if s is Go blank identifier ("_").

func IsValidExportedIdent

func IsValidExportedIdent(s string) bool

IsValidExportedIdent checks if s is valid exported Go ident. For blank identifier this function returns false.

func IsValidIdent

func IsValidIdent(s string) bool

IsValidIdent checks if s is valid Go ident. For blank identifier this function returns false.

func IsValidNotExportedIdent

func IsValidNotExportedIdent(s string) bool

IsValidNotExportedIdent checks if s is valid not exported Go ident. For blank identifier this function returns false.

Types

type PointInSource

type PointInSource struct {
	Offset int // offset, starting at 0
	Line   int // line number, starting at 1
	Column int // column number, starting at 1 (byte count)
}

PointInSource describes an some point in source file without file itself. A Position is valid if the line number is > 0.

func TokenPositionToPoint

func TokenPositionToPoint(p token.Position) PointInSource

TokenPositionToPoint convert token.Position to PointInSource.

func (PointInSource) IsValid

func (p PointInSource) IsValid() bool

IsValid reports whether the point in source is valid.

func (PointInSource) String

func (p PointInSource) String() string

String returns a string "line:column" or "-" if PointInSource is invalid

type Position

type Position struct {
	Filename string
	Pos, End PointInSource
}

Position describes position of piece of code in source file. It contains file name (if any), position of beginning and (optionally) position of end. End is the position of last character, not first character after piece of code.

func MakePosition

func MakePosition(pos, end token.Pos, fset *token.FileSet) (p Position)

MakePosition makes Position. pos is the first character of code. end is the first character after code. fset must be non nil (pass token.NewFileSet() instead).

func NodePosition

func NodePosition(n ast.Node, fset *token.FileSet) (p Position)

NodePosition makes Position of ast.Node. It is just shortcut for MakePosition.

func (Position) String

func (pos Position) String() string

String returns a string in one of several forms:

file:line:column-line:column    valid position with file name
file:line:column                valid position with file name
line:column-line:column         valid position without file name
line:column                     valid position without file name
file                            invalid position with file name
-                               invalid position without file name

Jump to

Keyboard shortcuts

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