parseutil

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KebabName = resourceNameSpec{
	// contains filtered or unexported fields
}
View Source
var SnakeName = resourceNameSpec{
	// contains filtered or unexported fields
}

Functions

func FindPkgNameRefs

func FindPkgNameRefs(pkg *pkginfo.Package, pkgNames []pkginfo.QualifiedName, fn func(f *pkginfo.File, name pkginfo.QualifiedName, stack []ast.Node))

FindPkgNameRefs finds all references in the given package that references any of the given pkgNames. For each such reference it calls fn.

func NodeType

func NodeType(node ast.Node) string

NodeType converts a node to a string that can be used in an error message. such as a ast.CallExpr will return "a function call to foo.Blah"

func ParseReference

func ParseReference(p *resourceparser.Pass, spec *ReferenceSpec, data ReferenceData)

func ParseResourceName

func ParseResourceName(errs *perr.List, resourceType string, paramName string, node ast.Expr, nameSpec resourceNameSpec, reservedPrefix string) string

ParseResourceName checks the given node is a string literal and that it conforms to the given spec.

If an error is encountered, it will report a parse error and return an empty string otherwise it will return the parsed resource name

Types

type ReferenceData

type ReferenceData struct {
	File         *pkginfo.File
	Stack        []ast.Node
	ResourceFunc pkginfo.QualifiedName
}

type ReferenceInfo

type ReferenceInfo struct {
	Pass         *resourceparser.Pass
	ResourceFunc pkginfo.QualifiedName
	File         *pkginfo.File

	Stack    []ast.Node
	Call     *ast.CallExpr
	TypeArgs []schema.Type
	Doc      string

	// Ident is the identifier this reference is assigned to, if any.
	Ident option.Option[*ast.Ident]
}

type ReferenceSpec

type ReferenceSpec struct {
	MinTypeArgs int
	MaxTypeArgs int
	Parse       func(ReferenceInfo)
}

Jump to

Keyboard shortcuts

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