@@ -154,7 +154,7 @@ private IEnumerable<DiagnosticRecord> FindOpenParenViolations(TokenOperations to
154
154
GetDiagnosticSeverity ( ) ,
155
155
tokenOperations . Ast . Extent . File ,
156
156
null ,
157
- GetOpenBracketCorrections ( lparen . Value ) . ToList ( ) ) ;
157
+ GetCorrections ( lparen . Previous . Value , lparen . Value , lparen . Next . Value , false , true ) . ToList ( ) ) ;
158
158
}
159
159
}
160
160
}
@@ -163,6 +163,7 @@ private bool IsSeparator(Token token)
163
163
{
164
164
return token . Kind == TokenKind . Comma || token . Kind == TokenKind . Semi ;
165
165
}
166
+
166
167
private IEnumerable < DiagnosticRecord > FindSeparatorViolations ( TokenOperations tokenOperations )
167
168
{
168
169
Func < LinkedListNode < Token > , bool > predicate = node =>
@@ -173,8 +174,6 @@ private IEnumerable<DiagnosticRecord> FindSeparatorViolations(TokenOperations to
173
174
&& ! IsPreviousTokenApartByWhitespace ( node . Next ) ;
174
175
} ;
175
176
176
- // TODO replace semi-colon with semicolon
177
- // TODO update separator error string
178
177
foreach ( var tokenNode in tokenOperations . GetTokenNodes ( IsSeparator ) . Where ( predicate ) )
179
178
{
180
179
var errorKind = tokenNode . Value . Kind == TokenKind . Comma
@@ -224,15 +223,6 @@ private bool IsKeyword(Token token)
224
223
}
225
224
}
226
225
227
- private IEnumerable < CorrectionExtent > GetOpenBracketCorrections ( Token token )
228
- {
229
- yield return new CorrectionExtent (
230
- token . Extent ,
231
- whiteSpace + token . Text ,
232
- token . Extent . File ,
233
- GetError ( ErrorKind . Brace ) ) ;
234
- }
235
-
236
226
private bool IsPreviousTokenApartByWhitespace ( LinkedListNode < Token > tokenNode )
237
227
{
238
228
return whiteSpaceSize ==
@@ -285,19 +275,23 @@ private List<CorrectionExtent> GetCorrections(
285
275
{
286
276
sb . Append ( whiteSpace ) ;
287
277
e1 = prevToken . Extent ;
288
- sb . Append ( token . Text ) ;
289
278
}
290
279
280
+ var e2 = token . Extent ;
291
281
if ( ! hasWhitespaceAfter )
292
282
{
283
+ if ( ! hasWhitespaceBefore )
284
+ {
285
+ sb . Append ( token . Text ) ;
286
+ }
287
+
288
+ e2 = nextToken . Extent ;
293
289
sb . Append ( whiteSpace ) ;
294
290
}
295
291
296
- var e2 = nextToken . Extent ;
297
292
var extent = new ScriptExtent (
298
293
new ScriptPosition ( e1 . File , e1 . EndLineNumber , e1 . EndColumnNumber , null ) ,
299
294
new ScriptPosition ( e2 . File , e2 . StartLineNumber , e2 . StartColumnNumber , null ) ) ;
300
-
301
295
return new List < CorrectionExtent > ( )
302
296
{
303
297
new CorrectionExtent (
0 commit comments