Skip to content

Commit

Permalink
fix: support proto descriptors without source info included (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
bweston92 authored Sep 24, 2024
1 parent 2d06a08 commit 3cf3558
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/proto/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,25 @@ func GetDescriptionOrComment(name NameWithSourceResolver, description Descriptio
return description.GetDescription()
}

srcInfo := name.SourceCodeInfo()
if srcInfo == nil {
return ""
}

builder := &strings.Builder{}
for _, comment := range name.SourceCodeInfo().LeadingDetachedComments() {
for _, comment := range srcInfo.LeadingDetachedComments() {
builder.WriteString(comment)
}
builder.WriteString(name.SourceCodeInfo().LeadingComments())
builder.WriteString(name.SourceCodeInfo().TrailingComments())
builder.WriteString(srcInfo.LeadingComments())
builder.WriteString(srcInfo.TrailingComments())
comment := strings.TrimSpace(strings.Trim(builder.String(), "\n"))

if comment != "" {
return comment
}
return ""
}

func GetEntrypointMessage(pluginOptions *PluginOptions, fileOptions *FileOptions) string {
if fileOptions != nil && fileOptions.GetEntrypointMessage() != "" {
return fileOptions.GetEntrypointMessage()
Expand Down

0 comments on commit 3cf3558

Please sign in to comment.