info

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package info provides informational types related to hcl.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pos

type Pos struct {
	// contains filtered or unexported fields
}

Pos represents a single position in a source file, by addressing the start byte of a unicode character encoded in UTF-8.

Pos is generally used only in the context of a Range, which then defines which source file the position is within.

func NewPos

func NewPos(p hcl.Pos) Pos

NewPos creates a new Pos from the given hcl.Pos.

func (Pos) Byte

func (p Pos) Byte() int

Byte is the byte offset into the file where the indicated character begins. This is a zero-based offset to the first byte of the first UTF-8 codepoint sequence in the character, and thus gives a position that can be resolved _without_ awareness of Unicode characters.

func (Pos) Column

func (p Pos) Column() int

Column is the source code column where this position points, in unicode characters, with counting starting at 1.

Column counts characters as they appear visually, so for example a latin letter with a combining diacritic mark counts as one character. This is intended for rendering visual markers against source code in contexts where these diacritics would be rendered in a single character cell. Technically speaking, Column is counting grapheme clusters as used in unicode normalization.

func (Pos) Line

func (p Pos) Line() int

Line is the source code line where this position points. Lines are counted starting at 1 and incremented for each newline character encountered.

type Range

type Range struct {
	// contains filtered or unexported fields
}

Range represents a span of characters between two positions in a source file.

func NewRange

func NewRange(rootdir string, r hcl.Range) Range

NewRange creates a new Range from the given hcl.Range and the rootdir. This function assumes that the filename on the given hcl.Range is absolute and inside rootdir.

func (Range) End

func (r Range) End() Pos

End represents the end of the bounds of this range, it is exclusive.

func (Range) HostPath

func (r Range) HostPath() string

HostPath is the name of the file into which this range's positions point. It is always an absolute path on the host filesystem.

func (Range) Path

func (r Range) Path() project.Path

Path is the name of the file into which this range's positions point. It is always an absolute path relative to the project root.

func (Range) Start

func (r Range) Start() Pos

Start represents the start of the bounds of this range, it is inclusive.

func (Range) String

func (r Range) String() string

func (Range) ToHCLRange

func (r Range) ToHCLRange() hcl.Range

ToHCLRange converts Range to hcl.Range.

Jump to

Keyboard shortcuts

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