internal

package
v0.9.0-alpha.2 Latest Latest
Warning

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

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

Documentation

Overview

Package internal exposes some cue internals to other packages.

A better name for this package would be technicaldebt.

Index

Constants

View Source
const (
	MinorCurrent   = 5
	MinorSupported = 4
	PatchSupported = 0
)
View Source
const MaxDepth = 20

MaxDepth indicates the maximum evaluation depth. This is there to break cycles in the absence of cycle detection.

It is registered in a central place to make it easy to find all spots where cycles are broken in this brute-force manner.

TODO(eval): have cycle detection.

Variables

View Source
var APIVersionSupported = Version(MinorSupported, PatchSupported)

APIVersionSupported is the back version until which deprecated features are still supported.

View Source
var BaseContext = Context{*apd.BaseContext.WithPrecision(34)}

BaseContext is used as CUE's default context for arbitrary-precision decimals.

View Source
var ErrIncomplete = errors.New("incomplete value")

ErrIncomplete can be used by builtins to signal the evaluation was incomplete.

View Source
var ErrInexact = errors.New("inexact subsumption")
View Source
var MakeInstance func(value interface{}) (instance interface{})

MakeInstance makes a new instance from a value.

Functions

func ConstraintToken added in v0.6.0

func ConstraintToken(f *ast.Field) (t token.Token, ok bool)

ConstraintToken reports which constraint token (? or !) is associated with a field (if any), taking into account compatibility of deprecated fields.

func DecorateError added in v0.1.0

func DecorateError(info error, err errors.Error) errors.Error

func EmbedStruct added in v0.2.0

func EmbedStruct(s *ast.StructLit) *ast.EmbedDecl

func FileComment added in v0.2.0

func FileComment(f *ast.File) *ast.CommentGroup

func GenPath added in v0.1.0

func GenPath(root string) string

GenPath reports the directory in which to store generated files.

func IsDef added in v0.2.0

func IsDef(s string) bool

func IsDefOrHidden added in v0.2.0

func IsDefOrHidden(s string) bool

func IsDefinition added in v0.2.0

func IsDefinition(label ast.Label) bool

func IsEllipsis added in v0.1.0

func IsEllipsis(x ast.Decl) bool

IsEllipsis reports whether the declaration can be represented as an ellipsis.

func IsHidden added in v0.2.0

func IsHidden(s string) bool

func IsRegularField added in v0.2.0

func IsRegularField(f *ast.Field) bool

func ListEllipsis added in v0.0.6

func ListEllipsis(n *ast.ListLit) (elts []ast.Expr, e *ast.Ellipsis)

ListEllipsis reports the list type and remaining elements of a list. If we ever relax the usage of ellipsis, this function will likely change. Using this function will ensure keeping correct behavior or causing a compiler failure.

func NewAttr added in v0.1.0

func NewAttr(name, str string) *ast.Attribute

func NewComment added in v0.1.0

func NewComment(isDoc bool, s string) *ast.CommentGroup

NewComment creates a new CommentGroup from the given text. Each line is prefixed with "//" and the last newline is removed. Useful for ASTs generated by code other than the CUE parser.

func PackageInfo deprecated added in v0.0.6

func PackageInfo(f *ast.File) (p *ast.Package, name string, tok token.Pos)

Deprecated: use GetPackageInfo

func SetConstraint added in v0.6.0

func SetConstraint(f *ast.Field, t token.Token)

SetConstraints sets both the main and deprecated fields of f according to the given constraint token.

func SetPackage added in v0.2.0

func SetPackage(f *ast.File, name string, overwrite bool)

func ToExpr added in v0.1.0

func ToExpr(n ast.Node) ast.Expr

ToExpr converts a node to an expression. If it is a file, it will return it as a struct. If is an expression, it will return it as is. Otherwise it panics.

func ToFile added in v0.1.0

func ToFile(n ast.Node) *ast.File

ToFile converts an expression to a file.

Adjusts the spacing of x when needed.

func Version added in v0.5.0

func Version(minor, patch int) int

Types

type Attr added in v0.1.0

type Attr struct {
	Name   string // e.g. "json" or "protobuf"
	Body   string
	Kind   AttrKind
	Fields []KeyValue
	Err    errors.Error
}

Attr holds positional information for a single Attr.

func NewNonExisting added in v0.1.0

func NewNonExisting(key string) Attr

NewNonExisting creates a non-existing attribute.

