Skip to content

Commit

Permalink
Declare the MessageExtensions with the correct visibility.
Browse files Browse the repository at this point in the history
While most developers should be able to use the accessors that are also
generated, the decls are still need to manual create a registry.
  • Loading branch information
thomasvl committed Mar 12, 2020
1 parent d596aaf commit 6dd8397
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Sources/protoc-gen-swift/ExtensionSetGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class ExtensionSetGenerator {
}

func generateProtobufExtensionDeclarations(printer p: inout CodePrinter) {
let visibility = generatorOptions.visibilitySourceSnippet
let scope = fieldDescriptor.extensionScope == nil ? "" : "static "
let traitsType = fieldDescriptor.traitsType(namer: namer)
let swiftRelativeExtensionName = namer.relativeName(extensionField: fieldDescriptor)
Expand All @@ -80,7 +81,7 @@ class ExtensionSetGenerator {

p.print(
comments,
"\(scope)let \(swiftRelativeExtensionName) = SwiftProtobuf.MessageExtension<\(extensionFieldType)<\(traitsType)>, \(containingTypeSwiftFullName)>(\n")
"\(visibility)\(scope)let \(swiftRelativeExtensionName) = SwiftProtobuf.MessageExtension<\(extensionFieldType)<\(traitsType)>, \(containingTypeSwiftFullName)>(\n")
p.indent()
p.print(
"_protobuf_fieldNumber: \(fieldDescriptor.number),\n",
Expand Down Expand Up @@ -250,6 +251,7 @@ class ExtensionSetGenerator {
p.print("}\n")
}

let visibility = generatorOptions.visibilitySourceSnippet
var currentScope: Descriptor? = nil
var addNewline = true
for e in extensions {
Expand All @@ -261,7 +263,7 @@ class ExtensionSetGenerator {
"\n",
"extension \(scopeSwiftFullName) {\n")
p.indent()
p.print("enum Extensions {\n")
p.print("\(visibility)enum Extensions {\n")
p.indent()
addNewline = false
}
Expand Down

0 comments on commit 6dd8397

Please sign in to comment.