-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid proto comments during experimental_strip_nonfunctional_codegen.
Following upstream protobuf, honor the experimental_strip_nonfunctional_codegen generation option to not include comments in generated code.
- Loading branch information
Showing
7 changed files
with
70 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
Sources/protoc-gen-swift/ProvidesDeprecationComment+Extensions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Sources/protoc-gen-swift/ProvidesSourceCodeLocation+Extensions.swift | ||
// | ||
// Copyright (c) 2014 - 2024 Apple Inc. and the project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See LICENSE.txt for license information: | ||
// https://github.com/apple/swift-protobuf/blob/main/LICENSE.txt | ||
// | ||
// ----------------------------------------------------------------------------- | ||
|
||
import Foundation | ||
|
||
import SwiftProtobufPluginLibrary | ||
|
||
extension ProvidesSourceCodeLocation { | ||
func protoSourceComments( | ||
generatorOptions: GeneratorOptions, | ||
commentPrefix: String = "///", | ||
leadingDetachedPrefix: String? = nil | ||
) -> String { | ||
if generatorOptions.experimentalStripNonfunctionalCodegen { | ||
// Comments are inherently non-functional, and may change subtly on | ||
// transformations. | ||
return String() | ||
} | ||
return protoSourceComments(commentPrefix: commentPrefix, | ||
leadingDetachedPrefix: leadingDetachedPrefix) | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
Sources/protoc-gen-swift/ProvidesSourceCodeLocation+Extensions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Sources/protoc-gen-swift/ProvidesDeprecationComment+Extensions.swift | ||
// | ||
// Copyright (c) 2014 - 2024 Apple Inc. and the project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See LICENSE.txt for license information: | ||
// https://github.com/apple/swift-protobuf/blob/main/LICENSE.txt | ||
// | ||
// ----------------------------------------------------------------------------- | ||
|
||
import Foundation | ||
|
||
import SwiftProtobufPluginLibrary | ||
|
||
extension ProvidesDeprecationComment where Self: ProvidesSourceCodeLocation { | ||
func protoSourceCommentsWithDeprecation( | ||
generatorOptions: GeneratorOptions, | ||
commentPrefix: String = "///", | ||
leadingDetachedPrefix: String? = nil | ||
) -> String { | ||
if generatorOptions.experimentalStripNonfunctionalCodegen { | ||
// Comments are inherently non-functional, and may change subtly on | ||
// transformations. | ||
return deprecationComment(commentPrefix: commentPrefix) | ||
} | ||
|
||
return protoSourceCommentsWithDeprecation(commentPrefix: commentPrefix, | ||
leadingDetachedPrefix: leadingDetachedPrefix) | ||
} | ||
} |