@@ -99,43 +99,41 @@ extension AddDocumentation: SyntaxRefactoringCodeActionProvider {
99
99
100
100
extension DeclSyntax {
101
101
fileprivate var parameters : FunctionParameterClauseSyntax ? {
102
- switch self . syntaxNodeType {
103
- case is FunctionDeclSyntax . Type :
104
- return self . as ( FunctionDeclSyntax . self ) ! . signature. parameterClause
105
- case is SubscriptDeclSyntax . Type :
106
- return self . as ( SubscriptDeclSyntax . self ) ! . parameterClause
107
- case is InitializerDeclSyntax . Type :
108
- return self . as ( InitializerDeclSyntax . self ) ! . signature. parameterClause
109
- case is MacroDeclSyntax . Type :
110
- return self . as ( MacroDeclSyntax . self ) ! . signature. parameterClause
102
+ switch self . as ( DeclSyntaxEnum . self ) {
103
+ case . functionDecl ( let functionDecl ) :
104
+ return functionDecl . signature. parameterClause
105
+ case . subscriptDecl ( let subscriptDecl ) :
106
+ return subscriptDecl . parameterClause
107
+ case . initializerDecl ( let initializer ) :
108
+ return initializer . signature. parameterClause
109
+ case . macroDecl ( let macro ) :
110
+ return macro . signature. parameterClause
111
111
default :
112
112
return nil
113
113
}
114
114
}
115
115
116
116
fileprivate var throwsKeyword : TokenSyntax ? {
117
- switch self . syntaxNodeType {
118
- case is FunctionDeclSyntax . Type :
119
- return self . as ( FunctionDeclSyntax . self) !. signature. effectSpecifiers?
120
- . throwsClause? . throwsSpecifier
121
- case is InitializerDeclSyntax . Type :
122
- return self . as ( InitializerDeclSyntax . self) !. signature. effectSpecifiers?
123
- . throwsClause? . throwsSpecifier
117
+ switch self . as ( DeclSyntaxEnum . self) {
118
+ case . functionDecl( let functionDecl) :
119
+ return functionDecl. signature. effectSpecifiers? . throwsClause? . throwsSpecifier
120
+ case . initializerDecl( let initializer) :
121
+ return initializer. signature. effectSpecifiers? . throwsClause? . throwsSpecifier
124
122
default :
125
123
return nil
126
124
}
127
125
}
128
126
129
127
fileprivate var returnType : TypeSyntax ? {
130
- switch self . syntaxNodeType {
131
- case is FunctionDeclSyntax . Type :
132
- return self . as ( FunctionDeclSyntax . self ) ! . signature. returnClause? . type
133
- case is SubscriptDeclSyntax . Type :
134
- return self . as ( SubscriptDeclSyntax . self ) ! . returnClause. type
135
- case is InitializerDeclSyntax . Type :
136
- return self . as ( InitializerDeclSyntax . self ) ! . signature. returnClause? . type
137
- case is MacroDeclSyntax . Type :
138
- return self . as ( MacroDeclSyntax . self ) ! . signature. returnClause? . type
128
+ switch self . as ( DeclSyntaxEnum . self ) {
129
+ case . functionDecl ( let functionDecl ) :
130
+ return functionDecl . signature. returnClause? . type
131
+ case . subscriptDecl ( let subscriptDecl ) :
132
+ return subscriptDecl . returnClause. type
133
+ case . initializerDecl ( let initializer ) :
134
+ return initializer . signature. returnClause? . type
135
+ case . macroDecl ( let macro ) :
136
+ return macro . signature. returnClause? . type
139
137
default :
140
138
return nil
141
139
}
0 commit comments