func ParseAttrBody added in v0.1.0

func ParseAttrBody(pos token.Pos, s string) (a Attr)

func (*Attr) Flag added in v0.1.0

func (a *Attr) Flag(pos int, key string) (bool, error)

Flag reports whether an entry with the given name exists at position pos or onwards or an error if the attribute is invalid or if the first pos-1 entries are not defined.

func (*Attr) Int added in v0.1.0

func (a *Attr) Int(pos int) (int64, error)

Int reports the integer at the given position or an error if the attribute is invalid, the position does not exist, or the value at the given position is not an integer.

func (*Attr) Lookup added in v0.1.0

func (a *Attr) Lookup(pos int, key string) (val string, found bool, err error)

Lookup searches for an entry of the form key=value from position pos onwards and reports the value if found. It reports an error if the attribute is invalid or if the first pos-1 entries are not defined.

func (*Attr) String added in v0.1.0

func (a *Attr) String(pos int) (string, error)

String reports the possibly empty string value at the given position or an error the attribute is invalid or if the position does not exist.

type AttrKind added in v0.3.0

type AttrKind uint8

AttrKind indicates the location of an attribute within CUE source.

const (
	// FieldAttr indicates an attribute is a field attribute.
	// foo: bar @attr()
	FieldAttr AttrKind = 1 << iota

	// DeclAttr indicates an attribute was specified at a declaration position.
	// foo: {
	//     @attr()
	// }
	DeclAttr
)

type Context added in v0.6.0

type Context struct {
	apd.Context
}

Context wraps apd.Context for CUE's custom logic.

Note that it avoids pointers to make it easier to make copies.

func (Context) Quo added in v0.6.0

func (c Context) Quo(d, x, y *apd.Decimal) (apd.Condition, error)

func (Context) Sqrt added in v0.6.0

func (c Context) Sqrt(d, x *apd.Decimal) (apd.Condition, error)

func (Context) WithPrecision added in v0.6.0

func (c Context) WithPrecision(p uint32) Context

WithPrecision mirrors upstream, but returning our type without a pointer.

type Decimal added in v0.0.5

type Decimal = apd.Decimal

A Decimal is an arbitrary-precision binary-coded decimal number.

Right now Decimal is aliased to apd.Decimal. This may change in the future.

type EvaluatorVersion added in v0.8.0

type EvaluatorVersion int
const (
	DefaultVersion EvaluatorVersion = iota

	// The DevVersion is used for new implementations of the evaluator that
	// do not cover all features of the CUE language yet.
	DevVersion
)

type KeyValue added in v0.3.0

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

func (*KeyValue) Key added in v0.3.0

func (kv *KeyValue) Key() string

func (*KeyValue) Text added in v0.3.0

func (kv *KeyValue) Text() string

func (*KeyValue) Value added in v0.3.0

func (kv *KeyValue) Value() string

type PkgInfo added in v0.3.0

type PkgInfo struct {
	Package *ast.Package
	Index   int // position in File.Decls
	Name    string
}

func GetPackageInfo added in v0.3.0

func GetPackageInfo(f *ast.File) PkgInfo

func (*PkgInfo) IsAnonymous added in v0.3.1

func (p *PkgInfo) IsAnonymous() bool

IsAnonymous reports whether the package is anonymous.

Directories

