@@ -32,31 +32,30 @@ public final class UseShorthandTypeNames: SyntaxFormatRule {
32
32
!( parent is MemberTypeIdentifierSyntax ) else { return node }
33
33
// Type is in long form if it has a non-nil generic argument clause
34
34
guard let genArg = node. genericArgumentClause else { return node }
35
- diagnose ( . useTypeShorthand( type: node. name. text. lowercased ( ) ) , on: node)
36
35
37
36
// Ensure that all arguments in the clause are shortened and in expected-format by visiting
38
37
// the argument list, first
39
38
let argList = visit ( genArg. arguments) as! GenericArgumentListSyntax
40
39
// Store trivia of the long form type to pass to the new shorthand type later
41
40
let trivia = retrieveTrivia ( from: node)
42
41
42
+ let newNode : TypeSyntax
43
43
switch node. name. text {
44
44
case " Array " :
45
45
guard let arg = argList. firstAndOnly else { return node }
46
- let newArray = shortenArrayType ( argument: arg, trivia: trivia)
47
- return newArray
46
+ newNode = shortenArrayType ( argument: arg, trivia: trivia)
48
47
case " Dictionary " :
49
48
guard let args = exactlyTwoChildren ( of: argList) else { return node }
50
- let newDictionary = shortenDictionaryType ( arguments: args, trivia: trivia)
51
- return newDictionary
49
+ newNode = shortenDictionaryType ( arguments: args, trivia: trivia)
52
50
case " Optional " :
53
51
guard let arg = argList. firstAndOnly else { return node }
54
- let newOptional = shortenOptionalType ( argument: arg, trivia: trivia)
55
- return newOptional
52
+ newNode = shortenOptionalType ( argument: arg, trivia: trivia)
56
53
default :
57
- break
54
+ return node
58
55
}
59
- return node
56
+
57
+ diagnose ( . useTypeShorthand( type: node. name. text) , on: node)
58
+ return newNode
60
59
}
61
60
62
61
// Visits all potential long forms interpreted as expressions
0 commit comments