Skip to content

Commit

Permalink
Replace SyntaxWalker with SafeSyntaxWalker (#6852)
Browse files Browse the repository at this point in the history
  • Loading branch information
zsolt-kolbay-sonarsource committed Mar 3, 2023
1 parent dffe8ff commit 0f74c56
Showing 1 changed file with 2 additions and 2 deletions.
Expand Up @@ -134,7 +134,7 @@ private static TypeDeclarationSyntax LowestCommonAncestorOrSelf(IEnumerable<Type
IEnumerable<MethodDeclarationSyntax> methods, TypeDeclarationSyntax outerType, SemanticModel model)
{
var collector = new PotentialMethodReferenceCollector(methods);
collector.Visit(outerType);
collector.SafeVisit(outerType);

return collector.PotentialMethodReferences
.Where(x => !OnlyUsedByOuterType(x))
Expand Down Expand Up @@ -181,7 +181,7 @@ private sealed record MethodUsedByTypes(MethodDeclarationSyntax Method, TypeDecl
/// Performance gains: by only using the syntax tree to find matches we can eliminate certain methods (which are only used by the type which has declared it)
/// without using the more costly symbolic lookup.
/// </summary>
private sealed class PotentialMethodReferenceCollector : CSharpSyntaxWalker
private sealed class PotentialMethodReferenceCollector : SafeCSharpSyntaxWalker
{
private readonly ISet<MethodDeclarationSyntax> methodsToFind;
private readonly Dictionary<MethodDeclarationSyntax, List<IdentifierNameSyntax>> potentialMethodReferences;
Expand Down

0 comments on commit 0f74c56

Please sign in to comment.