report

package
v0.0.0-...-74862b3 Latest Latest
Warning

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

Go to latest
Published: May 5, 2017 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsError

func AsError(report Report) error

Types

type AlreadyDeclaredError

type AlreadyDeclaredError struct {
	BaseReport
	Name string
}

func NewAlreadyDeclaredError

func NewAlreadyDeclaredError(decl ast.Decl, name *ast.Ident) *AlreadyDeclaredError

func (*AlreadyDeclaredError) Message

func (e *AlreadyDeclaredError) Message() string

type BaseReport

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

func NewBaseReport

func NewBaseReport(typ ReportType, pos token.Pos, msg string, region *Region) BaseReport

func (BaseReport) Message

func (r BaseReport) Message() string

func (BaseReport) Pos

func (r BaseReport) Pos() token.Pos

func (BaseReport) Region

func (r BaseReport) Region() *Region

func (BaseReport) Type

func (r BaseReport) Type() ReportType

type Diagnostic

type Diagnostic struct {
	Type    ReportType
	Message string
	Pos     source.LinePos
	Region  *source.Snippet
}

type Emitter

type Emitter interface {
	// Emit emits the given reports for the given file.
	Emit(string, []*Diagnostic) error
}

Emitter emits reports to the user.

func Errors

func Errors(warnings bool) Emitter

Errors is an emitter that emits Go errors with the reports.

func Stderr

func Stderr(warnings, colors bool) Emitter

Stderr creates a new emitter that will report to stderr all diagnostics.

type ExpectedCtorError

type ExpectedCtorError struct {
	BaseReport
	Name       string
	ActualKind ast.ObjKind
}

func NewExpectedCtorError

func NewExpectedCtorError(decl ast.Decl, obj *ast.Object) *ExpectedCtorError

func (*ExpectedCtorError) Message

func (e *ExpectedCtorError) Message() string

type ExpectedUnionError

type ExpectedUnionError struct {
	BaseReport
	Name       string
	ActualKind ast.ObjKind
}

func NewExpectedUnionError

func NewExpectedUnionError(decl ast.Decl, obj *ast.Object) *ExpectedUnionError

func (*ExpectedUnionError) Message

func (e *ExpectedUnionError) Message() string

type ExportError

type ExportError struct {
	BaseReport
	Module string
	Name   string
}

func NewExportError

func NewExportError(decl *ast.ModuleDecl, name *ast.Ident) *ExportError

func (*ExportError) Message

func (e *ExportError) Message() string

type ImportError

type ImportError struct {
	BaseReport
	Module string
	Name   string
}

func NewImportError

func NewImportError(decl ast.Node, module string, name *ast.Ident) *ImportError

type ModuleNotImportedError

type ModuleNotImportedError struct {
	BaseReport
	Module string
}

func NewModuleNotImportedError

func NewModuleNotImportedError(expr ast.Node, name string) *ModuleNotImportedError

func (ModuleNotImportedError) Message

func (e ModuleNotImportedError) Message() string

type Region

type Region struct {
	Start token.Pos
	End   token.Pos
}

func RegionFromNode

func RegionFromNode(node ast.Node) *Region

type RepeatedCtorError

type RepeatedCtorError struct {
	BaseReport
	Ctor string
}

func NewRepeatedCtorError

func NewRepeatedCtorError(decl ast.Decl, name *ast.Ident) *RepeatedCtorError

func (RepeatedCtorError) Message

func (e RepeatedCtorError) Message() string

type RepeatedFieldError

type RepeatedFieldError struct {
	BaseReport
	Field string
}

func NewRepeatedFieldError

func NewRepeatedFieldError(record ast.Node, field *ast.Ident) *RepeatedFieldError

func (*RepeatedFieldError) Message

func (e *RepeatedFieldError) Message() string

type RepeatedVarTypeError

type RepeatedVarTypeError struct {
	BaseReport
	Var string
}

func NewRepeatedVarTypeError

func NewRepeatedVarTypeError(decl ast.Decl, name *ast.Ident) *RepeatedVarTypeError

func (RepeatedVarTypeError) Message

func (e RepeatedVarTypeError) Message() string

type Report

type Report interface {
	Type() ReportType
	Message() string
	Pos() token.Pos
	Region() *Region
}

func NewExpectedTypeError

func NewExpectedTypeError(pos token.Pos, region *Region) Report

func NewUnexpectedEOFError

func NewUnexpectedEOFError(pos token.Pos, region *Region) Report

type ReportType

type ReportType byte
const (
	OtherError ReportType = iota
	SyntaxError
	NameError
	TypeError
	Info
	Warning
)

func (ReportType) Color

func (t ReportType) Color() func(string, ...interface{}) string

func (ReportType) String

func (t ReportType) String() string

type Reporter

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

Reporter is in charge of reporting the diagnostics occurred during any of the compilation steps to the user.

func NewReporter

func NewReporter(cm *source.CodeMap, emitter Emitter) *Reporter

NewReporter creates a new reporter.

func (*Reporter) Emit

func (r *Reporter) Emit() error

Emit writes all the reports using the reporter's emitter.

func (*Reporter) IsOK

func (r *Reporter) IsOK() bool

IsOK returns true if there are no diagnostics yet.

func (*Reporter) Report

func (r *Reporter) Report(path string, report Report)

Report adds a new report occurred at some path.

func (*Reporter) Reports

func (r *Reporter) Reports(path string) []Report

type UndefinedError

type UndefinedError struct {
	BaseReport
	Name string
}

func NewUndefinedError

func NewUndefinedError(expr ast.Node, name *ast.Ident) *UndefinedError

func (UndefinedError) Message

func (e UndefinedError) Message() string

type UndefinedTypeVarError

type UndefinedTypeVarError struct {
	BaseReport
	Name string
}

func NewUndefinedTypeVarError

func NewUndefinedTypeVarError(expr ast.Node, varTyp *ast.VarType) *UndefinedTypeVarError

func (UndefinedTypeVarError) Message

func (e UndefinedTypeVarError) Message() string

type UnexpectedTokenError

type UnexpectedTokenError struct {
	BaseReport
	Token    *token.Token
	Expected []token.Type
}

func NewUnexpectedTokenError

func NewUnexpectedTokenError(tok *token.Token, region *Region, expected ...token.Type) *UnexpectedTokenError

func (UnexpectedTokenError) Message

func (e UnexpectedTokenError) Message() string

type UnresolvedNameError

type UnresolvedNameError struct {
	BaseReport
	Name string
}

func NewUnresolvedNameError

func NewUnresolvedNameError(name string, node *ast.Ident) *UnresolvedNameError

func (*UnresolvedNameError) Message

func (e *UnresolvedNameError) Message() string

Jump to

Keyboard shortcuts

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