filepos

package
v0.51.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package filepos provides the concept of Position: a source name (usually a file) and line number within that source.

File positions are crucial when reporting errors to the user. It is often even more useful to share the actual source line as well. For this reason Position also contains a cached copy of the source line at the Position.

Not all Position point within a file (e.g. code that is generated). The zero-value of Position (can be created using NewUnknownPosition()) represents this case.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Position

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

func NewPosition

func NewPosition(lineNum int) *Position

func NewPositionInFile added in v0.48.0

func NewPositionInFile(lineNum int, file string) *Position

NewPositionInFile returns the Position of line "lineNum" within the file "file"

func NewUnknownPosition

func NewUnknownPosition() *Position

NewUnknownPosition is equivalent of zero value *Position

func NewUnknownPositionInFile added in v0.48.0

func NewUnknownPositionInFile(file string) *Position

NewUnknownPositionInFile produces a Position of a known file at an unknown line.

func NewUnknownPositionWithKeyVal added in v0.48.0

func NewUnknownPositionWithKeyVal(k, v interface{}, separator string) *Position

func (*Position) As4DigitString

func (p *Position) As4DigitString() string

func (*Position) AsCompactString added in v0.14.0

func (p *Position) AsCompactString() string

func (*Position) AsIntString

func (p *Position) AsIntString() string

func (*Position) AsString

func (p *Position) AsString() string

func (*Position) DeepCopy

func (p *Position) DeepCopy() *Position

func (*Position) DeepCopyWithLineOffset added in v0.17.0

func (p *Position) DeepCopyWithLineOffset(offset int) *Position

func (*Position) FromMemory added in v0.48.0

func (p *Position) FromMemory() bool

func (*Position) GetFile added in v0.48.0

func (p *Position) GetFile() string

func (*Position) GetLine added in v0.48.0

func (p *Position) GetLine() string

func (*Position) IsKnown

func (p *Position) IsKnown() bool

func (*Position) IsNextTo added in v0.48.0

func (p *Position) IsNextTo(otherPosition *Position) bool

IsNextTo compares the location of one position with another.

func (*Position) LineNum added in v0.48.0

func (p *Position) LineNum() int

func (*Position) SetLine added in v0.48.0

func (p *Position) SetLine(line string)

Jump to

Keyboard shortcuts

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