Skip to content

Commit 216395c

Browse files
author
Kapil Borle
committed
Use one corrections method for all violation kinds
1 parent 578fd98 commit 216395c

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

Rules/UseWhitespace.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private IEnumerable<DiagnosticRecord> FindOpenBraceViolations(TokenOperations to
132132
GetDiagnosticSeverity(),
133133
tokenOperations.Ast.Extent.File,
134134
null,
135-
GetOpenBracketCorrections(lcurly.Value).ToList());
135+
GetCorrections(lcurly.Previous.Value, lcurly.Value, lcurly.Next.Value, false, true).ToList());
136136
}
137137
}
138138
}
@@ -183,7 +183,12 @@ private IEnumerable<DiagnosticRecord> FindSeparatorViolations(TokenOperations to
183183
yield return getDiagnosticRecord(
184184
tokenNode.Value,
185185
errorKind,
186-
GetOperatorCorrections(tokenNode.Previous.Value, tokenNode.Value, tokenNode.Next.Value, true, false).ToList());
186+
GetCorrections(
187+
tokenNode.Previous.Value,
188+
tokenNode.Value,
189+
tokenNode.Next.Value,
190+
true,
191+
false));
187192
}
188193
}
189194

@@ -257,17 +262,17 @@ private IEnumerable<DiagnosticRecord> FindOperatorViolations(TokenOperations tok
257262
GetDiagnosticSeverity(),
258263
tokenOperations.Ast.Extent.File,
259264
null,
260-
GetOperatorCorrections(
265+
GetCorrections(
261266
tokenNode.Previous.Value,
262267
tokenNode.Value,
263268
tokenNode.Next.Value,
264269
hasWhitespaceBefore,
265-
hasWhitespaceAfter).ToList());
270+
hasWhitespaceAfter));
266271
}
267272
}
268273
}
269274

270-
private IEnumerable<CorrectionExtent> GetOperatorCorrections(
275+
private List<CorrectionExtent> GetCorrections(
271276
Token prevToken,
272277
Token token,
273278
Token nextToken,
@@ -293,11 +298,14 @@ private IEnumerable<CorrectionExtent> GetOperatorCorrections(
293298
new ScriptPosition(e1.File, e1.EndLineNumber, e1.EndColumnNumber, null),
294299
new ScriptPosition(e2.File, e2.StartLineNumber, e2.StartColumnNumber, null));
295300

296-
yield return new CorrectionExtent(
301+
return new List<CorrectionExtent>()
302+
{
303+
new CorrectionExtent(
297304
extent,
298305
sb.ToString(),
299306
token.Extent.File,
300-
GetError(ErrorKind.Operator));
307+
GetError(ErrorKind.Operator))
308+
};
301309
}
302310

303311
private bool IsOperator(Token token)

0 commit comments

Comments
 (0)