source

package
Version: v1.24.8 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2019 License: MIT Imports: 2 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 {

	// File name as provided to AddFile
	Name string
	// Pos value range for this file is [base...base+size]
	Base int
	// File size as provided to AddFile
	Size int
	// Lines contains the offset of the first character for each line (the first entry is always 0)
	Lines []int
	// 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) 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) 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) Set added in v1.9.0

func (f *File) Set() *FileSet

Set returns FileSet.

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 {
	Base     int     // base offset for the next file
	Files    []*File // list of files in the order added to the set
	LastFile *File   // cache of last file looked up
}

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) 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