github.com/octohelm/cuemod@v0.9.4/pkg/cueify/golang/astutil.go (about)

     1  package golang
     2  
     3  import (
     4  	"strconv"
     5  
     6  	cueast "cuelang.org/go/cue/ast"
     7  	cuetoken "cuelang.org/go/cue/token"
     8  )
     9  
    10  func newInt(i int) *cueast.BasicLit {
    11  	return cueast.NewLit(cuetoken.INT, strconv.Itoa(i))
    12  }
    13  
    14  func oneOf(types ...cueast.Expr) cueast.Expr {
    15  	return cueast.NewBinExpr(cuetoken.OR, types...)
    16  }
    17  
    18  func allOf(types ...cueast.Expr) cueast.Expr {
    19  	return cueast.NewBinExpr(cuetoken.AND, types...)
    20  }
    21  
    22  func any() *cueast.Ident {
    23  	return cueast.NewIdent("_")
    24  }
    25  
    26  func addComments(node cueast.Node, comments ...*cueast.CommentGroup) {
    27  	for i := range comments {
    28  		cg := comments[i]
    29  		if cg == nil {
    30  			continue
    31  		}
    32  		cueast.AddComment(node, comments[i])
    33  	}
    34  }