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

Commit

Permalink
fix full ident with parenthesis formatting
Browse files Browse the repository at this point in the history
Change-Id: I16e078cbdae1aece7d77a808b9b3e9ba02177a9d
  • Loading branch information
emicklei committed Feb 7, 2017
1 parent 69c9f5f commit 838d00d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion enum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ enum EnumAllowingAlias {
if got, want := ef3.Integer, 2; got != want {
t.Errorf("got [%v] want [%v]", got, want)
}
if got, want := ef3.ValueOption.Name, "custom_option"; got != want {
if got, want := ef3.ValueOption.Name, "(custom_option)"; got != want {
t.Errorf("got [%v] want [%v]", got, want)
}
if got, want := ef3.ValueOption.Constant.Source, "hello world"; got != want {
Expand Down
6 changes: 1 addition & 5 deletions option.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package proto

import "fmt"
import "strings"

// Option is a protoc compiler option
type Option struct {
Expand Down Expand Up @@ -45,9 +44,6 @@ func (o *Option) columns() (cols []aligned) {
func (o *Option) keyValuePair(embedded bool) (cols []aligned) {
equals := alignedEquals
name := o.Name
if strings.Contains(name, ".") {
name = fmt.Sprintf("(%s)", name)
}
if embedded {
return append(cols, notAligned(name), equals, rightAligned(o.Constant.String()))
}
Expand All @@ -65,11 +61,11 @@ func (o *Option) parse(p *Parser) error {
return p.unexpected(lit, "option full identifier", o)
}
}
o.Name = lit
tok, _ = p.scanIgnoreWhitespace()
if tok != tRIGHTPAREN {
return p.unexpected(lit, "full identifier closing )", o)
}
o.Name = fmt.Sprintf("(%s)", lit)
} else {
// non full ident
if tIDENT != tok {
Expand Down
4 changes: 2 additions & 2 deletions option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ func TestOption(t *testing.T) {
strLit string
nonStrLit string
}{{
`option (full.java_package) = "com.example.foo";`,
"full.java_package",
`option (full).java_package = "com.example.foo";`,
"(full).java_package",
"com.example.foo",
"",
}, {
Expand Down

0 comments on commit 838d00d

Please sign in to comment.