exception

package
v0.0.0-...-90ca10d Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CatchError = 0
	CatchType  = 1
)

Variables

This section is empty.

Functions

func GenAssignCall

func GenAssignCall(lhs []string, token string, rhs string) string

func GenAssigneStmt

func GenAssigneStmt(lhs []string, token string, rhs []string) string

func GenBlock

func GenBlock(stmts []string) string

func GenCompareExpr

func GenCompareExpr(left string, op string, right string) string

func GenErrAsHandler

func GenErrAsHandler(errorsPkg, errVar string, errTypes []string, stmts []string) string

func GenErrHandler

func GenErrHandler(errVar string, stmts []string) string

func GenErrIsHandler

func GenErrIsHandler(errorsPkg, errVar string, errVals []string, stmts []string) string

func GenGotoStmt

func GenGotoStmt(label string) string

func GenIfStmt

func GenIfStmt(cond string, stmt []string) string

func GenLabelDecl

func GenLabelDecl(name string) string

func GenOrExpr

func GenOrExpr(predicates ...string) string

func GenReturns

func GenReturns(exprs []string) string

func GenVarDecl

func GenVarDecl(name string, typ string) string

Types

type CallStmt

type CallStmt interface {
	fmt.Stringer
	Start() token.Position
	End() token.Position
}

type Catch

type Catch struct {
	lib.Extent
	Body    *lib.Extent
	Type    int
	Targets []*lib.Extent
	Err     string
	Calls   []CallStmt
}

func (*Catch) BodyEnd

func (m *Catch) BodyEnd() token.Position

func (*Catch) BodyStart

func (m *Catch) BodyStart() token.Position

func (*Catch) CallStmts

func (m *Catch) CallStmts() []CallStmt

func (*Catch) End

func (m *Catch) End() token.Position

func (*Catch) Start

func (m *Catch) Start() token.Position

func (*Catch) String

func (m *Catch) String() string

type ExceptionSyntax

type ExceptionSyntax struct {
	lib.Extent
	RetTypes   []*lib.Extent
	Blocks     []SyntaxBlock
	HasCatch   bool
	HasFinally bool
}

func (*ExceptionSyntax) String

func (m *ExceptionSyntax) String() string

type ExceptionSyntaxInspector

type ExceptionSyntaxInspector struct {
	// contains filtered or unexported fields
}

func NewExceptionSyntaxInspector

func NewExceptionSyntaxInspector(pkg *packages.Package) *ExceptionSyntaxInspector

func (*ExceptionSyntaxInspector) Inspect

func (i *ExceptionSyntaxInspector) Inspect(node ast.Node, stack []ast.Node) (syntax *ExceptionSyntax)

func (*ExceptionSyntaxInspector) Nodes

func (i *ExceptionSyntaxInspector) Nodes() []ast.Node

type Finally

type Finally struct {
	lib.Extent
	Body  *lib.Extent
	Calls []CallStmt
}

func (*Finally) BodyEnd

func (m *Finally) BodyEnd() token.Position

func (*Finally) BodyStart

func (m *Finally) BodyStart() token.Position

func (*Finally) CallStmts

func (m *Finally) CallStmts() []CallStmt

func (*Finally) End

func (m *Finally) End() token.Position

func (*Finally) Start

func (m *Finally) Start() token.Position

func (*Finally) String

func (m *Finally) String() string

type Func

type Func struct {
	lib.Extent
	Expr        *lib.Extent
	AssignToken string
	Vars        []*lib.Extent
	OuterStmt   *lib.Extent
}

func (*Func) End

func (m *Func) End() token.Position

func (*Func) Start

func (m *Func) Start() token.Position

func (*Func) String

func (m *Func) String() string

type Return

type Return struct {
	lib.Extent
	Args []*lib.Extent
}

func (*Return) End

func (m *Return) End() token.Position

func (*Return) Start

func (m *Return) Start() token.Position

func (*Return) String

func (m *Return) String() string

type SyntaxBlock

type SyntaxBlock interface {
	Start() token.Position
	End() token.Position
	BodyStart() token.Position
	BodyEnd() token.Position
	CallStmts() []CallStmt
	fmt.Stringer
}

type Throw

type Throw struct {
	lib.Extent
	Err *lib.Extent
}

func (*Throw) End

func (m *Throw) End() token.Position

func (*Throw) Start

func (m *Throw) Start() token.Position

func (*Throw) String

func (m *Throw) String() string

type Translator

type Translator struct{}

func (*Translator) Generate

func (*Translator) Generate(info *lib.FileInfo[*ExceptionSyntax], writer io.Writer) error

func (*Translator) InpectTypes

func (*Translator) InpectTypes(p *packages.Package) []*lib.Extent

func (*Translator) InspectSyntax

func (*Translator) Run

func (t *Translator) Run(ctx context.Context, rootDir string, firstRun bool) error

type Try

type Try struct {
	lib.Extent
	Body  *lib.Extent
	Calls []CallStmt
}

func (*Try) BodyEnd

func (m *Try) BodyEnd() token.Position

func (*Try) BodyStart

func (m *Try) BodyStart() token.Position

func (*Try) CallStmts

func (m *Try) CallStmts() []CallStmt

func (*Try) End

func (m *Try) End() token.Position

func (*Try) Start

func (m *Try) Start() token.Position

func (*Try) String

func (m *Try) String() string

Jump to

Keyboard shortcuts

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