lang

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyConfigErr = &emptyCfgErr{}

Functions

func AsHCLSyntaxBlock

func AsHCLSyntaxBlock(block *hcl.Block) (*hclsyntax.Block, error)

func ParserSupportsTerraform

func ParserSupportsTerraform(v string) error

Types

type Attribute

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

func (*Attribute) IsComputedOnly

func (a *Attribute) IsComputedOnly() bool

func (*Attribute) IsDeclared

func (a *Attribute) IsDeclared() bool

func (*Attribute) Range

func (a *Attribute) Range() hcl.Range

func (*Attribute) Schema

func (a *Attribute) Schema() *tfjson.SchemaAttribute

type Block

type Block interface {
	BlockAtPos(pos hcl.Pos) (Block, bool)
	LabelAtPos(pos hcl.Pos) (*Label, bool)
	Range() hcl.Range
	PosInLabels(pos hcl.Pos) bool
	PosInBody(pos hcl.Pos) bool
	PosInAttribute(pos hcl.Pos) bool
	Attributes() map[string]*Attribute
	BlockTypes() map[string]*BlockType
}

Block represents a decoded HCL block (by a Parser) which keeps track of the related schema

func ParseBlock

func ParseBlock(block *hclsyntax.Block, labels []*Label, schema *tfjson.SchemaBlock) Block

ParseBlock parses HCL configuration based on tfjson's SchemaBlock and keeps hold of all tfjson schema details on block or attribute level

type BlockType

type BlockType struct {
	BlockList []Block
	// contains filtered or unexported fields
}

func (*BlockType) BlockAtPos

func (b *BlockType) BlockAtPos(pos hcl.Pos) (Block, bool)

func (*BlockType) PosInAttribute

func (b *BlockType) PosInAttribute(pos hcl.Pos) bool

func (*BlockType) ReachedMaxItems

func (b *BlockType) ReachedMaxItems() bool

func (*BlockType) Schema

func (b *BlockType) Schema() *tfjson.SchemaBlockType

type BlockTypes

type BlockTypes map[string]*BlockType

func (BlockTypes) AddBlock

func (bt BlockTypes) AddBlock(name string, block *hclsyntax.Block, typeSchema *tfjson.SchemaBlockType)

type CompletionCandidate added in v0.2.0

type CompletionCandidate interface {
	Label() string
	Detail() string
	Snippet(pos hcl.Pos) (hcl.Pos, string)
}

CompletionCandidate represents a candidate for completion loosely reflecting lsp.CompletionItem

type CompletionCandidates added in v0.2.0

type CompletionCandidates interface {
	List() []CompletionCandidate
	IsComplete() bool
}

CompletionCandidate represents a list of candidates for completion loosely reflecting lsp.CompletionList

type ConfigBlock

type ConfigBlock interface {
	CompletionCandidatesAtPos(pos hcl.Pos) (CompletionCandidates, error)
	Name() string
	BlockType() string
	Labels() []*Label
}

ConfigBlock implements an abstraction above HCL block which provides any LSP capabilities (e.g. completion)

type Label added in v0.2.0

type Label struct {
	Name  string
	Value string
}

type LabelSchema added in v0.2.0

type LabelSchema []string

type Parser

type Parser interface {
	SetLogger(*log.Logger)
	SetSchemaReader(schema.Reader)
	ParseBlockFromHCL(*hcl.Block) (ConfigBlock, error)
}

Parser implements a parser which can turn raw HCL block into ConfigBlock with the help of a schema reader

func FindCompatibleParser

func FindCompatibleParser(v string) (Parser, error)

FindCompatibleParser finds a parser that is compatible with given Terraform version, so that it parses config accuretly

Jump to

Keyboard shortcuts

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