usage

package
v1.35.3 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterUsageResolver

func RegisterUsageResolver[Res resource.Resource](r *Resolver, fn func(ResolveData, Res) Usage)

Types

type Base

type Base struct {
	File *pkginfo.File
	Bind resource.Bind
	Expr Expr
}

func (*Base) ASTExpr

func (b *Base) ASTExpr() ast.Expr

func (*Base) DeclaredIn

func (b *Base) DeclaredIn() *pkginfo.File

func (*Base) End

func (b *Base) End() token.Pos

func (*Base) Pos

func (b *Base) Pos() token.Pos

func (*Base) ResourceBind

func (b *Base) ResourceBind() resource.Bind

type Expr

type Expr interface {
	// Node allows use to use the expression in error messages
	// where the Pos/End is used to point directly at the resource
	// bind being used, rather than the overall expression.
	ast.Node

	ResourceBind() resource.Bind
	ASTExpr() ast.Expr
	DeclaredIn() *pkginfo.File

	// DescriptionForTest describes the expression for testing purposes.
	DescriptionForTest() string
}

func ParseExprs

func ParseExprs(schema *schema.Parser, pkgs []*pkginfo.Package, binds []resource.Bind) []Expr

type FieldAccess

type FieldAccess struct {
	File  *pkginfo.File
	Bind  resource.Bind
	Expr  *ast.SelectorExpr
	Field string
}

FieldAccess describes a resource usage via a field access.

func (*FieldAccess) ASTExpr

func (f *FieldAccess) ASTExpr() ast.Expr

func (*FieldAccess) DeclaredIn

func (f *FieldAccess) DeclaredIn() *pkginfo.File

func (*FieldAccess) DescriptionForTest

func (f *FieldAccess) DescriptionForTest() string

func (*FieldAccess) End

func (f *FieldAccess) End() token.Pos

func (*FieldAccess) Pos

func (f *FieldAccess) Pos() token.Pos

func (*FieldAccess) ResourceBind

func (f *FieldAccess) ResourceBind() resource.Bind

type FuncArg

type FuncArg struct {
	File *pkginfo.File
	Bind resource.Bind
	Call *ast.CallExpr

	// TypeArgs are the type arguments to the function being called, if any.
	TypeArgs []schema.Type

	// ArgIdx is the function argument index that represents
	// the resource bind, starting at 0.
	ArgIdx int

	// PkgFunc is the package-level function that's being called.
	// It's None if the function is not a package-level function.
	PkgFunc option.Option[pkginfo.QualifiedName]
}

FuncArg describes a resource being used as a function argument.

func (*FuncArg) ASTExpr

func (f *FuncArg) ASTExpr() ast.Expr

func (*FuncArg) DeclaredIn

func (f *FuncArg) DeclaredIn() *pkginfo.File

func (*FuncArg) DescriptionForTest

func (f *FuncArg) DescriptionForTest() string

func (*FuncArg) End

func (f *FuncArg) End() token.Pos

func (*FuncArg) Pos

func (f *FuncArg) Pos() token.Pos

func (*FuncArg) ResourceBind

func (f *FuncArg) ResourceBind() resource.Bind

type FuncCall

type FuncCall struct {
	File *pkginfo.File
	Bind resource.Bind
	Call *ast.CallExpr
	Args []ast.Expr
}

FuncCall describes a resource being called as a function.

func (*FuncCall) ASTExpr

func (f *FuncCall) ASTExpr() ast.Expr

func (*FuncCall) DeclaredIn

func (f *FuncCall) DeclaredIn() *pkginfo.File

func (*FuncCall) DescriptionForTest

func (f *FuncCall) DescriptionForTest() string

func (*FuncCall) End

func (f *FuncCall) End() token.Pos

func (*FuncCall) Pos

func (f *FuncCall) Pos() token.Pos

func (*FuncCall) ResourceBind

func (f *FuncCall) ResourceBind() resource.Bind

type MethodCall

type MethodCall struct {
	File   *pkginfo.File
	Bind   resource.Bind
	Call   *ast.CallExpr
	Method string
	Args   []ast.Expr
}

MethodCall describes a resource usage via a method call.

func (*MethodCall) ASTExpr

func (m *MethodCall) ASTExpr() ast.Expr

func (*MethodCall) DeclaredIn

func (m *MethodCall) DeclaredIn() *pkginfo.File

func (*MethodCall) DescriptionForTest

func (m *MethodCall) DescriptionForTest() string

func (*MethodCall) End

func (m *MethodCall) End() token.Pos

func (*MethodCall) Pos

func (m *MethodCall) Pos() token.Pos

func (*MethodCall) ResourceBind

func (m *MethodCall) ResourceBind() resource.Bind

type Other

type Other struct {
	File    *pkginfo.File
	Bind    resource.Bind
	Expr    ast.Expr
	BindRef ast.Expr
}

Other describes any other resource usage.

func (*Other) ASTExpr

func (o *Other) ASTExpr() ast.Expr

func (*Other) DeclaredIn

func (o *Other) DeclaredIn() *pkginfo.File

func (*Other) DescriptionForTest

func (o *Other) DescriptionForTest() string

func (*Other) End

func (o *Other) End() token.Pos

func (*Other) Pos

func (o *Other) Pos() token.Pos

func (*Other) ResourceBind

func (o *Other) ResourceBind() resource.Bind

type ResolveData

type ResolveData struct {
	Errs *perr.List
	Expr Expr
}

ResolveData is the data being passed to usage resolver functions.

type Resolver

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

func NewResolver

func NewResolver() *Resolver

func (*Resolver) Resolve

func (r *Resolver) Resolve(errs *perr.List, expr Expr, res resource.Resource) option.Option[Usage]

type Usage

type Usage interface {
	ast.Node

	ResourceBind() resource.Bind
	ASTExpr() ast.Expr
	DeclaredIn() *pkginfo.File
	// contains filtered or unexported methods
}

Usage describes an infrastructure usage being used.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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