reflect/protodesc: split descriptor related functionality from prototype

In order to generate descriptor.proto, the generated code would want to depend
on the prototype package to construct the reflection data structures.
However, this is a problem since descriptor itself is one of the dependencies
for prototype. To break this dependency, we do the following:
* Avoid using concrete *descriptorpb.XOptions messages in the public API, and
instead just use protoreflect.ProtoMessage. We do lose some type safety here
as a result.
* Use protobuf reflection to interpret the Options message.
* Split out NewFileFromDescriptorProto into a separate protodesc package since
constructing protobuf reflection from the descriptor proto obviously depends
on the descriptor protos themselves.

As part of this CL, we check in a pre-generated version of descriptor and plugin
that supports protobuf reflection natively and switchover all usages of those
protos to the new definitions. These files were generated by protoc-gen-go
from CL/150074, but hand-modified to remove dependencies on the v1 proto runtime.

Change-Id: I81e03c42eeab480b03764e2fcbe1aae0e058fc57
Reviewed-on: https://go-review.googlesource.com/c/152020
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/protogen/protogen.go b/protogen/protogen.go
index 8951ca0..95a499f 100644
--- a/protogen/protogen.go
+++ b/protogen/protogen.go
@@ -28,13 +28,14 @@
 	"strings"
 
 	"github.com/golang/protobuf/proto"
-	descpb "github.com/golang/protobuf/protoc-gen-go/descriptor"
-	pluginpb "github.com/golang/protobuf/protoc-gen-go/plugin"
 	"github.com/golang/protobuf/v2/internal/scalar"
+	"github.com/golang/protobuf/v2/reflect/protodesc"
 	"github.com/golang/protobuf/v2/reflect/protoreflect"
 	"github.com/golang/protobuf/v2/reflect/protoregistry"
-	"github.com/golang/protobuf/v2/reflect/prototype"
 	"golang.org/x/tools/go/ast/astutil"
+
+	descriptorpb "github.com/golang/protobuf/v2/types/descriptor"
+	pluginpb "github.com/golang/protobuf/v2/types/plugin"
 )
 
 // Run executes a function as a protoc plugin.
@@ -376,7 +377,7 @@
 // A File describes a .proto source file.
 type File struct {
 	Desc  protoreflect.FileDescriptor
-	Proto *descpb.FileDescriptorProto
+	Proto *descriptorpb.FileDescriptorProto
 
 	GoPackageName GoPackageName // name of this file's Go package
 	GoImportPath  GoImportPath  // import path of this file's Go package
@@ -393,11 +394,11 @@
 	// of "dir/foo". Appending ".pb.go" produces an output file of "dir/foo.pb.go".
 	GeneratedFilenamePrefix string
 
-	sourceInfo map[pathKey][]*descpb.SourceCodeInfo_Location
+	sourceInfo map[pathKey][]*descriptorpb.SourceCodeInfo_Location
 }
 
-func newFile(gen *Plugin, p *descpb.FileDescriptorProto, packageName GoPackageName, importPath GoImportPath) (*File, error) {
-	desc, err := prototype.NewFileFromDescriptorProto(p, gen.fileReg)
+func newFile(gen *Plugin, p *descriptorpb.FileDescriptorProto, packageName GoPackageName, importPath GoImportPath) (*File, error) {
+	desc, err := protodesc.NewFile(p, gen.fileReg)
 	if err != nil {
 		return nil, fmt.Errorf("invalid FileDescriptorProto %q: %v", p.GetName(), err)
 	}
@@ -409,7 +410,7 @@
 		Proto:         p,
 		GoPackageName: packageName,
 		GoImportPath:  importPath,
-		sourceInfo:    make(map[pathKey][]*descpb.SourceCodeInfo_Location),
+		sourceInfo:    make(map[pathKey][]*descriptorpb.SourceCodeInfo_Location),
 	}
 
 	// Determine the prefix for generated Go files.
@@ -477,7 +478,7 @@
 // If there is no go_package, it returns ("", "").
 // If there's a simple name, it returns (pkg, "").
 // If the option implies an import path, it returns (pkg, impPath).
-func goPackageOption(d *descpb.FileDescriptorProto) (pkg GoPackageName, impPath GoImportPath) {
+func goPackageOption(d *descriptorpb.FileDescriptorProto) (pkg GoPackageName, impPath GoImportPath) {
 	opt := d.GetOptions().GetGoPackage()
 	if opt == "" {
 		return "", ""
@@ -988,13 +989,13 @@
 	if err != nil {
 		return "", err
 	}
-	info := &descpb.GeneratedCodeInfo{}
+	info := &descriptorpb.GeneratedCodeInfo{}
 
 	seenAnnotations := make(map[string]bool)
 	annotate := func(s string, ident *ast.Ident) {
 		seenAnnotations[s] = true
 		for _, loc := range g.annotations[s] {
-			info.Annotation = append(info.Annotation, &descpb.GeneratedCodeInfo_Annotation{
+			info.Annotation = append(info.Annotation, &descriptorpb.GeneratedCodeInfo_Annotation{
 				SourceFile: scalar.String(loc.SourceFile),
 				Path:       loc.Path,
 				Begin:      scalar.Int32(int32(fset.Position(ident.Pos()).Offset)),