Simplify some `ReportAt` calls in BizHawk.Analyzer

will rebuild in later commit
This commit is contained in:
YoshiRulz 2025-03-20 05:50:07 +10:00
parent e79ab84d98
commit a93da782e0
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
2 changed files with 10 additions and 10 deletions

View File

@ -45,21 +45,21 @@ public sealed class FeatureNotImplementedAnalyzer : DiagnosticAnalyzer
}
bool IncludesFNIAttribute(SyntaxList<AttributeListSyntax> mds)
=> mds.Matching(featureNotImplementedAttrSym, snac).Any();
void CheckBlockBody(BlockSyntax bs, Location location)
void CheckBlockBody(BlockSyntax bs)
{
if (bs.Statements is [ ThrowStatementSyntax tss ]) MaybeReportFor(snac.SemanticModel.GetThrownExceptionType(tss), tss);
else DiagShouldThrowNIE.ReportAt(location, snac, [ ERR_MSG_DOES_NOT_THROW ]);
else DiagShouldThrowNIE.ReportAt(bs.Parent!, snac, ERR_MSG_DOES_NOT_THROW);
}
void CheckExprBody(ArrowExpressionClauseSyntax aecs, Location location)
void CheckExprBody(ArrowExpressionClauseSyntax aecs)
{
if (aecs.Expression is ThrowExpressionSyntax tes) MaybeReportFor(snac.SemanticModel.GetThrownExceptionType(tes), tes);
else DiagShouldThrowNIE.ReportAt(location, snac, [ ERR_MSG_DOES_NOT_THROW ]);
else DiagShouldThrowNIE.ReportAt(aecs.Parent!, snac, ERR_MSG_DOES_NOT_THROW);
}
void CheckAccessor(AccessorDeclarationSyntax ads)
{
if (!IncludesFNIAttribute(ads.AttributeLists)) return;
if (ads.ExpressionBody is not null) CheckExprBody(ads.ExpressionBody, ads.GetLocation());
else if (ads.Body is not null) CheckBlockBody(ads.Body, ads.GetLocation());
if (ads.ExpressionBody is not null) CheckExprBody(ads.ExpressionBody);
else if (ads.Body is not null) CheckBlockBody(ads.Body);
else HawkSourceAnalyzer.ReportWTF(ads, snac, message: ERR_MSG_UNEXPECTED_INCANTATION);
}
switch (snac.Node)
@ -69,14 +69,14 @@ public sealed class FeatureNotImplementedAnalyzer : DiagnosticAnalyzer
break;
case MethodDeclarationSyntax mds:
if (!IncludesFNIAttribute(mds.AttributeLists)) return;
if (mds.ExpressionBody is not null) CheckExprBody(mds.ExpressionBody, mds.GetLocation());
else if (mds.Body is not null) CheckBlockBody(mds.Body, mds.GetLocation());
if (mds.ExpressionBody is not null) CheckExprBody(mds.ExpressionBody);
else if (mds.Body is not null) CheckBlockBody(mds.Body);
else HawkSourceAnalyzer.ReportWTF(mds, snac, message: ERR_MSG_UNEXPECTED_INCANTATION);
break;
case PropertyDeclarationSyntax pds:
if (pds.ExpressionBody is not null)
{
if (IncludesFNIAttribute(pds.AttributeLists)) CheckExprBody(pds.ExpressionBody, pds.GetLocation());
if (IncludesFNIAttribute(pds.AttributeLists)) CheckExprBody(pds.ExpressionBody);
}
else
{

View File

@ -50,7 +50,7 @@ public sealed class UseNameofOperatorAnalyzer : DiagnosticAnalyzer
break;
case MemberAccessExpressionSyntax maes1:
var accessed = snac.SemanticModel.GetSymbolInfo(maes1.Name, snac.CancellationToken).Symbol;
if (memberInfoDotNameSym.Matches(accessed)) DiagUseNameof.ReportAt(maes1, snac, [ toes.Type.GetText() ]);
if (memberInfoDotNameSym.Matches(accessed)) DiagUseNameof.ReportAt(maes1, snac, toes.Type.GetText().ToString());
else if (typeDotToStringSym.Matches(accessed)) DiagNoToStringOnType.ReportAt(maes1, snac, [ toes.Type.GetText(), ".ToString()" ]);
break;
}