source

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2019 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

File represents a source file.

func (*File) AddLine

func (f *File) AddLine(offset int)

AddLine adds a new line.

func (*File) Base

func (f *File) Base() int

Base returns the base position of the file.

func (*File) FileSetPos

func (f *File) FileSetPos(offset int) Pos

FileSetPos returns the position in the file set.

func (*File) LineCount

func (f *File) LineCount() int

LineCount returns the current number of lines.

func (*File) LineStart

func (f *File) LineStart(line int) Pos

LineStart returns the position of the first character in the line.

func (*File) Name

func (f *File) Name() string

Name returns the file name.

func (*File) Offset

func (f *File) Offset(p Pos) int

Offset translates the file set position into the file offset.

func (*File) Position

func (f *File) Position(p Pos) (pos FilePos)

Position translates the file set position into the file position.

func (*File) Size

func (f *File) Size() int

Size returns the size of the file.

type FilePos

type FilePos struct {
	Filename string // filename, if any
	Offset   int    // offset, starting at 0
	Line     int    // line number, starting at 1
	Column   int    // column number, starting at 1 (byte count)
}

FilePos represents a position information in the file.

func (FilePos) IsValid

func (p FilePos) IsValid() bool

IsValid returns true if the position is valid.

func (FilePos) String

func (p FilePos) String() string

String returns a string in one of several forms:

file:line:column    valid position with file name
file:line           valid position with file name but no column (column == 0)
line:column         valid position without file name
line                valid position without file name and no column (column == 0)
file                invalid position with file name
-                   invalid position without file name

type FileSet

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

FileSet represents a set of source files.

func NewFileSet

func NewFileSet() *FileSet

NewFileSet creates a new file set.

func (*FileSet) AddFile

func (s *FileSet) AddFile(filename string, base, size int) *File

AddFile adds a new file in the file set.

func (*FileSet) Base

func (s *FileSet) Base() int

Base returns the current base position of the file set.

func (*FileSet) File

func (s *FileSet) File(p Pos) (f *File)

File returns the file that contains the position p. If no such file is found (for instance for p == NoPos), the result is nil.

func (*FileSet) Position

func (s *FileSet) Position(p Pos) (pos FilePos)

Position converts a Pos p in the fileset into a FilePos value.

type Pos

type Pos int

Pos represents a position in the file set.

const NoPos Pos = 0

NoPos represents an invalid position.

func (Pos) IsValid

func (p Pos) IsValid() bool

IsValid returns true if the position is valid.

Jump to

Keyboard shortcuts

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