Path Synopsis
cmd
cue-ast-print
cue-ast-print parses a CUE file and prints its syntax tree, for example:
cue-ast-print parses a CUE file and prints its syntax tree, for example:
Package copy provides utilities to copy files and directories.
Package copy provides utilities to copy files and directories.
core
adt
Package adt represents partially and fully evaluated CUE types.
Package adt represents partially and fully evaluated CUE types.
convert
Package convert allows converting to and from Go values and Types.
Package convert allows converting to and from Go values and Types.
debug
Package debug prints a given ADT node.
Package debug prints a given ADT node.
dep
Package dep analyzes dependencies between values.
Package dep analyzes dependencies between values.
path
Package path provides utilities for converting cue.Selectors and cue.Paths to internal equivalents.
Package path provides utilities for converting cue.Selectors and cue.Paths to internal equivalents.
subsume
Package subsume defines various subsumption relations.
Package subsume defines various subsumption relations.
validate
Package validate collects errors from an evaluated Vertex.
Package validate collects errors from an evaluated Vertex.
walk
walk provides functions for visiting the nodes of an ADT tree.
walk provides functions for visiting the nodes of an ADT tree.
Package cueconfig holds internal API relating to CUE configuration.
Package cueconfig holds internal API relating to CUE configuration.
Package cueimports provides support for reading the import section of a CUE file without needing to read the rest of it.
Package cueimports provides support for reading the import section of a CUE file without needing to read the rest of it.
Package testing is a helper package for test packages in the CUE project.
Package testing is a helper package for test packages in the CUE project.
Package cueversion provides access to the version of the cuelang.org/go module.
Package cueversion provides access to the version of the cuelang.org/go module.
golangorgx
gopls/cache
Package cache is the core of gopls: it is concerned with state management, dependency analysis, and invalidation; and it holds the machinery of type checking and modular static analysis.
Package cache is the core of gopls: it is concerned with state management, dependency analysis, and invalidation; and it holds the machinery of type checking and modular static analysis.
gopls/cache/metadata
The metadata package defines types and functions for working with package metadata, which describes Go packages and their relationships.
The metadata package defines types and functions for working with package metadata, which describes Go packages and their relationships.
gopls/cache/methodsets
Package methodsets defines an incremental, serializable index of method-set information that allows efficient 'implements' queries across packages of the workspace without using the type checker.
Package methodsets defines an incremental, serializable index of method-set information that allows efficient 'implements' queries across packages of the workspace without using the type checker.
gopls/cache/typerefs
Package typerefs extracts symbol-level reachability information from the syntax of a Go package.
Package typerefs extracts symbol-level reachability information from the syntax of a Go package.
gopls/cache/xrefs
Package xrefs defines the serializable index of cross-package references that is computed during type checking.
Package xrefs defines the serializable index of cross-package references that is computed during type checking.
gopls/cmd
Package cmd handles the gopls command line.
Package cmd handles the gopls command line.
gopls/cuelang
Package golang defines the LSP features for navigation, analysis, and refactoring of Go source code.
Package golang defines the LSP features for navigation, analysis, and refactoring of Go source code.
gopls/debug
Package debug exports debug information for gopls.
Package debug exports debug information for gopls.
gopls/debug/log
Package log provides helper methods for exporting log events to the internal/event package.
Package log provides helper methods for exporting log events to the internal/event package.
gopls/file
The file package defines types used for working with LSP files.
The file package defines types used for working with LSP files.
gopls/filecache
The filecache package provides a file-based shared durable blob cache.
The filecache package provides a file-based shared durable blob cache.
gopls/golang
Package golang defines the LSP features for navigation, analysis, and refactoring of Go source code.
Package golang defines the LSP features for navigation, analysis, and refactoring of Go source code.
gopls/hooks
Package hooks adds all the standard gopls implementations.
Package hooks adds all the standard gopls implementations.
gopls/lsprpc
Package lsprpc implements a jsonrpc2.StreamServer that may be used to serve the LSP on a jsonrpc2 channel.
Package lsprpc implements a jsonrpc2.StreamServer that may be used to serve the LSP on a jsonrpc2 channel.
gopls/progress
The progress package defines utilities for reporting the progress of long-running operations using features of the LSP client interface such as Progress and ShowMessage.
The progress package defines utilities for reporting the progress of long-running operations using features of the LSP client interface such as Progress and ShowMessage.
gopls/protocol
Package protocol contains the structs that map directly to the request and response messages of the Language Server Protocol.
Package protocol contains the structs that map directly to the request and response messages of the Language Server Protocol.
gopls/protocol/command
Package command defines the interface provided by gopls for the workspace/executeCommand LSP request.
Package command defines the interface provided by gopls for the workspace/executeCommand LSP request.
gopls/protocol/semtok
The semtok package provides an encoder for LSP's semantic tokens.
The semtok package provides an encoder for LSP's semantic tokens.
gopls/server
Package server defines gopls' implementation of the LSP server interface, [protocol.Server].
Package server defines gopls' implementation of the LSP server interface, [protocol.Server].
gopls/template
Package template contains code for dealing with templates
Package template contains code for dealing with templates
gopls/test/integration
Package integration provides a framework for writing integration tests of gopls.
Package integration provides a framework for writing integration tests of gopls.
gopls/test/integration/fake
Package fake provides a fake implementation of an LSP-enabled text editor, its LSP client plugin, and a Sandbox environment for use in integration tests.
Package fake provides a fake implementation of an LSP-enabled text editor, its LSP client plugin, and a Sandbox environment for use in integration tests.
gopls/test/integration/fake/glob
Package glob implements an LSP-compliant glob pattern matcher for testing.
Package glob implements an LSP-compliant glob pattern matcher for testing.
gopls/util/astutil
Package astutil provides various AST utility functions for gopls.
Package astutil provides various AST utility functions for gopls.
gopls/util/browser
Package browser provides utilities for interacting with users' browsers.
Package browser provides utilities for interacting with users' browsers.
gopls/util/bug
Package bug provides utilities for reporting internal bugs, and being notified when they occur.
Package bug provides utilities for reporting internal bugs, and being notified when they occur.
gopls/util/constraints
Package constraints defines a set of useful constraints to be used with type parameters.
Package constraints defines a set of useful constraints to be used with type parameters.
gopls/util/frob
Package frob is a fast restricted object encoder/decoder in the spirit of encoding/gob.
Package frob is a fast restricted object encoder/decoder in the spirit of encoding/gob.
gopls/util/goversion
Package goversions defines gopls's policy for which versions of Go it supports.
Package goversions defines gopls's policy for which versions of Go it supports.
gopls/util/immutable
The immutable package defines immutable wrappers around common data structures.
The immutable package defines immutable wrappers around common data structures.
gopls/util/lru
The lru package implements a fixed-size in-memory LRU cache.
The lru package implements a fixed-size in-memory LRU cache.
gopls/util/persistent
The persistent package defines various persistent data structures; that is, data structures that can be efficiently copied and modified in sublinear time.
The persistent package defines various persistent data structures; that is, data structures that can be efficiently copied and modified in sublinear time.
gopls/util/safetoken
Package safetoken provides wrappers around methods in go/token, that return errors rather than panicking.
Package safetoken provides wrappers around methods in go/token, that return errors rather than panicking.
gopls/version
Package version manages the gopls version.
Package version manages the gopls version.
telemetry/counter
Package counter implements a simple counter system for collecting totally public telemetry data.
Package counter implements a simple counter system for collecting totally public telemetry data.
telemetry/internal/config
package config provides methods for loading and querying a telemetry upload config file.
package config provides methods for loading and querying a telemetry upload config file.
telemetry/internal/configstore
Package configstore abstracts interaction with the telemetry config server.
Package configstore abstracts interaction with the telemetry config server.
telemetry/internal/counter
Package internal/counter implements the internals of the public counter package.
Package internal/counter implements the internals of the public counter package.
telemetry/internal/mmap
The mmap package provides an abstraction for memory mapping files on different platforms.
The mmap package provides an abstraction for memory mapping files on different platforms.
telemetry/internal/telemetry
Package telemetry manages the telemetry mode file.
Package telemetry manages the telemetry mode file.
tools/analysisinternal
Package analysisinternal provides gopls' internal analyses with a number of helper functions that operate on typed syntax trees.
Package analysisinternal provides gopls' internal analyses with a number of helper functions that operate on typed syntax trees.
tools/diff
Package diff computes differences between text files or strings.
Package diff computes differences between text files or strings.
tools/diff/lcs
package lcs contains code to find longest-common-subsequences (and diffs)
package lcs contains code to find longest-common-subsequences (and diffs)
tools/event
Package event provides a set of packages that cover the main concepts of telemetry in an implementation agnostic way.
Package event provides a set of packages that cover the main concepts of telemetry in an implementation agnostic way.
tools/event/core
Package core provides support for event based telemetry.
Package core provides support for event based telemetry.
tools/event/export/metric
Package metric aggregates events into metrics that can be exported.
Package metric aggregates events into metrics that can be exported.
tools/event/export/ocagent
Package ocagent adds the ability to export all telemetry to an ocagent.
Package ocagent adds the ability to export all telemetry to an ocagent.
tools/event/tag
Package tag provides the labels used for telemetry throughout gopls.
Package tag provides the labels used for telemetry throughout gopls.
tools/facts
Package facts defines a serializable set of analysis.Fact.
Package facts defines a serializable set of analysis.Fact.
tools/fuzzy
Package fuzzy implements a fuzzy matching algorithm.
Package fuzzy implements a fuzzy matching algorithm.
tools/gcimporter
Package gcimporter provides various functions for reading gc-generated object files that can be used to implement the Importer interface defined by the Go 1.5 standard library package.
Package gcimporter provides various functions for reading gc-generated object files that can be used to implement the Importer interface defined by the Go 1.5 standard library package.
tools/gocommand
Package gocommand is a helper for calling the go command.
Package gocommand is a helper for calling the go command.
tools/gopathwalk
Package gopathwalk is like filepath.Walk but specialized for finding Go packages, particularly in $GOPATH and $GOROOT.
Package gopathwalk is like filepath.Walk but specialized for finding Go packages, particularly in $GOPATH and $GOROOT.
tools/goroot
Package goroot is a copy of package internal/goroot in the main GO repot.
Package goroot is a copy of package internal/goroot in the main GO repot.
tools/imports
Package imports implements a Go pretty-printer (like package "go/format") that also adds or removes import statements as necessary.
Package imports implements a Go pretty-printer (like package "go/format") that also adds or removes import statements as necessary.
tools/jsonrpc2
Package jsonrpc2 is a minimal implementation of the JSON RPC 2 spec.
Package jsonrpc2 is a minimal implementation of the JSON RPC 2 spec.
tools/jsonrpc2/servertest
Package servertest provides utilities for running tests against a remote LSP server.
Package servertest provides utilities for running tests against a remote LSP server.
tools/jsonrpc2_v2
Package jsonrpc2 is a minimal implementation of the JSON RPC 2 spec.
Package jsonrpc2 is a minimal implementation of the JSON RPC 2 spec.
tools/memoize
Package memoize defines a "promise" abstraction that enables memoization of the result of calling an expensive but idempotent function.
Package memoize defines a "promise" abstraction that enables memoization of the result of calling an expensive but idempotent function.
tools/packagesinternal
Package packagesinternal exposes internal-only fields from go/packages.
Package packagesinternal exposes internal-only fields from go/packages.
tools/pkgbits
Package pkgbits implements low-level coding abstractions for Unified IR's export data format.
Package pkgbits implements low-level coding abstractions for Unified IR's export data format.
tools/proxydir
Package proxydir provides functions for writing module data to a directory in proxy format, so that it can be used as a module proxy by setting GOPROXY="file://<dir>".
Package proxydir provides functions for writing module data to a directory in proxy format, so that it can be used as a module proxy by setting GOPROXY="file://<dir>".
tools/refactor/inline
Package inline implements inlining of Go function calls.
Package inline implements inlining of Go function calls.
tools/robustio
Package robustio wraps I/O functions that are prone to failure on Windows, transparently retrying errors up to an arbitrary timeout.
Package robustio wraps I/O functions that are prone to failure on Windows, transparently retrying errors up to an arbitrary timeout.
tools/testenv
Package testenv contains helper functions for skipping tests based on which tools are present in the environment.
Package testenv contains helper functions for skipping tests based on which tools are present in the environment.
tools/tokeninternal
package tokeninternal provides access to some internal features of the token package.
package tokeninternal provides access to some internal features of the token package.
tools/tool
Package tool is a harness for writing Go tools.
Package tool is a harness for writing Go tools.
tools/typeparams
Package typeparams contains common utilities for writing tools that interact with generic Go code, as introduced with Go 1.18.
Package typeparams contains common utilities for writing tools that interact with generic Go code, as introduced with Go 1.18.
tools/typesinternal
Package typesinternal provides access to internal go/types APIs that are not yet exported.
Package typesinternal provides access to internal go/types APIs that are not yet exported.
tools/xcontext
Package xcontext is a package to offer the extra functionality we need from contexts that is not available from the standard context package.
Package xcontext is a package to offer the extra functionality we need from contexts that is not available from the standard context package.
mod
mvs
Package mvs implements Minimal Version Selection.
Package mvs implements Minimal Version Selection.
semver
Package semver implements comparison of semantic version strings.
Package semver implements comparison of semantic version strings.
Package par implements parallel execution helpers.
Package par implements parallel execution helpers.
Package source contains utility functions that standardize reading source bytes across cue packages.
Package source contains utility functions that standardize reading source bytes across cue packages.
Package task provides a registry for tasks to be used by commands.
Package task provides a registry for tasks to be used by commands.
Package tdtest provides support for table-driven testing.
Package tdtest provides support for table-driven testing.
third_party
yaml
Package yaml implements YAML support for the Go language.
Package yaml implements YAML support for the Go language.
Package value contains functions for converting values to internal types and various other Value-related utilities.
Package value contains functions for converting values to internal types and various other Value-related utilities.

Jump to

Keyboard shortcuts

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