lang

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: 6 Imported by: 0

Documentation

Overview

Package lang defines the core types that can be adapted to language server constructs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Candidate

type Candidate struct {
	Label               string
	Description         MarkupContent
	Detail              string
	IsDeprecated        bool
	TextEdit            TextEdit
	AdditionalTextEdits []TextEdit
	Kind                CandidateKind

	// TriggerSuggest allows server to instruct the client whether
	// to reopen candidate suggestion popup after insertion
	TriggerSuggest bool

	// ResolveHook allows resolution of additional information
	// for a completion candidate via ResolveCandidate.
	ResolveHook *ResolveHook

	// SortText is an optional string that will be used when comparing this
	// candidate with other candidates
	SortText string
}

Candidate represents a completion candidate in the form of an attribute, block, or a label

type CandidateKind

type CandidateKind uint
const (
	NilCandidateKind CandidateKind = iota

	// structural kinds
	AttributeCandidateKind
	BlockCandidateKind
	LabelCandidateKind

	// expressions
	BoolCandidateKind
	KeywordCandidateKind
	ListCandidateKind
	MapCandidateKind
	NumberCandidateKind
	ObjectCandidateKind
	SetCandidateKind
	StringCandidateKind
	TupleCandidateKind
	ReferenceCandidateKind
	FunctionCandidateKind
)

func (CandidateKind) String

func (i CandidateKind) String() string

type Candidates

type Candidates struct {
	List       []Candidate
	IsComplete bool
}

Candidates represents a list of candidates and indication whether the list is complete or if it needs further filtering because there is too many candidates.

Decoder has an upper limit for the number of candidates it can return and when the limit is reached, the list is considered incomplete.

func CompleteCandidates

func CompleteCandidates(list []Candidate) Candidates

CompleteCandidates creates a static (complete) list of candidates

NewCandidates should be used at runtime instead, but CompleteCandidates provides a syntactic sugar useful in tests.

func IncompleteCandidates

func IncompleteCandidates(list []Candidate) Candidates

IncompleteCandidates creates a static list of candidates

NewCandidates should be used at runtime instead, but IncompleteCandidates provides a syntactic sugar useful in tests.

func NewCandidates

func NewCandidates() Candidates

NewCandidates creates a new (incomplete) list of candidates to be appended to.

func ZeroCandidates

func ZeroCandidates() Candidates

ZeroCandidates returns a (complete) "list" of no candidates

func (Candidates) Len

func (ca Candidates) Len() int

func (Candidates) Less

func (ca Candidates) Less(i, j int) bool

func (Candidates) Swap

func (ca Candidates) Swap(i, j int)

type CodeLens

type CodeLens struct {
	Range   hcl.Range
	Command Command
}

type CodeLensFunc

type CodeLensFunc func(ctx context.Context, path Path, file string) ([]CodeLens, error)

type Command

type Command struct {
	Title     string
	ID        string
	Arguments []CommandArgument
}

type CommandArgument

type CommandArgument interface {
	MarshalJSON() ([]byte, error)
}

type CompletionHook

type CompletionHook struct {
	Name string
}

type CompletionHooks

type CompletionHooks []CompletionHook

func (CompletionHooks) Copy

func (chs CompletionHooks) Copy() CompletionHooks

type DiagnosticsMap

type DiagnosticsMap map[string]hcl.Diagnostics

func (DiagnosticsMap) Count

func (dm DiagnosticsMap) Count() int

Count returns the number of diagnostics for all files

func (DiagnosticsMap) Extend

func (dm DiagnosticsMap) Extend(diagMap DiagnosticsMap) DiagnosticsMap

type ExpressionCandidate

type ExpressionCandidate struct {
	// Value represents the value to be inserted
	Value cty.Value

	// Detail represents a human-readable string with additional
	// information about this candidate, like symbol information.
	Detail string

	// Description represents human-readable description
	// of the candidate
	Description MarkupContent

	// IsDeprecated indicates whether the candidate is deprecated
	IsDeprecated bool
}

