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

Commit

Permalink
put back ValueOption field in Enum and mark it deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernest Micklei committed Jan 4, 2018
1 parent b9faf51 commit 8512541
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 8 additions & 4 deletions enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ done:

// EnumField is part of the body of an Enum.
type EnumField struct {
Position scanner.Position
Comment *Comment
Name string
Integer int
Position scanner.Position
Comment *Comment
Name string
Integer int
// ValueOption is deprecated, use Elements instead
ValueOption *Option
Elements []Visitee // such as Option and Comment
InlineComment *Comment
}
Expand Down Expand Up @@ -165,6 +167,8 @@ func (f *EnumField) parse(p *Parser) error {
if err != nil {
return err
}
// update deprecated field with the last option found
f.ValueOption = o
f.Elements = append(f.Elements, o)
pos, tok, lit = p.next()
if tok == tCOMMA {
Expand Down
4 changes: 4 additions & 0 deletions enum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ enum EnumAllowingAlias {
if got, want := ef3opt.Name, "(custom_option)"; got != want {
t.Errorf("got [%v] want [%v]", got, want)
}
// test for deprecated field
if got, want := ef3opt, ef3.ValueOption; got != want {
t.Errorf("got [%v] want [%v]", got, want)
}
if got, want := ef3opt.Constant.Source, "hello world"; got != want {
t.Errorf("got [%v] want [%v]", got, want)
}
Expand Down

0 comments on commit 8512541

Please sign in to comment.