Skip to content

Commit

Permalink
Register operation actions separately.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlossanlop committed Jul 17, 2023
1 parent 372cbd1 commit bd55933
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,22 +203,22 @@ private void AnalyzeCompilationStart(CompilationStartAnalysisContext context)
return;
}

// a.ToLower().Method()
context.RegisterOperationAction(context =>
{
if (context.Operation is IInvocationOperation caseChangingInvocation)
{
AnalyzeInvocation(context, caseChangingInvocation, stringType,
containsStringMethod, startsWithStringMethod, compareToStringMethod,
indexOfStringMethod, indexOfStringInt32Method, indexOfStringInt32Int32Method);
}
else if (context.Operation is IBinaryOperation binaryOperation)
{
AnalyzeBinaryOperation(context, binaryOperation, stringType);
}
},
OperationKind.Invocation, // a.ToLower().Method()
OperationKind.Binary // a.ToLower() == b.ToLower()
);
IInvocationOperation caseChangingInvocation = (IInvocationOperation)context.Operation;
AnalyzeInvocation(context, caseChangingInvocation, stringType,
containsStringMethod, startsWithStringMethod, compareToStringMethod,
indexOfStringMethod, indexOfStringInt32Method, indexOfStringInt32Int32Method);
}, OperationKind.Invocation);

// a.ToLower() == b.ToLower()
context.RegisterOperationAction(context =>
{
IBinaryOperation binaryOperation = (IBinaryOperation)context.Operation;
AnalyzeBinaryOperation(context, binaryOperation, stringType);

}, OperationKind.Binary);
}

private static void AnalyzeInvocation(OperationAnalysisContext context, IInvocationOperation caseChangingInvocation, INamedTypeSymbol stringType,
Expand Down

0 comments on commit bd55933

Please sign in to comment.