Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLastColumnOnLine ¶
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 ¶
PositionFromSourceMeta returns the line and column from the provided source meta. This is primarily useful for attaching position information to errors.
Types ¶
type ColumnAccuracy ¶ added in v0.39.0
type ColumnAccuracy int
ColumnAccuracy indicates how accurate the column position is.
const ( // ColumnAccuracyExact indicates that column numbers are accurate. ColumnAccuracyExact ColumnAccuracy = 1 // ColumnAccuracyApproximate indicates that column numbers are approximate. // This is the case for YAML block literals where the column cannot be precisely determined. ColumnAccuracyApproximate ColumnAccuracy = 2 )
type Meta ¶
type Meta struct {
Position
EndPosition *Position `json:"endPosition,omitempty"`
ColumnAccuracy *ColumnAccuracy `json:"columnAccuracy,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 ¶
ExtractSourcePositionForJSONNodeMapField extracts the position in source document for a map field's KEY (not value) from a given JSON node. This is useful for error reporting where we want to highlight the field name.
type Position ¶
Position represents a position in the source code of a blueprint.
func EndSourcePositionFromYAMLScalarNode ¶
EndSourcePositionFromYAMLScalarNode returns the precise end position of a YAML scalar node.
func PositionFromJSONNode ¶
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 ¶
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.
type PositionInfo ¶
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 PositionRange ¶ added in v0.39.0
type PositionRange struct {
Line *int
Column *int
EndLine *int
EndColumn *int
ColumnAccuracy *ColumnAccuracy
}
PositionRange holds start and end positions with column accuracy information.
func PositionRangeFromSourceMeta ¶ added in v0.39.0
func PositionRangeFromSourceMeta(sourceMeta *Meta) *PositionRange
PositionRangeFromSourceMeta extracts position range info from source meta. Returns an empty PositionRange (with nil fields) if sourceMeta is nil.