dev
This commit is contained in:
@@ -13,7 +13,7 @@ type commentGenerator struct {
|
||||
descriptor protoreflect.Descriptor
|
||||
}
|
||||
|
||||
func (c commentGenerator) generateLeading(f *codegen.File, indent int) {
|
||||
func (c commentGenerator) generateLeading(f *codegen.File, indent int) string {
|
||||
loc := c.descriptor.ParentFile().SourceLocations().ByDescriptor(c.descriptor)
|
||||
var comments string
|
||||
if loc.TrailingComments != "" {
|
||||
@@ -34,6 +34,8 @@ func (c commentGenerator) generateLeading(f *codegen.File, indent int) {
|
||||
f.P(t(indent), "/** "+behaviorComment+" */")
|
||||
}
|
||||
}
|
||||
|
||||
return strings.TrimSpace(comments)
|
||||
}
|
||||
|
||||
func fieldBehaviorComment(field protoreflect.FieldDescriptor) string {
|
||||
|
||||
14
internal/plugin/const.go
Normal file
14
internal/plugin/const.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package plugin
|
||||
|
||||
var (
|
||||
AllSrvMethods []SrvMethod
|
||||
)
|
||||
|
||||
type SrvMethod struct {
|
||||
PkgName string
|
||||
ServiceName string
|
||||
MethodName string
|
||||
Comment string
|
||||
In string
|
||||
Out string
|
||||
}
|
||||
@@ -14,6 +14,8 @@ import (
|
||||
)
|
||||
|
||||
func Generate(request *pluginpb.CodeGeneratorRequest) (*pluginpb.CodeGeneratorResponse, error) {
|
||||
AllSrvMethods = make([]SrvMethod, 0)
|
||||
|
||||
generate := make(map[string]struct{})
|
||||
registry, err := protodesc.NewFiles(&descriptorpb.FileDescriptorSet{
|
||||
File: request.GetProtoFile(),
|
||||
@@ -46,7 +48,10 @@ func Generate(request *pluginpb.CodeGeneratorRequest) (*pluginpb.CodeGeneratorRe
|
||||
Name: proto.String(path.Join(indexPathElems...)),
|
||||
Content: proto.String(string(index.Content())),
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
res.SupportedFeatures = proto.Uint64(uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL))
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ func (p packageGenerator) Generate(f *codegen.File) error {
|
||||
walkErr = err
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
seenService = true
|
||||
}
|
||||
return true
|
||||
|
||||
@@ -35,6 +35,7 @@ func (s serviceGenerator) generateInterface(f *codegen.File) {
|
||||
input := typeFromMessage(s.pkg, method.Input())
|
||||
output := typeFromMessage(s.pkg, method.Output())
|
||||
f.P(t(1), method.Name(), "(request: ", input.Reference(), "): Promise<", output.Reference(), ">;")
|
||||
|
||||
})
|
||||
f.P("}")
|
||||
f.P()
|
||||
@@ -80,6 +81,25 @@ func (s serviceGenerator) generateClient(f *codegen.File) error {
|
||||
}
|
||||
|
||||
func (s serviceGenerator) generateMethod(f *codegen.File, method protoreflect.MethodDescriptor) error {
|
||||
|
||||
loc := method.ParentFile().SourceLocations().ByDescriptor(method)
|
||||
var comments string
|
||||
if loc.TrailingComments != "" {
|
||||
comments = comments + loc.TrailingComments
|
||||
}
|
||||
if loc.LeadingComments != "" {
|
||||
comments = comments + loc.LeadingComments
|
||||
}
|
||||
|
||||
AllSrvMethods = append(AllSrvMethods, SrvMethod{
|
||||
PkgName: string(s.pkg.Name()),
|
||||
ServiceName: string(s.service.Name()),
|
||||
MethodName: string(method.Name()),
|
||||
Comment: comments,
|
||||
In: string(method.Input().Name()),
|
||||
Out: string(method.Output().Name()),
|
||||
})
|
||||
|
||||
outputType := typeFromMessage(s.pkg, method.Output())
|
||||
r, ok := httprule.Get(method)
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user