Movatterモバイル変換


[0]ホーム

URL:


common

package
v0.26.1Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License:Apache-2.0, BSD-3-ClauseImports:7Imported by:71

Details

Repository

github.com/google/cel-go

Links

Documentation

Overview

Package common defines types and utilities common to expression parsing,checking, and interpretation

Index

Constants

View Source
const (// SelectAndIdentCost is the cost of an operation that accesses an identifier or performs a select.SelectAndIdentCost = 1// ConstCost is the cost of an operation that accesses a constant.ConstCost = 0// ListCreateBaseCost is the base cost of any operation that creates a new list.ListCreateBaseCost = 10// MapCreateBaseCost is the base cost of any operation that creates a new map.MapCreateBaseCost = 30// StructCreateBaseCost is the base cost of any operation that creates a new struct.StructCreateBaseCost = 40// StringTraversalCostFactor is multiplied to a length of a string when computing the cost of traversing the entire// string once.StringTraversalCostFactor = 0.1// RegexStringLengthCostFactor is multiplied ot the length of a regex string pattern when computing the cost of// applying the regex to a string of unit cost.RegexStringLengthCostFactor = 0.25)

Variables

View Source
var (// NoLocation is a particular illegal location.NoLocation = &SourceLocation{-1, -1})

Functions

funcMultilineDescriptionadded inv0.25.0

func MultilineDescription(lines ...string)string

MultilineDescription combines multiple lines into a newline separated string.

funcParseDescriptionadded inv0.25.0

func ParseDescription(docstring)string

ParseDescription takes a single string containing newline characters and splitsit into a multiline description. All empty lines will be skipped.

Returns an empty string if the input string is empty.

funcParseDescriptionsadded inv0.25.0

func ParseDescriptions(docstring) []string

ParseDescriptions splits a documentation string into multiple multi-line descriptionsections, using blank lines as delimiters.

Types

typeDocadded inv0.25.0

type Doc struct {// Kind specifies the type of documentation element (e.g., Function, Variable).KindDocKind// Name is the identifier of the documented element (e.g., function name, variable name).Namestring// Type is the data type associated with the element, primarily used for variables.Typestring// Signature represents the function or overload signature.Signaturestring// Description holds the textual description of the element, potentially spanning multiple lines.Descriptionstring// Children holds nested documentation elements, such as overloads for a function// or examples for a function/macro.Children []*Doc}

Doc holds the documentation details for a specific program element likea variable, function, macro, or example.

funcNewExampleDocadded inv0.25.0

func NewExampleDoc(exstring) *Doc

NewExampleDoc creates a new Doc struct specifically for holding an example.

funcNewFunctionDocadded inv0.25.0

func NewFunctionDoc(name, descriptionstring, overloads ...*Doc) *Doc

NewFunctionDoc creates a new Doc struct for documenting a function.

funcNewMacroDocadded inv0.25.0

func NewMacroDoc(name, descriptionstring, examples ...*Doc) *Doc

NewMacroDoc creates a new Doc struct for documenting a macro.

funcNewOverloadDocadded inv0.25.0

func NewOverloadDoc(id, signaturestring, examples ...*Doc) *Doc

NewOverloadDoc creates a new Doc struct for a function example.

funcNewVariableDocadded inv0.25.0

func NewVariableDoc(name, celType, descriptionstring) *Doc

NewVariableDoc creates a new Doc struct specifically for documenting a variable.

typeDocKindadded inv0.25.0

type DocKindint

DocKind indicates the type of documentation element.

const (// DocEnv represents environment variable documentation.DocEnvDocKind =iota + 1// DocFunction represents function documentation.DocFunction// DocOverload represents function overload documentation.DocOverload// DocVariable represents variable documentation.DocVariable// DocMacro represents macro documentation.DocMacro// DocExample represents example documentation.DocExample)

typeDocumentoradded inv0.25.0

type Documentor interface {// Documentation returns the documentation coded by the DocKind to assist// with text formatting.Documentation() *Doc}

Documentor is an interface for types that can provide their own documentation.

typeError

type Error struct {LocationLocationMessagestringExprIDint64}

Error type which references an expression id, a location within source, and a message.

funcNewErroradded inv0.17.0

func NewError(idint64, messagestring, locationLocation) *Error

NewError creates an error associated with an expression id with the given message at the given location.

func (*Error)ToDisplayString

func (e *Error) ToDisplayString(sourceSource)string

ToDisplayString decorates the error message with the source location.

typeErrors

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

Errors type which contains a list of errors observed during parsing.

funcNewErrors

func NewErrors(sourceSource) *Errors

NewErrors creates a new instance of the Errors type.

func (*Errors)Appendadded inv0.4.0

func (e *Errors) Append(errs []*Error) *Errors

Append creates a new Errors object with the current and input errors.

func (*Errors)GetErrors

func (e *Errors) GetErrors() []*Error

GetErrors returns the list of observed errors.

func (*Errors)ReportError

func (e *Errors) ReportError(lLocation, formatstring, args ...any)

ReportError records an error at a source location.

func (*Errors)ReportErrorAtIDadded inv0.17.0

func (e *Errors) ReportErrorAtID(idint64, lLocation, formatstring, args ...any)

ReportErrorAtID records an error at a source location and expression id.

func (*Errors)ReportErrorStringadded inv0.23.0

func (e *Errors) ReportErrorString(lLocation, messagestring)

ReportErrorString records an error at a source location.

func (*Errors)ToDisplayString

func (e *Errors) ToDisplayString()string

ToDisplayString returns the error set to a newline delimited string.

typeLocation

type Location interface {Line()int// 1-based line number within source.Column()int// 0-based column number within source.}

Location interface to represent a location within Source.

funcNewLocation

func NewLocation(line, columnint)Location

NewLocation creates a new location.

typeSource

type Source interface {// Content returns the source content represented as a string.// Examples contents are the single file contents, textbox field,// or url parameter.Content()string// Description gives a brief description of the source.// Example descriptions are a file name or ui element.Description()string// LineOffsets gives the character offsets at which lines occur.// The zero-th entry should refer to the break between the first// and second line, or EOF if there is only one line of source.LineOffsets() []int32// LocationOffset translates a Location to an offset.// Given the line and column of the Location returns the// Location's character offset in the Source, and a bool// indicating whether the Location was found.LocationOffset(locationLocation) (int32,bool)// OffsetLocation translates a character offset to a Location, or// false if the conversion was not feasible.OffsetLocation(offsetint32) (Location,bool)// NewLocation takes an input line and column and produces a Location.// The default behavior is to treat the line and column as absolute,// but concrete derivations may use this method to convert a relative// line and column position into an absolute location.NewLocation(line, colint)Location// Snippet returns a line of content and whether the line was found.Snippet(lineint) (string,bool)}

Source interface for filter source contents.

funcNewInfoSource

func NewInfoSource(info *exprpb.SourceInfo)Source

NewInfoSource creates a new Source from a SourceInfo.

funcNewStringSource

func NewStringSource(contentsstring, descriptionstring)Source

NewStringSource creates a new Source from the given contents and description.

funcNewTextSource

func NewTextSource(textstring)Source

NewTextSource creates a new Source from the input text string.

typeSourceLocation

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

SourceLocation helper type to manually construct a location.

func (*SourceLocation)Column

func (l *SourceLocation) Column()int

Column returns the 0-based column number of the location.

func (*SourceLocation)Line

func (l *SourceLocation) Line()int

Line returns the 1-based line of the location.

Source Files

View all Source files

Directories

PathSynopsis
Package ast declares data structures useful for parsed and checked abstract syntax trees
Package ast declares data structures useful for parsed and checked abstract syntax trees
Package containers defines types and functions for resolving qualified names within a namespace or type provided to CEL.
Package containers defines types and functions for resolving qualified names within a namespace or type provided to CEL.
Package debug provides tools to print a parsed expression graph and adorn each expression element with additional metadata.
Package debug provides tools to print a parsed expression graph and adorn each expression element with additional metadata.
Package decls contains function and variable declaration structs and helper methods.
Package decls contains function and variable declaration structs and helper methods.
Package env provides a representation of a CEL environment.
Package env provides a representation of a CEL environment.
Package functions defines the standard builtin functions supported by the interpreter
Package functions defines the standard builtin functions supported by the interpreter
Package operators defines the internal function names of operators.
Package operators defines the internal function names of operators.
Package overloads defines the internal overload identifiers for function and operator overloads.
Package overloads defines the internal overload identifiers for function and operator overloads.
Package runes provides interfaces and utilities for working with runes.
Package runes provides interfaces and utilities for working with runes.
Package stdlib contains all of the standard library function declarations and definitions for CEL.
Package stdlib contains all of the standard library function declarations and definitions for CEL.
Package types contains the types, traits, and utilities common to all components of expression handling.
Package types contains the types, traits, and utilities common to all components of expression handling.
pb
Package pb reflects over protocol buffer descriptors to generate objects that simplify type, enum, and field lookup.
Package pb reflects over protocol buffer descriptors to generate objects that simplify type, enum, and field lookup.
ref
Package ref contains the reference interfaces used throughout the types components.
Package ref contains the reference interfaces used throughout the types components.
traits
Package traits defines interfaces that a type may implement to participate in operator overloads and function dispatch.
Package traits defines interfaces that a type may implement to participate in operator overloads and function dispatch.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp