target

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package target provides definition and reference information for a function-hcl module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SchemaForRelativeTraversal

func SchemaForRelativeTraversal(root *schema.AttributeSchema, traversal hcl.Traversal) (ret *schema.AttributeSchema)

SchemaForRelativeTraversal returns the child schema implied by the root schema and the supplied traversal. The traversal does not have to be a relative traversal; an absolute one is also ok. It returns an unknown schema if a schema could not be found.

func SubSchema

func SubSchema(s *schema.AttributeSchema, path ...string) *schema.AttributeSchema

SubSchema returns a known schema at the supplied path relative to the supplied root schema. It returns an unknown schema if one could not be found.

Types

type DefToRefs

type DefToRefs map[hcl.Range][]hcl.Range // map of definition ranges to multiple reference ranges

type Node

type Node struct {
	Name        string                  // the name using which the node is referenced
	IsContainer bool                    // container node that has an implied schema of "any object"
	Schema      *schema.AttributeSchema // the schema for non-container nodes
	NameRange   hcl.Range               // the range where the name of the node is declared
	Definition  hcl.Range               // the range where the node is defined
	Children    []*Node                 // the child nodes of this one.
}

Node represents a specific leaf or intermediate target in a target tree.

func (*Node) AsSchema

func (n *Node) AsSchema() *schema.AttributeSchema

type ReferenceMap

type ReferenceMap struct {
	DefToRefs DefToRefs
	RefsToDef RefsToDef
}

ReferenceMap provides mappings between definitions and references in both directions.

func BuildReferenceMap

func BuildReferenceMap(files map[string]*hcl.File, targets *Targets) *ReferenceMap

BuildReferenceMap builds the reference map for a module.

func (*ReferenceMap) FindDefinitionFromReference

func (p *ReferenceMap) FindDefinitionFromReference(filename string, pos hcl.Pos) *hcl.Range

FindDefinitionFromReference returns the definition range for a reference range that includes the supplied position.

func (*ReferenceMap) FindReferencesFromDefinition

func (p *ReferenceMap) FindReferencesFromDefinition(filename string, pos hcl.Pos) []hcl.Range

FindReferencesFromDefinition returns reference ranges for a definition range that includes the supplied position.

type RefsToDef

type RefsToDef map[hcl.Range]hcl.Range // maps of reference ranges to definition ranges

type Targets

type Targets struct {
	CompositeSchema *schema.AttributeSchema // the schema used for the composite or nil
	// contains filtered or unexported fields
}

Targets provides a mechanism to find all accessible symbols at a given position. It contains a global tree for references that are accessible globally (e.g. file-scoped variables, req.composite etc.) and stores extra information for block scoped locals, self aliases for resources and collections. Given a position in a file, these extras allow construction of a "visible" tree that contains all accessible references from that position.

func BuildTargets

func BuildTargets(files map[string]*hcl.File, dyn ourschema.DynamicLookup, compositeSchema *schema.AttributeSchema) *Targets

BuildTargets builds targets for a module.

func (*Targets) VisibleTreeAt

func (t *Targets) VisibleTreeAt(parent *hcl.Block, file string, pos hcl.Pos) *Tree

VisibleTreeAt returns a tree that contains all references visible from the supplied position in a specific file.

type Tree

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

Tree is a tree of nodes accessible in a given scope.

func (*Tree) AsSchema

func (t *Tree) AsSchema() *schema.AttributeSchema

AsSchema returns the contents of the tree as an attribute schema of a top-level object that represents the tree as a whole.

func (*Tree) Roots

func (t *Tree) Roots() []*Node

Roots returns the roots of the tree. These are the "top-level variables" like locals, `req`, `self`, `each` etc.

Jump to

Keyboard shortcuts

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