ProvidesSourceCodeLocation+Extensions.swift 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. // Sources/protoc-gen-swift/ProvidesDeprecationComment+Extensions.swift
  2. //
  3. // Copyright (c) 2014 - 2024 Apple Inc. and the project authors
  4. // Licensed under Apache License v2.0 with Runtime Library Exception
  5. //
  6. // See LICENSE.txt for license information:
  7. // https://github.com/apple/swift-protobuf/blob/main/LICENSE.txt
  8. //
  9. // -----------------------------------------------------------------------------
  10. import Foundation
  11. import SwiftProtobufPluginLibrary
  12. extension ProvidesDeprecationComment where Self: ProvidesSourceCodeLocation {
  13. func protoSourceCommentsWithDeprecation(
  14. generatorOptions: GeneratorOptions,
  15. commentPrefix: String = "///",
  16. leadingDetachedPrefix: String? = nil
  17. ) -> String {
  18. if generatorOptions.experimentalStripNonfunctionalCodegen {
  19. // Comments are inherently non-functional, and may change subtly on
  20. // transformations.
  21. return deprecationComment(commentPrefix: commentPrefix)
  22. }
  23. return protoSourceCommentsWithDeprecation(
  24. commentPrefix: commentPrefix,
  25. leadingDetachedPrefix: leadingDetachedPrefix
  26. )
  27. }
  28. }