source

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: Apache-2.0 Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLastColumnOnLine

func GetLastColumnOnLine(line int, linePositions []int) (int, int)

GetLastColumnOnLine returns the last column on a given line based on the provided line positions. The second return value is the raw offset for the end of the line.

func PositionFromSourceMeta

func PositionFromSourceMeta(sourceMeta *Meta) (line *int, column *int)

PositionFromSourceMeta returns the line and column from the provided source meta. This is primarily useful for attaching position information to errors.

Types

type Meta

type Meta struct {
	Position
	EndPosition *Position `json:"endPosition,omitempty"`
}

Meta represents information about the deserialised source of a blueprint value including the line and column where a blueprint element begins that can be used by tools such as linters to provide more detailed diagnostics to users creating blueprints from source in some supported formats.

func ExtractSourcePositionForJSONNodeMapField

func ExtractSourcePositionForJSONNodeMapField(
	node *json.Node,
	linePositions []int,
) *Meta

ExtractSourcePositionForJSONNodeMapField extracts the position in source document from a given JSON node and line positions.

func ExtractSourcePositionFromJSONNode

func ExtractSourcePositionFromJSONNode(
	node *json.Node,
	linePositions []int,
) *Meta

ExtractSourcePositionFromJSONNode extracts the position in source document from a given JSON node and line positions.

type Position

type Position struct {
	Line   int `json:"line"`
	Column int `json:"column"`
}

Position represents a position in the source code of a blueprint.

func EndSourcePositionFromYAMLScalarNode

func EndSourcePositionFromYAMLScalarNode(node *yaml.Node) *Position

EndSourcePositionFromYAMLScalarNode returns the precise end position of a YAML scalar node.

func PositionFromJSONNode

func PositionFromJSONNode(node *json.Node, linePositions []int) Position

PositionFromJSONNode returns the position of a JSON node in the source code based on the node and an ordered list of line offsets.

func PositionFromOffset

func PositionFromOffset(offset int, linePositions []int) Position

PositionFromOffset returns the position of a character in the source code based on the offset and an ordered list of line offsets. This treats the offset of a new line character as the end of the line and not the first column of the next line.

func (*Position) GetColumn

func (p *Position) GetColumn() int

func (*Position) GetLine

func (p *Position) GetLine() int

type PositionInfo

type PositionInfo interface {
	GetLine() int
	GetColumn() int
}

PositionInfo provides an interface for the position information of a value. This is primarily useful for attaching position information to errors for values extracted from intermediary source document nodes with position/offset information.

type Range

type Range struct {
	Start *Position
	End   *Position
}

Range represents a range in the source code of a blueprint. Start and End could also hold additional information provided in the Meta struct.

Jump to

Keyboard shortcuts

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