@@ -2,16 +2,14 @@ import SwiftSyntax
22import SwiftSyntaxBuilder
33import TecoCodeGeneratorCommons
44
5- typealias Deprecation = ( deprecated: Bool , message: String ? )
6-
7- private func buildActionAttributeList( discardableResult: Bool , deprecation: Deprecation ) -> AttributeListSyntax {
5+ private func buildActionAttributeList( for action: APIModel . Action , discardableResult: Bool ) -> AttributeListSyntax {
86 AttributeListSyntax {
9- if deprecation . deprecated {
10- if let message = deprecation . message {
11- AttributeSyntax ( " @available(*, deprecated , message: \( literal: message) ) " )
7+ if let availability = action . availability {
8+ if let message = action . deprecationMessage {
9+ AttributeSyntax ( " @available(*, \( raw : availability ) , message: \( literal: message) ) " )
1210 . withTrailingTrivia ( . newline)
1311 } else {
14- AttributeSyntax ( " @available(*, deprecated ) " ) . withTrailingTrivia ( . newline)
12+ AttributeSyntax ( " @available(*, \( raw : availability ) ) " ) . withTrailingTrivia ( . newline)
1513 }
1614 }
1715 AttributeSyntax ( " @inlinable " )
@@ -24,7 +22,7 @@ private func buildActionAttributeList(discardableResult: Bool, deprecation: Depr
2422func buildActionDecl( for action: String , metadata: APIModel . Action , discardableResult: Bool ) -> FunctionDeclSyntax {
2523 FunctionDeclSyntax ( """
2624 \( raw: buildDocumentation ( summary: metadata. name, discussion: metadata. document) )
27- \( buildActionAttributeList ( discardableResult : discardableResult , deprecation : metadata . deprecation ) )
25+ \( buildActionAttributeList ( for : metadata , discardableResult : discardableResult ) )
2826 public func \( raw: action. lowerFirst ( ) ) (_ input: \( raw: metadata. input) , region: TCRegion? = nil, logger: Logger = TCClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> \( raw: " EventLoopFuture< \( metadata. output) > " ) {
2927 self.client.execute(action: \( literal: action) , region: region, serviceConfig: self.config \( raw: skipAuthorizationParameter ( for: action) ) , input: input, logger: logger, on: eventLoop)
3028 }
@@ -34,7 +32,7 @@ func buildActionDecl(for action: String, metadata: APIModel.Action, discardableR
3432func buildAsyncActionDecl( for action: String , metadata: APIModel . Action , discardableResult: Bool ) -> FunctionDeclSyntax {
3533 FunctionDeclSyntax ( """
3634 \( raw: buildDocumentation ( summary: metadata. name, discussion: metadata. document) )
37- \( buildActionAttributeList ( discardableResult : discardableResult , deprecation : metadata . deprecation ) )
35+ \( buildActionAttributeList ( for : metadata , discardableResult : discardableResult ) )
3836 public func \( raw: action. lowerFirst ( ) ) (_ input: \( raw: metadata. input) , region: TCRegion? = nil, logger: Logger = TCClient.loggingDisabled, on eventLoop: EventLoop? = nil) async throws -> \( raw: metadata. output) {
3937 try await self.client.execute(action: \( literal: action) , region: region, serviceConfig: self.config \( raw: skipAuthorizationParameter ( for: action) ) , input: input, logger: logger, on: eventLoop).get()
4038 }
@@ -44,7 +42,7 @@ func buildAsyncActionDecl(for action: String, metadata: APIModel.Action, discard
4442func buildUnpackedActionDecl( for action: String , metadata: APIModel . Action , inputMembers: [ APIObject . Member ] , discardableResult: Bool ) -> FunctionDeclSyntax {
4543 FunctionDeclSyntax ( """
4644 \( raw: buildDocumentation ( summary: metadata. name, discussion: metadata. document) )
47- \( buildActionAttributeList ( discardableResult : discardableResult , deprecation : metadata . deprecation ) )
45+ \( buildActionAttributeList ( for : metadata , discardableResult : discardableResult ) )
4846 public func \( raw: action. lowerFirst ( ) ) ( \( raw: initializerParameterList ( for: inputMembers, packed: true ) ) region: TCRegion? = nil, logger: Logger = TCClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> \( raw: " EventLoopFuture< \( metadata. output) > " ) {
4947 self. \( raw: action. lowerFirst ( ) ) ( \( raw: metadata. input) ( \( raw: inputMembers. map ( { " \( $0. identifier) : \( $0. escapedIdentifier) " } ) . joined ( separator: " , " ) ) ), region: region, logger: logger, on: eventLoop)
5048 }
@@ -54,13 +52,9 @@ func buildUnpackedActionDecl(for action: String, metadata: APIModel.Action, inpu
5452func buildUnpackedAsyncActionDecl( for action: String , metadata: APIModel . Action , inputMembers: [ APIObject . Member ] , discardableResult: Bool ) -> FunctionDeclSyntax {
5553 FunctionDeclSyntax ( """
5654 \( raw: buildDocumentation ( summary: metadata. name, discussion: metadata. document) )
57- \( buildActionAttributeList ( discardableResult : discardableResult , deprecation : metadata . deprecation ) )
55+ \( buildActionAttributeList ( for : metadata , discardableResult : discardableResult ) )
5856 public func \( raw: action. lowerFirst ( ) ) ( \( raw: initializerParameterList ( for: inputMembers, packed: true ) ) region: TCRegion? = nil, logger: Logger = TCClient.loggingDisabled, on eventLoop: EventLoop? = nil) async throws -> \( raw: metadata. output) {
5957 try await self. \( raw: action. lowerFirst ( ) ) ( \( raw: metadata. input) ( \( raw: inputMembers. map ( { " \( $0. identifier) : \( $0. escapedIdentifier) " } ) . joined ( separator: " , " ) ) ), region: region, logger: logger, on: eventLoop)
6058 }
6159 """ )
6260}
63-
64- extension APIModel . Action {
65- fileprivate var deprecation : Deprecation { ( self . deprecated, self . deprecationMessage) }
66- }
0 commit comments