protogen: camel-case "Foo.bar" as "FooBar" instead of "Foo_Bar".
Given:
message Parent {
message Child1 {}
message child2 {}
}
Historic behavior is to generate child messages named:
Parent_Child1
ParentChild2
Avoid adding an _ in the latter case.
Change-Id: I49a6732655d64967b8c7bb7ad358ae54d294f7b4
Reviewed-on: https://go-review.googlesource.com/c/140898
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/protogen/names.go b/protogen/names.go
index 445613f..9da11d9 100644
--- a/protogen/names.go
+++ b/protogen/names.go
@@ -136,6 +136,8 @@
for ; i < len(s); i++ {
c := s[i]
switch {
+ case c == '.' && i+1 < len(s) && isASCIILower(s[i+1]):
+ // Skip over .<lowercase>, to match historic behavior.
case c == '.':
t = append(t, '_') // Convert . to _.
case c == '_' && (i == 0 || s[i-1] == '.'):