lang

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2020 License: MPL-2.0 Imports: 15 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 PosInLabels added in v0.3.0

func PosInLabels(b *hclsyntax.Block, pos hcl.Pos) bool

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)
	Range() hcl.Range
	PosInBody(pos hcl.Pos) bool
	PosInAttribute(pos hcl.Pos) bool
	PosInAttributeValue(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(tBlock ihcl.TokenizedBlock, schema *tfjson.SchemaBlock) Block

ParseBlock parses HCL block's tokens 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) PosInAttributeValue added in v0.5.3

func (b *BlockType) PosInAttributeValue(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
	Documentation() MarkupContent
	Snippet() TextEdit
	PlainText() TextEdit
}

CompletionCandidate represents a candidate for completion loosely reflecting lsp.CompletionItem

type CompletionCandidates added in v0.2.0

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

CompletionCandidates 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() []*ParsedLabel
}

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
	IsCompletable bool
}

type LabelSchema added in v0.2.0

type LabelSchema []Label

type Markdown added in v0.3.0

type Markdown string

Markdown represents markdown formatted markup content for the LSP.

func (Markdown) Value added in v0.3.0

func (m Markdown) Value() string

Value returns the content itself for the LSP protocol.

type MarkupContent added in v0.3.0

type MarkupContent interface {
	// TODO: eventually will need to propapate Kind here once the LSP
	// protocol types we use support it
	Value() string
}

MarkupContent reflects lsp.MarkupContent

type ParsedLabel added in v0.3.0

type ParsedLabel struct {
	Name  string
	Value string
	Range hcl.Range
}

func LabelAtPos added in v0.3.0

func LabelAtPos(labels []*ParsedLabel, pos hcl.Pos) (*ParsedLabel, bool)

func ParseLabels added in v0.3.0

func ParseLabels(tBlock ihcl.TokenizedBlock, schema LabelSchema) []*ParsedLabel

ParseLabels parses HCL block's tokens based on LabelSchema, returning labels as a slice of *ParsedLabel

type Parser

type Parser interface {
	SetLogger(*log.Logger)
	SetSchemaReader(schema.Reader)
	BlockTypeCandidates(ihcl.TokenizedFile, hcl.Pos) CompletionCandidates
	CompletionCandidatesAtPos(ihcl.TokenizedFile, hcl.Pos) (CompletionCandidates, 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

type PlainText added in v0.3.0

type PlainText string

PlainText represents plain text markup content for the LSP.

func (PlainText) Value added in v0.3.0

func (m PlainText) Value() string

Value returns the content itself for the LSP protocol.

type TextEdit added in v0.3.0

type TextEdit interface {
	Range() *hcl.Range
	NewText() string
}

type TokenAtPosLooker added in v0.3.0

type TokenAtPosLooker interface {
	TokenAtPosition(hcl.Pos) (hclsyntax.Token, error)
}

Jump to

Keyboard shortcuts

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