Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

Commit

Permalink
fix issue emicklei#42 restoring deprecated RPC.Options
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernest Micklei committed Jan 19, 2018
1 parent 5a91db7 commit b22518e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion service.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ type RPC struct {
StreamsReturns bool
Elements []Visitee
InlineComment *Comment

// Options field is DEPRECATED, use Elements instead.
Options []*Option
}

// Accept dispatches the call to the visitor.
Expand Down Expand Up @@ -207,7 +210,7 @@ func (r *RPC) parse(p *Parser) error {
if err := o.parse(p); err != nil {
return err
}
r.Elements = append(r.Elements, o)
r.addElement(o)
}
}
return nil
Expand All @@ -216,6 +219,10 @@ func (r *RPC) parse(p *Parser) error {
// addElement is part of elementContainer
func (r *RPC) addElement(v Visitee) {
r.Elements = append(r.Elements, v)
// handle deprecated field
if option, ok := v.(*Option); ok {
r.Options = append(r.Options, option)
}
}

// elements is part of elementContainer
Expand Down
4 changes: 4 additions & 0 deletions service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,8 @@ func TestRPCWithOptionAggregateSyntax(t *testing.T) {
if got, want := opt.AggregatedConstants[1].Source, "test2"; got != want {
t.Errorf("got [%v] want [%v]", got, want)
}
// test deprecated field Options in RPC
if got, want := len(rpc1.Options), 1; got != want {
t.Errorf("got len Options %v want %v", got, want)
}
}

0 comments on commit b22518e

Please sign in to comment.