From 310f2d5b158c5ed294f13a93407558cde79c53af Mon Sep 17 00:00:00 2001 From: Tristan Swadell Date: Wed, 6 Jul 2022 14:06:51 -0700 Subject: [PATCH] Lint fixes for various doc comments --- cel/decls.go | 2 +- cel/env.go | 4 ++++ cel/macro.go | 6 +++++- parser/macro.go | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cel/decls.go b/cel/decls.go index 4349d7ec..415674fa 100644 --- a/cel/decls.go +++ b/cel/decls.go @@ -165,7 +165,7 @@ type Type struct { isAssignableRuntimeType func(other ref.Type) bool } -// IsAssignableFrom determines whether the current type is type-check assignable from the input fromType. +// IsAssignableType determines whether the current type is type-check assignable from the input fromType. func (t *Type) IsAssignableType(fromType *Type) bool { if t.isAssignableType != nil { return t.isAssignableType(fromType) diff --git a/cel/env.go b/cel/env.go index f037405a..f2c40c0e 100644 --- a/cel/env.go +++ b/cel/env.go @@ -61,6 +61,8 @@ func (ast *Ast) SourceInfo() *exprpb.SourceInfo { // ResultType returns the output type of the expression if the Ast has been type-checked, else // returns decls.Dyn as the parse step cannot infer the type. +// +// Deprecated: use OutputType func (ast *Ast) ResultType() *exprpb.Type { if !ast.IsChecked() { return decls.Dyn @@ -68,6 +70,8 @@ func (ast *Ast) ResultType() *exprpb.Type { return ast.typeMap[ast.expr.GetId()] } +// OutputType returns the output type of the expression if the Ast has been type-checked, else +// returns cel.DynType as the parse step cannot infer types. func (ast *Ast) OutputType() *Type { t, err := ExprTypeToType(ast.ResultType()) if err != nil { diff --git a/cel/macro.go b/cel/macro.go index d0bfa489..e43cb4ee 100644 --- a/cel/macro.go +++ b/cel/macro.go @@ -20,6 +20,10 @@ import ( exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" ) +// Macro describes a function signature to match and the MacroExpander to apply. +// +// Note: when a Macro should apply to multiple overloads (based on arg count) of a given function, +// a Macro should be created per arg-count or as a var arg macro. type Macro = parser.Macro // MacroExpander converts a call and its associated arguments into a new CEL abstract syntax tree, or an error @@ -85,7 +89,7 @@ func MapMacroExpander(meh MacroExprHelper, target *exprpb.Expr, args []*exprpb.E return parser.MakeMap(meh, target, args) } -// MakeFilter expands the input call arguments into a comprehension which produces a list which contains +// FilterMacroExpander expands the input call arguments into a comprehension which produces a list which contains // only elements which match the provided predicate expression: // .filter(, ) func FilterMacroExpander(meh MacroExprHelper, target *exprpb.Expr, args []*exprpb.Expr) (*exprpb.Expr, *common.Error) { diff --git a/parser/macro.go b/parser/macro.go index 7d022218..9150b064 100644 --- a/parser/macro.go +++ b/parser/macro.go @@ -284,7 +284,7 @@ const ( quantifierExistsOne ) -// MakeExists expands the input call arguments into a comprehension that returns true if all of the +// MakeAll expands the input call arguments into a comprehension that returns true if all of the // elements in the range match the predicate expressions: // .all(, ) func MakeAll(eh ExprHelper, target *exprpb.Expr, args []*exprpb.Expr) (*exprpb.Expr, *common.Error) {