ExpressionCandidate is a simplified version of HookCandidate and the preferred way to create completion candidates from completion hooks for attributes values (expressions). One can use ExpressionCompletionCandidate to convert those into candidates.

type FunctionParameter

type FunctionParameter struct {
	// Name is the parameter name.
	Name string
	// Description is an optional human-readable description
	// of the parameter.
	Description MarkupContent
}

FunctionParameter represents a parameter for a function.

type FunctionSignature

type FunctionSignature struct {
	// Name is the function name.
	Name string
	// Description is an optional human-readable description
	// of the function.
	Description MarkupContent
	// Parameters is an ordered list of the function's parameters.
	Parameters []FunctionParameter
	// ActiveParameter is an index marking the parameter a user is currently
	// editing. It should lie inside the range of Parameters.
	ActiveParameter uint32
}

FunctionSignature represents a function's signature.

type HookCandidate

type HookCandidate struct {
	// Label represents a human-readable name of the candidate
	// if one exists (otherwise Value is used)
	Label string
	// Detail represents a human-readable string with additional
	// information about this candidate, like symbol information.
	Detail string
	Kind   CandidateKind
	// Description represents human-readable description
	// of the candidate
	Description MarkupContent
	// IsDeprecated indicates whether the candidate is deprecated
	IsDeprecated bool
	// RawInsertText represents the final text which is used to build the
	// TextEdit for completion. It should contain quotes when completing
	// strings.
	RawInsertText string
	// ResolveHook represents a resolve hook to call
	// and any arguments to pass to it
	ResolveHook *ResolveHook
	// SortText is an optional string that will be used when comparing this
	// candidate with other candidates
	SortText string
}

HookCandidate represents a completion candidate created and returned from a completion hook.

func ExpressionCompletionCandidate

func ExpressionCompletionCandidate(c ExpressionCandidate) HookCandidate

ExpressionCompletionCandidate converts a simplified ExpressionCandidate into a HookCandidate while taking care of populating fields and quoting strings

type HoverData

type HoverData struct {
	Content MarkupContent
	Range   hcl.Range
}
type Link struct {
	URI     string
	Tooltip string
	Range   hcl.Range
}

type LiteralTypeKind

type LiteralTypeKind struct {
	Type cty.Type
}

type MarkupContent

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

MarkupContent represents human-readable content which can be represented as Markdown or plaintext for backwards-compatible reasons.

func Markdown

func Markdown(value string) MarkupContent

func NewMarkup

func NewMarkup(kind MarkupKind, value string) MarkupContent

func PlainText

func PlainText(value string) MarkupContent

func (MarkupContent) AsDetail

func (m MarkupContent) AsDetail() string

func (MarkupContent) Kind

func (m MarkupContent) Kind() MarkupKind

func (MarkupContent) Value

func (m MarkupContent) Value() string

type MarkupKind

type MarkupKind uint
const (
	NilKind MarkupKind = iota
	PlainTextKind
	MarkdownKind
)

func (MarkupKind) String

func (i MarkupKind) String() string

type ObjectConsExprKind

type ObjectConsExprKind struct{}

type Path

type Path struct {
	Path       string
	LanguageID string
}

func (Path) Equals

func (path Path) Equals(p Path) bool

type ReferenceExprKind

type ReferenceExprKind struct{}

type ResolveHook

type ResolveHook struct {
	Name string `json:"resolve_hook,omitempty"`
	Path string `json:"path,omitempty"`
}

type SymbolExprKind

type SymbolExprKind interface {
	// contains filtered or unexported methods
}

type TextEdit

type TextEdit struct {
	Range   hcl.Range
	NewText string
	Snippet string
}

TextEdit represents a change (edit) of an HCL config file in the form of a Snippet *and* NewText to replace the given Range.

Snippet and NewText are equivalent, but NewText is provided for backwards-compatible reasons. Snippet uses 1-indexed placeholders, such as name = ${1:value}.

type TupleConsExprKind

type TupleConsExprKind struct{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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