otto: Index | Files

package file

import ""

Package file encapsulates the file abstractions used by the ast & parser.


Package Files


type File Uses

type File struct {
    // contains filtered or unexported fields

func NewFile Uses

func NewFile(filename, src string, base int) *File

func (*File) Base Uses

func (fl *File) Base() int

func (*File) Name Uses

func (fl *File) Name() string

func (*File) Position Uses

func (fl *File) Position(idx Idx) *Position

func (*File) Source Uses

func (fl *File) Source() string

func (*File) WithSourceMap Uses

func (fl *File) WithSourceMap(sm *sourcemap.Consumer) *File

type FileSet Uses

type FileSet struct {
    // contains filtered or unexported fields

A FileSet represents a set of source files.

func (*FileSet) AddFile Uses

func (self *FileSet) AddFile(filename, src string) int

AddFile adds a new file with the given filename and src.

This an internal method, but exported for cross-package use.

func (*FileSet) File Uses

func (self *FileSet) File(idx Idx) *File

func (*FileSet) Position Uses

func (self *FileSet) Position(idx Idx) *Position

Position converts an Idx in the FileSet into a Position.

type Idx Uses

type Idx int

Idx is a compact encoding of a source position within a file set. It can be converted into a Position for a more convenient, but much larger, representation.

type Position Uses

type Position struct {
    Filename string // The filename where the error occurred, if any
    Offset   int    // The src offset
    Line     int    // The line number, starting at 1
    Column   int    // The column number, starting at 1 (The character count)


Position describes an arbitrary source position including the filename, line, and column location.

func (*Position) String Uses

func (self *Position) String() string

String returns a string in one of several forms:

file:line:column    A valid position with filename
line:column         A valid position without filename
file                An invalid position with filename
-                   An invalid position without filename

Package file imports 3 packages (graph) and is imported by 122 packages. Updated 2018-03-04. Refresh now. Tools for package owners.