opa: github.com/open-policy-agent/opa/ast/location Index | Files

package location

import "github.com/open-policy-agent/opa/ast/location"

Package location defines locations in Rego source code.

Index

Package Files

location.go

type Location Uses

type Location struct {
    Text   []byte `json:"-"`    // The original text fragment from the source.
    File   string `json:"file"` // The name of the source file (which may be empty).
    Row    int    `json:"row"`  // The line in the source.
    Col    int    `json:"col"`  // The column in the row.
    Offset int    `json:"-"`    // The byte offset for the location in the source.
}

Location records a position in source code

func NewLocation Uses

func NewLocation(text []byte, file string, row int, col int) *Location

NewLocation returns a new Location object.

func (*Location) Compare Uses

func (loc *Location) Compare(other *Location) int

Compare returns -1, 0, or 1 to indicate if this loc is less than, equal to, or greater than the other. Comparison is performed on the file, row, and column of the Location (but not on the text.) Nil locations are greater than non-nil locations.

func (*Location) Equal Uses

func (loc *Location) Equal(other *Location) bool

Equal checks if two locations are equal to each other.

func (*Location) Errorf Uses

func (loc *Location) Errorf(f string, a ...interface{}) error

Errorf returns a new error value with a message formatted to include the location info (e.g., line, column, filename, etc.)

func (*Location) Format Uses

func (loc *Location) Format(f string, a ...interface{}) string

Format returns a formatted string prefixed with the location information.

func (*Location) String Uses

func (loc *Location) String() string

func (*Location) Wrapf Uses

func (loc *Location) Wrapf(err error, f string, a ...interface{}) error

Wrapf returns a new error value that wraps an existing error with a message formatted to include the location info (e.g., line, column, filename, etc.)

Package location imports 3 packages (graph) and is imported by 1 packages. Updated 2020-03-26. Refresh now. Tools for package owners.