Skip to content

Commit 7695d98

Browse files
authored
Align on config name for use import access level (#35)
Motivation: When the plugin was done we went through a few iterations of the shape of config and settled on `accessLevelOnImports` vs. `useAccessLevelOnImports` but that change wasn't made. Modifications: - Update config name. Result: API is what we planned it to be.
1 parent 7d129ce commit 7695d98

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

Plugins/GRPCProtobufGenerator/BuildPluginConfig.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,16 @@ struct BuildPluginConfig: Codable {
5757
/// Whether imports should have explicit access levels.
5858
///
5959
/// Defaults to `false`.
60-
var useAccessLevelOnImports: Bool
60+
var accessLevelOnImports: Bool
6161

6262
static let defaults = Self(
6363
accessLevel: .internal,
64-
useAccessLevelOnImports: false
64+
accessLevelOnImports: false
6565
)
6666

67-
private init(accessLevel: GenerationConfig.AccessLevel, useAccessLevelOnImports: Bool) {
67+
private init(accessLevel: GenerationConfig.AccessLevel, accessLevelOnImports: Bool) {
6868
self.accessLevel = accessLevel
69-
self.useAccessLevelOnImports = useAccessLevelOnImports
69+
self.accessLevelOnImports = accessLevelOnImports
7070
}
7171
}
7272

@@ -159,7 +159,7 @@ extension BuildPluginConfig.GeneratedSource: Codable {
159159
// Codable conformance with defaults
160160
enum CodingKeys: String, CodingKey {
161161
case accessLevel
162-
case useAccessLevelOnImports
162+
case accessLevelOnImports
163163
}
164164

165165
init(from decoder: any Decoder) throws {
@@ -168,9 +168,9 @@ extension BuildPluginConfig.GeneratedSource: Codable {
168168
self.accessLevel =
169169
try container.decodeIfPresent(GenerationConfig.AccessLevel.self, forKey: .accessLevel)
170170
?? Self.defaults.accessLevel
171-
self.useAccessLevelOnImports =
172-
try container.decodeIfPresent(Bool.self, forKey: .useAccessLevelOnImports)
173-
?? Self.defaults.useAccessLevelOnImports
171+
self.accessLevelOnImports =
172+
try container.decodeIfPresent(Bool.self, forKey: .accessLevelOnImports)
173+
?? Self.defaults.accessLevelOnImports
174174
}
175175
}
176176

@@ -199,7 +199,7 @@ extension GenerationConfig {
199199
// hard-code full-path to avoid collisions since this goes into a temporary directory anyway
200200
self.fileNaming = .fullPath
201201
self.visibility = buildPluginConfig.generatedSource.accessLevel
202-
self.useAccessLevelOnImports = buildPluginConfig.generatedSource.useAccessLevelOnImports
202+
self.accessLevelOnImports = buildPluginConfig.generatedSource.accessLevelOnImports
203203
// Generate absolute paths for the imports relative to the config file in which they are specified
204204
self.importPaths = buildPluginConfig.protoc.importPaths.map { relativePath in
205205
configFilePath.deletingLastPathComponent().absoluteStringNoScheme + "/" + relativePath

Plugins/PluginsShared/GenerationConfig.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct GenerationConfig {
5252
/// The naming of output files with respect to the path of the source file.
5353
var fileNaming: FileNaming
5454
/// Whether imports should have explicit access levels.
55-
var useAccessLevelOnImports: Bool
55+
var accessLevelOnImports: Bool
5656

5757
/// Specify the directory in which to search for imports.
5858
///

Plugins/PluginsShared/PluginUtils.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func constructProtocGenSwiftArguments(
6565

6666
protocArgs.append("--swift_opt=Visibility=\(config.visibility.rawValue)")
6767
protocArgs.append("--swift_opt=FileNaming=\(config.fileNaming.rawValue)")
68-
protocArgs.append("--swift_opt=UseAccessLevelOnImports=\(config.useAccessLevelOnImports)")
68+
protocArgs.append("--swift_opt=UseAccessLevelOnImports=\(config.accessLevelOnImports)")
6969
protocArgs.append(contentsOf: inputFiles.map { $0.absoluteStringNoScheme })
7070

7171
return protocArgs
@@ -101,7 +101,7 @@ func constructProtocGenGRPCSwiftArguments(
101101
protocArgs.append("--grpc-swift_opt=Server=\(config.server)")
102102
protocArgs.append("--grpc-swift_opt=Client=\(config.client)")
103103
protocArgs.append("--grpc-swift_opt=FileNaming=\(config.fileNaming.rawValue)")
104-
protocArgs.append("--grpc-swift_opt=UseAccessLevelOnImports=\(config.useAccessLevelOnImports)")
104+
protocArgs.append("--grpc-swift_opt=UseAccessLevelOnImports=\(config.accessLevelOnImports)")
105105
protocArgs.append(contentsOf: inputFiles.map { $0.absoluteStringNoScheme })
106106

107107
return protocArgs

0 commit comments

Comments
 (0)