@@ -177,13 +177,37 @@ private IEnumerable<DiagnosticRecord> FindSeparatorViolations(TokenOperations to
177
177
// TODO update separator error string
178
178
foreach ( var tokenNode in tokenOperations . GetTokenNodes ( IsSeparator ) . Where ( predicate ) )
179
179
{
180
+ var errorKind = tokenNode . Value . Kind == TokenKind . Comma
181
+ ? ErrorKind . SeparatorComma
182
+ : ErrorKind . SeparatorSemi ;
180
183
yield return getDiagnosticRecord (
181
184
tokenNode . Value ,
182
- tokenNode . Value . Kind == TokenKind . Comma ? ErrorKind . SeparatorComma : ErrorKind . SeparatorSemi ) ;
185
+ errorKind ,
186
+ GetSeparatorCorrections ( errorKind , tokenNode . Value , tokenNode . Next . Value ) . ToList ( ) ) ;
183
187
}
184
188
}
185
189
186
- private DiagnosticRecord getDiagnosticRecord ( Token token , ErrorKind errKind )
190
+ private IEnumerable < CorrectionExtent > GetSeparatorCorrections (
191
+ ErrorKind errorKind ,
192
+ Token separatorToken ,
193
+ Token nextToken )
194
+ {
195
+ var e1 = separatorToken . Extent ;
196
+ var e2 = nextToken . Extent ;
197
+ var extent = new ScriptExtent (
198
+ new ScriptPosition ( e1 . File , e1 . StartLineNumber , e1 . StartColumnNumber , null ) ,
199
+ new ScriptPosition ( e2 . File , e2 . StartLineNumber , e2 . StartColumnNumber , null ) ) ;
200
+ yield return new CorrectionExtent (
201
+ separatorToken . Extent ,
202
+ separatorToken . Text + whiteSpace ,
203
+ separatorToken . Extent . File ,
204
+ GetError ( errorKind ) ) ; // TODO replace with better string
205
+ }
206
+
207
+ private DiagnosticRecord getDiagnosticRecord (
208
+ Token token ,
209
+ ErrorKind errKind ,
210
+ List < CorrectionExtent > corrections )
187
211
{
188
212
return new DiagnosticRecord (
189
213
GetError ( errKind ) ,
@@ -192,7 +216,7 @@ private DiagnosticRecord getDiagnosticRecord(Token token, ErrorKind errKind)
192
216
GetDiagnosticSeverity ( ) ,
193
217
token . Extent . File ,
194
218
null ,
195
- null ) ;
219
+ corrections ) ;
196
220
}
197
221
198
222
private bool IsKeyword ( Token token )
0 commit comments