Fix bug in `HawkSourceAnalyzer`
This commit is contained in:
parent
1fdacd762a
commit
c09f195148
|
@ -134,14 +134,14 @@ public class HawkSourceAnalyzer : DiagnosticAnalyzer
|
|||
snac.ReportDiagnostic(Diagnostic.Create(DiagNoDiscardingLocals, snac.Node.GetLocation()));
|
||||
break;
|
||||
case CollectionExpressionSyntax ces:
|
||||
var cesError = CheckSpacingInList(ces.Elements, ces.OpenBracketToken, ces.ToFullString);
|
||||
var cesError = CheckSpacingInList(ces.Elements, ces.OpenBracketToken, ces.ToString);
|
||||
if (cesError is not null) snac.ReportDiagnostic(Diagnostic.Create(DiagListExprSpacing, ces.GetLocation(), cesError));
|
||||
break;
|
||||
case InterpolatedStringExpressionSyntax ises:
|
||||
if (ises.StringStartToken.Text[0] is '@') snac.ReportDiagnostic(Diagnostic.Create(DiagInterpStringIsDollarAt, ises.GetLocation()));
|
||||
break;
|
||||
case ListPatternSyntax lps:
|
||||
var lpsError = CheckSpacingInList(lps.Patterns, lps.OpenBracketToken, lps.ToFullString);
|
||||
var lpsError = CheckSpacingInList(lps.Patterns, lps.OpenBracketToken, lps.ToString);
|
||||
if (lpsError is not null) snac.ReportDiagnostic(Diagnostic.Create(DiagListExprSpacing, lps.GetLocation(), lpsError));
|
||||
break;
|
||||
case QueryExpressionSyntax:
|
||||
|
|
|
@ -118,11 +118,17 @@ public sealed class HawkSourceAnalyzerTests
|
|||
public Task CheckMisuseOfListSyntaxes()
|
||||
=> Verify.VerifyAnalyzerAsync("""
|
||||
public static class Cases {
|
||||
private static readonly int[] V = [ ];
|
||||
private static readonly bool W = V is [ ];
|
||||
private static readonly int[] X = W ? [ ] : V;
|
||||
private static readonly int[] Y = [ 0x80, 0x20, 0x40 ];
|
||||
private static readonly bool Z = Y is [ _, > 20, .. ];
|
||||
private static readonly int[] A = {|BHI1110:[0x80, 0x20, 0x40 ]|};
|
||||
private static readonly bool B = A is {|BHI1110:[ _, > 20, ..]|};
|
||||
private static readonly bool C = A is {|BHI1110:[_, > 20, ..]|};
|
||||
private static readonly int[] D = {|BHI1110:[]|};
|
||||
private static readonly bool E = D is {|BHI1110:[]|};
|
||||
private static readonly int[] F = E ? {|BHI1110:[]|} : D;
|
||||
}
|
||||
""");
|
||||
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue