mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-07 23:20:00 +08:00
fix syntax of the key expression (#4586)
This commit is contained in:
@@ -46,7 +46,8 @@ func (i *InfoStmt) Format(prefix ...string) string {
|
||||
w.Write(withNode(infoNode, i.LParen))
|
||||
w.NewLine()
|
||||
for _, v := range i.Values {
|
||||
node := transferTokenNode(v.Key, withTokenNodePrefix(peekOne(prefix)+Indent), ignoreLeadingComment())
|
||||
node := transferNilInfixNode([]*TokenNode{v.Key, v.Colon})
|
||||
node = transferTokenNode(node, withTokenNodePrefix(peekOne(prefix)+Indent), ignoreLeadingComment())
|
||||
w.Write(withNode(node, v.Value), expectIndentInfix(), expectSameLine())
|
||||
w.NewLine()
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import "github.com/zeromicro/go-zero/tools/goctl/pkg/parser/api/token"
|
||||
type KVExpr struct {
|
||||
// Key is the key of the key value expression.
|
||||
Key *TokenNode
|
||||
// Colon is the colon of the key value expression.
|
||||
Colon *TokenNode
|
||||
// Value is the value of the key value expression.
|
||||
Value *TokenNode
|
||||
}
|
||||
@@ -24,7 +26,8 @@ func (i *KVExpr) CommentGroup() (head, leading CommentGroup) {
|
||||
|
||||
func (i *KVExpr) Format(prefix ...string) string {
|
||||
w := NewBufferWriter()
|
||||
w.Write(withNode(i.Key, i.Value), withPrefix(prefix...), withInfix(Indent), withRawText())
|
||||
node := transferNilInfixNode([]*TokenNode{i.Key, i.Colon})
|
||||
w.Write(withNode(node, i.Value), withPrefix(prefix...), withInfix(Indent), withRawText())
|
||||
return w.String()
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,8 @@ func (a *AtServerStmt) Format(prefix ...string) string {
|
||||
w.Write(withNode(atServerNode, a.LParen), expectSameLine())
|
||||
w.NewLine()
|
||||
for _, v := range a.Values {
|
||||
node := transferTokenNode(v.Key, withTokenNodePrefix(peekOne(prefix)+Indent), ignoreLeadingComment())
|
||||
node := transferNilInfixNode([]*TokenNode{v.Key, v.Colon})
|
||||
node = transferTokenNode(node, withTokenNodePrefix(peekOne(prefix)+Indent), ignoreLeadingComment())
|
||||
w.Write(withNode(node, v.Value), expectIndentInfix(), expectSameLine())
|
||||
w.NewLine()
|
||||
}
|
||||
@@ -148,7 +149,8 @@ func (a *AtDocGroupStmt) Format(prefix ...string) string {
|
||||
w.Write(withNode(atDocNode, a.LParen), expectSameLine())
|
||||
w.NewLine()
|
||||
for _, v := range a.Values {
|
||||
node := transferTokenNode(v.Key, withTokenNodePrefix(peekOne(prefix)+Indent), ignoreLeadingComment())
|
||||
node := transferNilInfixNode([]*TokenNode{v.Key, v.Colon})
|
||||
node = transferTokenNode(node, withTokenNodePrefix(peekOne(prefix)+Indent), ignoreLeadingComment())
|
||||
w.Write(withNode(node, v.Value), expectIndentInfix(), expectSameLine())
|
||||
w.NewLine()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user