kvexpression.go 932 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package ast
  2. import "github.com/zeromicro/go-zero/tools/goctl/pkg/parser/api/token"
  3. // KVExpr is a key value expression.
  4. type KVExpr struct {
  5. // Key is the key of the key value expression.
  6. Key *TokenNode
  7. // Value is the value of the key value expression.
  8. Value *TokenNode
  9. }
  10. func (i *KVExpr) HasHeadCommentGroup() bool {
  11. return i.Key.HasHeadCommentGroup()
  12. }
  13. func (i *KVExpr) HasLeadingCommentGroup() bool {
  14. return i.Value.HasLeadingCommentGroup()
  15. }
  16. func (i *KVExpr) CommentGroup() (head, leading CommentGroup) {
  17. return i.Key.HeadCommentGroup, i.Value.LeadingCommentGroup
  18. }
  19. func (i *KVExpr) Format(prefix ...string) string {
  20. w := NewBufferWriter()
  21. w.Write(withNode(i.Key, i.Value), withPrefix(prefix...), withInfix(Indent), withRawText())
  22. return w.String()
  23. }
  24. func (i *KVExpr) End() token.Position {
  25. return i.Value.End()
  26. }
  27. func (i *KVExpr) Pos() token.Position {
  28. return i.Key.Pos()
  29. }
  30. func (i *KVExpr) exprNode() {}