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#70: multi comment in rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernest Micklei committed Mar 13, 2018
1 parent 7abc7dc commit c43723a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
15 changes: 7 additions & 8 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,14 @@ func (r *RPC) parse(p *Parser) error {
maybeScanInlineComment(p, r)
continue
}
if tOPTION != tok {
return p.unexpected(lit, "rpc option", r)
}
o := new(Option)
o.Position = pos
if err := o.parse(p); err != nil {
return err
if tOPTION == tok {
o := new(Option)
o.Position = pos
if err := o.parse(p); err != nil {
return err
}
r.addElement(o)
}
r.addElement(o)
}
}
return nil
Expand Down
12 changes: 10 additions & 2 deletions service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,23 @@ func TestRPCWithOneLineCommentInOptionBlock(t *testing.T) {
}

func TestRPCWithMultiLineCommentInOptionBlock(t *testing.T) {
t.Skip("this fails")
proto := `service AccountService {
rpc CreateAccount (CreateAccount) returns (ServiceFault) {
// test comment
// test comment
}
}`
_, err := newParserOn(proto).Parse()
def, err := newParserOn(proto).Parse()
if err != nil {
t.Fatal(err)
}
s := def.Elements[0].(*Service)
r := s.Elements[0].(*RPC)
if got, want := len(r.Elements), 1; got != want {
t.Errorf("got [%v] want [%v]", got, want)
}
c := r.Elements[0].(*Comment)
if got, want := len(c.Lines), 2; got != want {
t.Errorf("got [%v] want [%v]", got, want)
}
}

0 comments on commit c43723a

Please sign in to comment.