reference

package
v0.0.0-...-d90dc4d Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MPL-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const InfiniteDepth = -1

Variables

This section is empty.

Functions

This section is empty.

Types

type DirectOrigin

type DirectOrigin struct {
	// Range represents a range of a local traversal, attribute, or an expression
	Range hcl.Range

	// TargetPath represents what (directory) Path does the origin targets
	TargetPath lang.Path

	// TargetRange represents which file and line the origin targets
	TargetRange hcl.Range
}

DirectOrigin represents an origin which directly targets a file and doesn't need a matching target

func (DirectOrigin) Copy

func (do DirectOrigin) Copy() Origin

func (DirectOrigin) OriginRange

func (do DirectOrigin) OriginRange() hcl.Range

type LocalOrigin

type LocalOrigin struct {
	// Addr describes the resolved address of the reference
	Addr lang.Address

	// Range represents the range of the traversal
	Range hcl.Range

	// Constraints represents any traversal expression constraints
	// for the attribute where the origin was found.
	//
	// Further matching against decoded reference targets is needed
	// for >1 constraints, which is done later at runtime as
	// targets and origins can be decoded at different times.
	Constraints OriginConstraints
}

LocalOrigin represents a resolved reference origin (traversal) targeting a *local* attribute or a block within the same path

func TraversalToLocalOrigin

func TraversalToLocalOrigin(traversal hcl.Traversal, cons OriginConstraints, allowSelfRefs bool) (LocalOrigin, bool)

func (LocalOrigin) Address

func (lo LocalOrigin) Address() lang.Address

func (LocalOrigin) AppendConstraints

func (lo LocalOrigin) AppendConstraints(oc OriginConstraints) MatchableOrigin

func (LocalOrigin) Copy

func (lo LocalOrigin) Copy() Origin

func (LocalOrigin) OriginConstraints

func (lo LocalOrigin) OriginConstraints() OriginConstraints

func (LocalOrigin) OriginRange

func (lo LocalOrigin) OriginRange() hcl.Range

type MatchableOrigin

type MatchableOrigin interface {
	Origin
	OriginConstraints() OriginConstraints
	AppendConstraints(OriginConstraints) MatchableOrigin
	Address() lang.Address
}

type NoOriginFound

type NoOriginFound struct{}

func (*NoOriginFound) Error

func (*NoOriginFound) Error() string

type NoTargetFound

type NoTargetFound struct{}

func (*NoTargetFound) Error

func (*NoTargetFound) Error() string

type Origin

type Origin interface {
	Copy() Origin
	OriginRange() hcl.Range
	// contains filtered or unexported methods
}

type OriginConstraint

type OriginConstraint struct {
	OfScopeId lang.ScopeId
	OfType    cty.Type
}

type OriginConstraints

type OriginConstraints []OriginConstraint

func (OriginConstraints) Copy

type Origins

type Origins []Origin

func (Origins) AtPos

func (ro Origins) AtPos(file string, pos hcl.Pos) (Origins, bool)

func (Origins) Copy

func (ro Origins) Copy() Origins

func (Origins) Match

func (ro Origins) Match(localPath lang.Path, target Target, targetPath lang.Path) Origins

type PathOrigin

type PathOrigin struct {
	// Range represents a range of a local traversal or an attribute
	Range hcl.Range

	// TargetAddr describes the address of the targeted attribute or block
	TargetAddr lang.Address

	// TargetPath represents what Path does the origin target
	TargetPath lang.Path

	// Constraints represent any constraints to use when filtering
	// the targets within the destination Path
	Constraints OriginConstraints
}

PathOrigin represents a resolved reference origin targeting an attribute or a block in a separate path

func (PathOrigin) Address

func (po PathOrigin) Address() lang.Address

func (PathOrigin) AppendConstraints

func (po PathOrigin) AppendConstraints(oc OriginConstraints) MatchableOrigin

func (PathOrigin) Copy

func (po PathOrigin) Copy() Origin

func (PathOrigin) OriginConstraints

func (po PathOrigin) OriginConstraints() OriginConstraints

func (PathOrigin) OriginRange

func (po PathOrigin) OriginRange() hcl.Range

type Target

type Target struct {
	// Addr represents the address of the target, as available
	// elsewhere in the configuration
	Addr lang.Address

	// LocalAddr represents the address of the target
	// as available *locally* (e.g. self.attr_name)
	LocalAddr lang.Address

	// TargetableFromRangePtr defines where the target is targetable from.
	// This is considered when matching the target against origin.
	//
	// e.g. count.index is only available within the body of the block
	// where count is declared (and extension enabled)
	TargetableFromRangePtr *hcl.Range

	// ScopeId provides scope for matching/filtering
	// (in addition to Type & Addr/LocalAddr).
	//
	// There should never be two targets with the same Type & address,
	// but there are contexts (e.g. completion) where we don't filter
	// by address and may not have type either (e.g. because targets
	// are type-unaware).
	ScopeId lang.ScopeId

	// RangePtr represents range of the whole attribute or block
	// or nil if the target is not addressable.
	RangePtr *hcl.Range

	// DefRangePtr represents a definition range, i.e. block header,
	// or an attribute name or nil if the target is not addressable
	// or when it represents multiple list, set or map blocks.
	//
	// This is useful in situation where a representative single-line
	// range is needed - e.g. to render a contextual UI element in
	// the editor near the middle of this range.
	DefRangePtr *hcl.Range

	Type        cty.Type
	Name        string
	Description lang.MarkupContent

	NestedTargets Targets
}

func (Target) Address

func (r Target) Address(ctx context.Context, pos hcl.Pos) lang.Address

Address returns any of the two non-empty addresses depending on the provided context

func (Target) Copy

func (ref Target) Copy() Target

func (Target) FriendlyName

func (r Target) FriendlyName() string

func (Target) IsConvertibleToType

func (ref Target) IsConvertibleToType(typ cty.Type) bool

func (Target) Matches

func (target Target) Matches(origin MatchableOrigin) bool

func (Target) MatchesConstraint

func (target Target) MatchesConstraint(ref schema.Reference) bool

func (Target) MatchesScopeId

func (ref Target) MatchesScopeId(scopeId lang.ScopeId) bool

func (Target) TargetRange

func (r Target) TargetRange() (hcl.Range, bool)

type TargetWalkFunc

type TargetWalkFunc func(Target) error

type Targets

type Targets []Target

func (Targets) Copy

func (refs Targets) Copy() Targets

func (Targets) InnermostAtPos

func (refs Targets) InnermostAtPos(file string, pos hcl.Pos) (Targets, bool)

func (Targets) Len

func (r Targets) Len() int

func (Targets) Less

func (r Targets) Less(i, j int) bool

func (Targets) Match

func (refs Targets) Match(origin MatchableOrigin) (Targets, bool)

func (Targets) MatchWalk

func (targets Targets) MatchWalk(ctx context.Context, ref schema.Reference, prefix string, outermostBodyRng, originRng hcl.Range, f TargetWalkFunc)

func (Targets) OutermostInFile

func (refs Targets) OutermostInFile(file string) Targets

func (Targets) Swap

func (r Targets) Swap(i, j int)

Jump to

Keyboard shortcuts

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