ui

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsoleUI

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

ConsoleUI is a concrete implementation of ErrorHandler

func NewConsoleUI

func NewConsoleUI(warningAsErrors, suppressWarnings bool) *ConsoleUI

NewConsoleUI return a new ConsoleUI

func (*ConsoleUI) GetErrorCount

func (c *ConsoleUI) GetErrorCount() int

GetErrorCount return the number of errors found during parsing

func (*ConsoleUI) ReportError

func (c *ConsoleUI) ReportError(msg string, newLine bool)

ReportError report a generic error without format

func (*ConsoleUI) ReportMessage

func (c *ConsoleUI) ReportMessage(msg string, newLine bool)

ReportMessage report a message to the user

func (*ConsoleUI) ReportSourceError

func (c *ConsoleUI) ReportSourceError(msg string, index uint, line UIPrintable)

ReportSourceError report an error to the user

func (*ConsoleUI) ReportSourceWarning

func (c *ConsoleUI) ReportSourceWarning(msg string, index uint, line UIPrintable)

ReportSourceWarning report a warning to the user if suppressWarning is false

func (*ConsoleUI) ReportWarning

func (c *ConsoleUI) ReportWarning(msg string, newLine bool)

ReportWarning report a warning without format, can be ignored

type SourceCodeError

type SourceCodeError interface {
	Error() string
	Report(ui UI, line UIPrintable)
	GetLine() uint
}

SourceCodeError is an enrichment of the Error interface in go

type UI

type UI interface {
	ReportSourceError(msg string, index uint, line UIPrintable)
	ReportSourceWarning(msg string, index uint, line UIPrintable)
	ReportError(msg string, newLine bool)
	ReportWarning(msg string, newLine bool)
	ReportMessage(msg string, newLine bool)
	GetErrorCount() int
}

UI is an interface to report errors, warnings and messages to user

type UIPrintable

type UIPrintable interface {
	Print(ui UI)                            //Print the object using ui
	RuneIndex(ui UI, indexOfWord uint) uint //RuneIndex calculate the index of the first rune of the specified word
	LineNumber() uint                       //LineNumber return the lineNumber
	StringAt(i uint) string                 //StringAt return the i-th string
}

UIPrintable is an interface of a user printable object

Jump to

Keyboard shortcuts

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