refactor goctl (#902)

master
Kevin Wan 3 years ago committed by GitHub
parent 0b0406f41a
commit 1fb356f328
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -197,7 +197,7 @@ func Disable() {
})
}
// DisableStat to disable stat logs
// DisableStat disables the stat logs.
func DisableStat() {
atomic.StoreUint32(&disableStat, 1)
}

@ -104,6 +104,7 @@ func (v *ApiVisitor) newExprWithTerminalNode(node antlr.TerminalNode) *defaultEx
if node == nil {
return nil
}
token := node.GetSymbol()
return v.newExprWithToken(token)
}
@ -132,6 +133,7 @@ func (v *ApiVisitor) newExprWithText(text string, line, column, start, stop int)
instance.column = column
instance.start = start
instance.stop = stop
return instance
}
@ -248,8 +250,7 @@ func EqualDoc(spec1, spec2 Spec) bool {
}
func (v *ApiVisitor) getDoc(t TokenStream) []Expr {
list := v.getHiddenTokensToLeft(t, api.COMEMNTS, false)
return list
return v.getHiddenTokensToLeft(t, api.COMEMNTS, false)
}
func (v *ApiVisitor) getComment(t TokenStream) Expr {
@ -273,11 +274,9 @@ func (v *ApiVisitor) getComment(t TokenStream) Expr {
func (v *ApiVisitor) getHiddenTokensToLeft(t TokenStream, channel int, containsCommentOfDefaultChannel bool) []Expr {
ct := t.GetParser().GetTokenStream().(*antlr.CommonTokenStream)
tokens := ct.GetHiddenTokensToLeft(t.GetStart().GetTokenIndex(), channel)
tmp := make([]antlr.Token, len(tokens))
copy(tmp, tokens)
var list []Expr
for _, each := range tmp {
for _, each := range tokens {
if !containsCommentOfDefaultChannel {
index := each.GetTokenIndex() - 1

@ -66,7 +66,6 @@ func (p parser) convert2Spec() error {
func (p parser) fillInfo() {
properties := make(map[string]string)
if p.ast.Info != nil {
p.spec.Info = spec.Info{}
for _, kv := range p.ast.Info.Kvs {
properties[kv.Key.Text()] = kv.Value.Text()
}

Loading…
Cancel
Save