package internal
import "cuelang.org/go/internal"
Package internal exposes some cue internals to other packages.
A better name for this package would be technicaldebt.
Index ¶
- Constants
- Variables
- func ConstraintToken(f *ast.Field) (t token.Token, ok bool)
- func EmbedStruct(s *ast.StructLit) *ast.EmbedDecl
- func FileComments(f *ast.File) (docs, rest []*ast.CommentGroup)
- func GenPath(root string) string
- func IsDef(s string) bool
- func IsDefOrHidden(s string) bool
- func IsDefinition(label ast.Label) bool
- func IsEllipsis(x ast.Decl) bool
- func IsHidden(s string) bool
- func IsRegularField(f *ast.Field) bool
- func ListEllipsis(n *ast.ListLit) (elts []ast.Expr, e *ast.Ellipsis)
- func MergeDocs(comments []*ast.CommentGroup) []*ast.CommentGroup
- func NewAttr(name, str string) *ast.Attribute
- func NewComment(isDoc bool, s string) *ast.CommentGroup
- func Package(f *ast.File) *ast.Package
- func SetConstraint(f *ast.Field, t token.Token)
- func SetPackage(f *ast.File, name string, overwrite bool)
- func ToExpr(n ast.Node) ast.Expr
- func ToFile(n ast.Node) *ast.File
- func Version(minor, patch int) int
- type Attr
- func NewNonExisting(key string) Attr
- func ParseAttrBody(pos token.Pos, s string) (a Attr)
- func (a *Attr) Flag(pos int, key string) (bool, error)
- func (a *Attr) Int(pos int) (int64, error)
- func (a *Attr) Lookup(pos int, key string) (val string, found bool, err error)
- func (a *Attr) String(pos int) (string, error)
- type AttrKind
- type Context
- func (c Context) Quo(d, x, y *apd.Decimal) (apd.Condition, error)
- func (c Context) Sqrt(d, x *apd.Decimal) (apd.Condition, error)
- func (c Context) WithPrecision(p uint32) Context
- type Decimal
- type EvaluatorVersion
- type KeyValue
Constants ¶
const ( MinorCurrent = 5 MinorSupported = 4 PatchSupported = 0 )
Variables ¶
var APIVersionSupported = Version(MinorSupported, PatchSupported)
APIVersionSupported is the back version until which deprecated features are still supported.
var BaseContext = Context{*apd.BaseContext.WithPrecision(34)}
BaseContext is used as CUE's default context for arbitrary-precision decimals.
ErrIncomplete can be used by builtins to signal the evaluation was incomplete.
Functions ¶
func ConstraintToken ¶
ConstraintToken reports which constraint token (? or !) is associated with a field (if any), taking into account compatibility of deprecated fields.
func EmbedStruct ¶
func FileComments ¶
func FileComments(f *ast.File) (docs, rest []*ast.CommentGroup)
func GenPath ¶
GenPath reports the directory in which to store generated files.
func IsDef ¶
func IsDefOrHidden ¶
func IsDefinition ¶
func IsEllipsis ¶
IsEllipsis reports whether the declaration can be represented as an ellipsis.
func IsHidden ¶
func IsRegularField ¶
func ListEllipsis ¶
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 MergeDocs ¶
func MergeDocs(comments []*ast.CommentGroup) []*ast.CommentGroup
MergeDocs merges multiple doc comments into one single doc comment.
func NewAttr ¶
func NewComment ¶
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 Package ¶
Package finds the package declaration from the preamble of a file.
func SetConstraint ¶
SetConstraints sets both the main and deprecated fields of f according to the given constraint token.
func SetPackage ¶
func ToExpr ¶
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 ¶
ToFile converts an expression to a file.
Adjusts the spacing of x when needed.
func Version ¶
Types ¶
type Attr ¶
type Attr struct { Name string // e.g. "json" or "protobuf" Body string Kind AttrKind Fields []KeyValue Err errors.Error Pos token.Pos }
Attr holds positional information for a single Attr.
func NewNonExisting ¶
NewNonExisting creates a non-existing attribute.
func ParseAttrBody ¶
func (*Attr) Flag ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
func (Context) Sqrt ¶
func (Context) WithPrecision ¶
WithPrecision mirrors upstream, but returning our type without a pointer.
type Decimal ¶
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 ¶
type EvaluatorVersion int
EvaluatorVersion is declared here so it can be used everywhere without import cycles, but the canonical documentation lives at cuelang.org/go/cue/cuecontext.EvalVersion.
TODO(mvdan): rename to EvalVersion for consistency with cuecontext.
const ( // EvalVersionUnset is the zero value, which signals that no evaluator version is provided. EvalVersionUnset EvaluatorVersion = 0 EvalV2 EvaluatorVersion = 2 EvalV3 EvaluatorVersion = 3 DefaultVersion = EvalV2 // TODO(mvdan): rename to EvalDefault for consistency with cuecontext DevVersion = EvalV3 // TODO(mvdan): rename to EvalExperiment for consistency with cuecontext )
type KeyValue ¶
type KeyValue struct {
// contains filtered or unexported fields
}
func (*KeyValue) Key ¶
func (*KeyValue) Text ¶
func (*KeyValue) Value ¶
Source Files ¶
attrs.go internal.go
Directories ¶
Path | Synopsis |
---|---|
internal/astinternal | |
internal/buildattr | Package buildattr implements support for interpreting the @if build attributes in CUE files. |
internal/ci | |
internal/ci/checks | |
internal/cli | |
internal/cmd | |
internal/cmd/cue-ast | cue-ast-print parses a CUE file and prints its syntax tree, for example: |
internal/copy | Package copy provides utilities to copy files and directories. |
internal/core | |
internal/core/adt | Package adt represents partially and fully evaluated CUE types. |
internal/core/compile | |
internal/core/convert | Package convert allows converting to and from Go values and Types. |
internal/core/debug | Package debug prints a given ADT node. |
internal/core/dep | Package dep analyzes dependencies between values. |
internal/core/eval | |
internal/core/export | |
internal/core/path | Package path provides utilities for converting cue.Selectors and cue.Paths to internal equivalents. |
internal/core/runtime | |
internal/core/subsume | Package subsume defines various subsumption relations. |
internal/core/toposort | |
internal/core/validate | Package validate collects errors from an evaluated Vertex. |
internal/core/walk | walk provides functions for visiting the nodes of an ADT tree. |
internal/cueconfig | Package cueconfig holds internal API relating to CUE configuration. |
internal/cuedebug | |
internal/cueexperiment | |
internal/cueimports | Package cueimports provides support for reading the import section of a CUE file without needing to read the rest of it. |
internal/cuetdtest | Package testing is a helper package for test packages in the CUE project. |
internal/cuetest | Package testing is a helper package for test packages in the CUE project. |
internal/cuetxtar | |
internal/cueversion | Package cueversion provides access to the version of the cuelang.org/go module. |
internal/diff | |
internal/_e2e | |
internal/encoding | |
internal/encoding/gotypes | |
internal/encoding/json | |
internal/encoding/yaml | |
internal/envflag | |
internal/filetypes | |
internal/golangorgx | |
internal/golangorgx/gopls | |
internal/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. |
internal/golangorgx/gopls/cache/metadata | The metadata package defines types and functions for working with package metadata, which describes Go packages and their relationships. |
internal/golangorgx/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. |
internal/golangorgx/gopls/cache/parsego | |
internal/golangorgx/gopls/cache/typerefs | Package typerefs extracts symbol-level reachability information from the syntax of a Go package. |
internal/golangorgx/gopls/cache/xrefs | Package xrefs defines the serializable index of cross-package references that is computed during type checking. |
internal/golangorgx/gopls/cmd | Package cmd handles the gopls command line. |
internal/golangorgx/gopls/cuelang | Package golang defines the LSP features for navigation, analysis, and refactoring of Go source code. |
internal/golangorgx/gopls/debug | Package debug exports debug information for gopls. |
internal/golangorgx/gopls/debug/log | Package log provides helper methods for exporting log events to the internal/event package. |
internal/golangorgx/gopls/file | The file package defines types used for working with LSP files. |
internal/golangorgx/gopls/filecache | The filecache package provides a file-based shared durable blob cache. |
internal/golangorgx/gopls/hooks | Package hooks adds all the standard gopls implementations. |
internal/golangorgx/gopls/lsprpc | Package lsprpc implements a jsonrpc2.StreamServer that may be used to serve the LSP on a jsonrpc2 channel. |
internal/golangorgx/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. |
internal/golangorgx/gopls/protocol | Package protocol contains the structs that map directly to the request and response messages of the Language Server Protocol. |
internal/golangorgx/gopls/protocol/command | Package command defines the interface provided by gopls for the workspace/executeCommand LSP request. |
internal/golangorgx/gopls/protocol/semtok | The semtok package provides an encoder for LSP's semantic tokens. |
internal/golangorgx/gopls/server | Package server defines gopls' implementation of the LSP server interface, protocol.Server. |
internal/golangorgx/gopls/settings | |
internal/golangorgx/gopls/telemetry | |
internal/golangorgx/gopls/test | |
internal/golangorgx/gopls/test/integration | Package integration provides a framework for writing integration tests of gopls. |
internal/golangorgx/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. |
internal/golangorgx/gopls/test/integration/fake/glob | Package glob implements an LSP-compliant glob pattern matcher for testing. |
internal/golangorgx/gopls/util | |
internal/golangorgx/gopls/util/astutil | Package astutil provides various AST utility functions for gopls. |
internal/golangorgx/gopls/util/browser | Package browser provides utilities for interacting with users' browsers. |
internal/golangorgx/gopls/util/bug | Package bug provides utilities for reporting internal bugs, and being notified when they occur. |
internal/golangorgx/gopls/util/constraints | Package constraints defines a set of useful constraints to be used with type parameters. |
internal/golangorgx/gopls/util/frob | Package frob is a fast restricted object encoder/decoder in the spirit of encoding/gob. |
internal/golangorgx/gopls/util/immutable | The immutable package defines immutable wrappers around common data structures. |
internal/golangorgx/gopls/util/lru | The lru package implements a fixed-size in-memory LRU cache. |
internal/golangorgx/gopls/util/maps | |
internal/golangorgx/gopls/util/pathutil | |
internal/golangorgx/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. |
internal/golangorgx/gopls/util/safetoken | Package safetoken provides wrappers around methods in go/token, that return errors rather than panicking. |
internal/golangorgx/gopls/util/slices | |
internal/golangorgx/gopls/util/typesutil | |
internal/golangorgx/gopls/version | Package version manages the gopls version. |
internal/golangorgx/telemetry | |
internal/golangorgx/telemetry/counter | Package counter implements a simple counter system for collecting totally public telemetry data. |
internal/golangorgx/telemetry/crashmonitor | |
internal/golangorgx/telemetry/internal | |
internal/golangorgx/telemetry/internal/config | package config provides methods for loading and querying a telemetry upload config file. |
internal/golangorgx/telemetry/internal/configstore | Package configstore abstracts interaction with the telemetry config server. |
internal/golangorgx/telemetry/internal/counter | Package internal/counter implements the internals of the public counter package. |
internal/golangorgx/telemetry/internal/mmap | The mmap package provides an abstraction for memory mapping files on different platforms. |
internal/golangorgx/telemetry/internal/telemetry | Package telemetry manages the telemetry mode file. |
internal/golangorgx/telemetry/internal/upload | |
internal/golangorgx/telemetry/upload | |
internal/golangorgx/tools | |
internal/golangorgx/tools/aliases | |
internal/golangorgx/tools/analysisinternal | Package analysisinternal provides gopls' internal analyses with a number of helper functions that operate on typed syntax trees. |
internal/golangorgx/tools/astutil | |
internal/golangorgx/tools/diff | Package diff computes differences between text files or strings. |
internal/golangorgx/tools/diff/lcs | package lcs contains code to find longest-common-subsequences (and diffs) |
internal/golangorgx/tools/event | Package event provides a set of packages that cover the main concepts of telemetry in an implementation agnostic way. |
internal/golangorgx/tools/event/core | Package core provides support for event based telemetry. |
internal/golangorgx/tools/event/export | |
internal/golangorgx/tools/event/export/metric | Package metric aggregates events into metrics that can be exported. |
internal/golangorgx/tools/event/export/ocagent | Package ocagent adds the ability to export all telemetry to an ocagent. |
internal/golangorgx/tools/event/export/ocagent/wire | |
internal/golangorgx/tools/event/export/prometheus | |
internal/golangorgx/tools/event/keys | |
internal/golangorgx/tools/event/label | |
internal/golangorgx/tools/event/tag | Package tag provides the labels used for telemetry throughout gopls. |
internal/golangorgx/tools/facts | Package facts defines a serializable set of analysis.Fact. |
internal/golangorgx/tools/fakenet | |
internal/golangorgx/tools/fuzzy | Package fuzzy implements a fuzzy matching algorithm. |
internal/golangorgx/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. |
internal/golangorgx/tools/gocommand | Package gocommand is a helper for calling the go command. |
internal/golangorgx/tools/gopathwalk | Package gopathwalk is like filepath.Walk but specialized for finding Go packages, particularly in $GOPATH and $GOROOT. |
internal/golangorgx/tools/goroot | Package goroot is a copy of package internal/goroot in the main GO repot. |
internal/golangorgx/tools/imports | Package imports implements a Go pretty-printer (like package "go/format") that also adds or removes import statements as necessary. |
internal/golangorgx/tools/jsonrpc2 | Package jsonrpc2 is a minimal implementation of the JSON RPC 2 spec. |
internal/golangorgx/tools/jsonrpc2/servertest | Package servertest provides utilities for running tests against a remote LSP server. |
internal/golangorgx/tools/jsonrpc2_v2 | Package jsonrpc2 is a minimal implementation of the JSON RPC 2 spec. |
internal/golangorgx/tools/memoize | Package memoize defines a "promise" abstraction that enables memoization of the result of calling an expensive but idempotent function. |
internal/golangorgx/tools/packagesinternal | Package packagesinternal exposes internal-only fields from go/packages. |
internal/golangorgx/tools/pkgbits | Package pkgbits implements low-level coding abstractions for Unified IR's export data format. |
internal/golangorgx/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>". |
internal/golangorgx/tools/refactor | |
internal/golangorgx/tools/refactor/inline | Package inline implements inlining of Go function calls. |
internal/golangorgx/tools/robustio | Package robustio wraps I/O functions that are prone to failure on Windows, transparently retrying errors up to an arbitrary timeout. |
internal/golangorgx/tools/testenv | Package testenv contains helper functions for skipping tests based on which tools are present in the environment. |
internal/golangorgx/tools/tokeninternal | package tokeninternal provides access to some internal features of the token package. |
internal/golangorgx/tools/tool | Package tool is a harness for writing Go tools. |
internal/golangorgx/tools/typeparams | Package typeparams contains common utilities for writing tools that interact with generic Go code, as introduced with Go 1.18. |
internal/golangorgx/tools/typesinternal | Package typesinternal provides access to internal go/types APIs that are not yet exported. |
internal/golangorgx/tools/versions | |
internal/golangorgx/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. |
internal/httplog | |
internal/mod | |
internal/mod/modimports | |
internal/mod/modload | |
internal/mod/modpkgload | |
internal/mod/modrequirements | |
internal/mod/modresolve | |
internal/mod/mvs | Package mvs implements Minimal Version Selection. |
internal/mod/semver | Package semver implements comparison of semantic version strings. |
internal/par | Package par implements parallel execution helpers. |
internal/pkg | |
internal/registrytest | |
internal/source | Package source contains utility functions that standardize reading source bytes across cue packages. |
internal/task | Package task provides a registry for tasks to be used by commands. |
internal/tdtest | Package tdtest provides support for table-driven testing. |
internal/types | |
internal/value | Package value contains functions for converting values to internal types and various other Value-related utilities. |
internal/vcs | Package vcs provides access to operations on the version control systems supported by the source field in module.cue. |
- Version
- v0.12.0 (latest)
- Published
- Jan 30, 2025
- Platform
- linux/amd64
- Imports
- 12 packages
- Last checked
- 5 hours ago –
Tools for package owners.