@@ -38,7 +38,8 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName) {
38
38
{
39
39
if ( IncorrectComparisonWithNull ( binExpressionAst , ast ) )
40
40
{
41
- yield return new DiagnosticRecord ( Strings . PossibleIncorrectComparisonWithNullError , binExpressionAst . Extent , GetName ( ) , DiagnosticSeverity . Warning , fileName ) ;
41
+ yield return new DiagnosticRecord ( Strings . PossibleIncorrectComparisonWithNullError , binExpressionAst . Extent , GetName ( ) , DiagnosticSeverity . Warning , fileName ,
42
+ null , suggestedCorrections : GetCorrectionExtent ( binExpressionAst ) ) ;
42
43
}
43
44
}
44
45
}
@@ -60,7 +61,8 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName) {
60
61
{
61
62
if ( IncorrectComparisonWithNull ( binAst , funcAst ) )
62
63
{
63
- yield return new DiagnosticRecord ( Strings . PossibleIncorrectComparisonWithNullError , binAst . Extent , GetName ( ) , DiagnosticSeverity . Warning , fileName ) ;
64
+ yield return new DiagnosticRecord ( Strings . PossibleIncorrectComparisonWithNullError , binAst . Extent , GetName ( ) , DiagnosticSeverity . Warning , fileName ,
65
+ null , suggestedCorrections : GetCorrectionExtent ( binAst ) ) ;
64
66
}
65
67
}
66
68
}
@@ -101,6 +103,21 @@ private bool IncorrectComparisonWithNull(BinaryExpressionAst binExpressionAst, A
101
103
return false ;
102
104
}
103
105
106
+ private IEnumerable < CorrectionExtent > GetCorrectionExtent ( BinaryExpressionAst binaryExpressionAst )
107
+ {
108
+ var correction = new CorrectionExtent (
109
+ binaryExpressionAst . Extent . StartLineNumber ,
110
+ binaryExpressionAst . Extent . EndLineNumber ,
111
+ binaryExpressionAst . Extent . StartColumnNumber ,
112
+ binaryExpressionAst . Extent . EndColumnNumber ,
113
+ $ "{ binaryExpressionAst . Right . Extent . Text } { binaryExpressionAst . ErrorPosition . Text } { binaryExpressionAst . Left . Extent . Text } ",
114
+ binaryExpressionAst . Extent . File ,
115
+ Strings . PossibleIncorrectComparisonWithNullSuggesteCorrectionDescription
116
+ ) ;
117
+
118
+ yield return correction ;
119
+ }
120
+
104
121
/// <summary>
105
122
/// GetName: Retrieves the name of this rule.
106
123
/// </summary>
0 commit comments