@@ -96,13 +96,12 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
96
96
if shouldSkip ( node) {
97
97
return . skipChildren
98
98
}
99
+ // Detect C-style for loops based on two semicolons which could not be parsed between the 'for' keyword and the '{'
99
100
// This is mostly a proof-of-concept implementation to produce more complex diagnostics.
100
- if let unexpectedCondition = node. body. unexpectedBeforeLeftBrace {
101
- // Detect C-style for loops based on two semicolons which could not be parsed between the 'for' keyword and the '{'
102
- if unexpectedCondition. tokens ( withKind: . semicolon) . count == 2 {
103
- addDiagnostic ( node, . cStyleForLoop)
104
- markNodesAsHandled ( node. inKeyword. id, unexpectedCondition. id)
105
- }
101
+ if let unexpectedCondition = node. body. unexpectedBeforeLeftBrace,
102
+ unexpectedCondition. tokens ( withKind: . semicolon) . count == 2 {
103
+ addDiagnostic ( node, . cStyleForLoop)
104
+ markNodesAsHandled ( node. inKeyword. id, unexpectedCondition. id)
106
105
}
107
106
return . visitChildren
108
107
}
@@ -111,12 +110,12 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
111
110
if shouldSkip ( node) {
112
111
return . skipChildren
113
112
}
114
- if let output = node. output, let unexpectedBeforeReturnType = output. unexpectedBetweenArrowAndReturnType {
115
- if let throwsInReturnPosition = unexpectedBeforeReturnType. tokens ( withKind: . throwsKeyword) . first {
113
+ if let output = node. output,
114
+ let unexpectedBeforeReturnType = output. unexpectedBetweenArrowAndReturnType,
115
+ let throwsInReturnPosition = unexpectedBeforeReturnType. tokens ( withKind: . throwsKeyword) . first {
116
116
addDiagnostic ( throwsInReturnPosition, . throwsInReturnPosition)
117
117
markNodesAsHandled ( unexpectedBeforeReturnType. id, throwsInReturnPosition. id)
118
118
return . visitChildren
119
- }
120
119
}
121
120
return . visitChildren
122
121
}
0 commit comments