Documentation
¶
Index ¶
- func ExtractContext(content string, loc domain.Location, before, after int) []string
- func ExtractContextBytes(content []byte, loc domain.Location, before, after int) []string
- func HighlightColumn(content string, loc domain.Location) string
- func HighlightColumnWithLength(content string, loc domain.Location, length int) string
- type LocationTracker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractContext ¶
ExtractContext extracts source lines around a location for error display. before and after specify how many lines to include before and after the target line. Returns empty slice if the location is invalid.
func ExtractContextBytes ¶
ExtractContextBytes is like ExtractContext but takes []byte input.
func HighlightColumn ¶
HighlightColumn creates a visual pointer at the specified column. Returns a string with the source line and a pointer line below it.
Types ¶
type LocationTracker ¶
type LocationTracker struct {
// contains filtered or unexported fields
}
LocationTracker tracks the source locations (line/column) of YAML fields. This is essential for providing accurate error messages with file locations.
func NewLocationTracker ¶
func NewLocationTracker(content []byte) (*LocationTracker, error)
NewLocationTracker creates a LocationTracker from YAML content.
func NewLocationTrackerWithFile ¶
func NewLocationTrackerWithFile(content []byte, filePath string) (*LocationTracker, error)
NewLocationTrackerWithFile creates a LocationTracker with an associated file path.
func (*LocationTracker) GetLocation ¶
func (t *LocationTracker) GetLocation(path string) domain.Location
GetLocation returns the location of a field specified by path. Path uses dot notation for nested fields (e.g., "metadata.author") and bracket notation for array indices (e.g., "tags[0]" or "[0].id"). Returns a zero location if the path is not found.
func (*LocationTracker) GetValueLocation ¶
func (t *LocationTracker) GetValueLocation(path string) domain.Location
GetValueLocation returns the location of a field's value. This finds the value node, not the key node.