compiler/protogen, internal/strs, internal/impl: expose enum Go name derivation

In order to migrate v1 to wrap v2, we need a way to reproduce
the awful enum "names" that v1 used, which was the concatenation of
the proto package with the Go identifier used for the enum.

To support this:
* Move the camel case logic from compiler/protogen to internal/strs
* Add a small stub in internal/impl to expose this functionality

Change-Id: I8ff31daa9ae541e5788dc04d2e89eae1574877e4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/191637
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/impl/legacy_extension.go b/internal/impl/legacy_extension.go
index b484067..ec5420d 100644
--- a/internal/impl/legacy_extension.go
+++ b/internal/impl/legacy_extension.go
@@ -77,31 +77,10 @@
 		}
 	}
 
-	// Reconstruct the legacy enum full name, which is an odd mixture of the
-	// proto package name with the Go type name.
+	// Reconstruct the legacy enum full name.
 	var enumName string
 	if xd.Kind() == pref.EnumKind {
-		// Derive Go type name.
-		t := extType
-		if t.Kind() == reflect.Ptr || t.Kind() == reflect.Slice {
-			t = t.Elem()
-		}
-		enumName = t.Name()
-
-		// Derive the proto package name.
-		// For legacy enums, obtain the proto package from the raw descriptor.
-		var protoPkg string
-		if fd := xd.Enum().ParentFile(); fd != nil {
-			protoPkg = string(fd.Package())
-		}
-		if ed, ok := reflect.Zero(t).Interface().(enumV1); ok && protoPkg == "" {
-			b, _ := ed.EnumDescriptor()
-			protoPkg = string(legacyLoadFileDesc(b).Package())
-		}
-
-		if protoPkg != "" {
-			enumName = protoPkg + "." + enumName
-		}
+		enumName = legacyEnumName(xd.Enum())
 	}
 
 	// Derive the proto file that the extension was declared within.