Skip to content

Commit aabfd74

Browse files
committed
Add more comments calling out things in the file.
Since developers might need to go looking into the source for some of the extension related things, add command/marks into the file to hopefully make it easier to find the using things.
1 parent 3bee8b5 commit aabfd74

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Sources/protoc-gen-swift/ExtensionSetGenerator.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,15 @@ class ExtensionSetGenerator {
159159
func generateMessageSwiftExtensions(printer p: inout CodePrinter) {
160160
guard !extensions.isEmpty else { return }
161161

162+
p.print(
163+
"\n",
164+
"// MARK: - Extension Properties\n",
165+
"\n",
166+
"// Swift Extensions on the exteneded Messages to add easy access to the declared\n",
167+
"// extension fields. The names are based on the extension field name from the proto\n",
168+
"// declaration. To avoid naming collisions, the names are prefixed with the name of\n",
169+
"// the scope where the extend directive occurs.\n")
170+
162171
// Reorder the list so they are grouped by the Message being extended, but
163172
// maintaining the order they were within the file within those groups.
164173
let grouped: [ExtensionGenerator] = extensions.enumerated().sorted {
@@ -206,6 +215,8 @@ class ExtensionSetGenerator {
206215
let filenameAsIdentifer = NamingUtils.toUpperCamelCase(pathParts.base)
207216
let filePrefix = namer.typePrefix(forFile: fileDescriptor)
208217
p.print(
218+
"\n",
219+
"// MARK: - File's ExtensionMap: \(filePrefix)\(filenameAsIdentifer)_Extensions\n",
209220
"\n",
210221
"/// A `SwiftProtobuf.SimpleExtensionMap` that includes all of the extensions defined by\n",
211222
"/// this .proto file. It can be used any place an `SwiftProtobuf.ExtensionMap` is needed\n",
@@ -226,6 +237,12 @@ class ExtensionSetGenerator {
226237
func generateProtobufExtensionDeclarations(printer p: inout CodePrinter) {
227238
guard !extensions.isEmpty else { return }
228239

240+
p.print(
241+
"\n",
242+
"// Extension Objects - The only reason these might be needed is when manually\n",
243+
"// constructing a `SimpleExtensionMap`, otherwise, use the above _Extension Properties_\n",
244+
"// accessors for the extension fields on the messages directly.\n")
245+
229246
func endScope() {
230247
p.outdent()
231248
p.print("}\n")

0 commit comments

Comments
 (0)