Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,12 @@ public RenameRewriter(RenameRewriterParameters parameters)

var isInConflictLambdaBody = false;
var lambdas = node.GetAncestorsOrThis(n => n is SimpleLambdaExpressionSyntax or ParenthesizedLambdaExpressionSyntax);
if (lambdas.Count() != 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YIKES

foreach (var lambda in lambdas)
{
foreach (var lambda in lambdas)
if (_conflictLocations.Any(cf => cf.Contains(lambda.Span)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no 'any' that takes an arg?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't one available, and the only current extension methods we have on ImmutableHashSet are in the compiler, and I didn't want to change that in this PR.

{
if (_conflictLocations.Any(cf => cf.Contains(lambda.Span)))
{
isInConflictLambdaBody = true;
break;
}
isInConflictLambdaBody = true;
break;
}
}

Expand Down Expand Up @@ -298,7 +295,7 @@ private SyntaxNode Complexify(SyntaxNode originalNode, SyntaxNode newNode)
RoslynDebug.Assert(_speculativeModel != null, "expanding a syntax node which cannot be speculated?");

var oldSpan = originalNode.Span;
var expandParameter = originalNode.GetAncestorsOrThis(n => n is SimpleLambdaExpressionSyntax or ParenthesizedLambdaExpressionSyntax).Count() == 0;
var expandParameter = !originalNode.GetAncestorsOrThis(n => n is SimpleLambdaExpressionSyntax or ParenthesizedLambdaExpressionSyntax).Any();

newNode = _simplificationService.Expand(newNode,
_speculativeModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,13 @@ private static bool IsConflictFreeChange(
private IEnumerable<(SyntaxNodeOrToken syntax, RenameActionAnnotation annotation)> GetNodesOrTokensToCheckForConflicts(
SyntaxNode syntaxRoot)
{
return syntaxRoot.DescendantNodesAndTokens(descendIntoTrivia: true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YIKES

.Where(_renameAnnotations.HasAnnotations<RenameActionAnnotation>)
.Select(s => (s, _renameAnnotations.GetAnnotations<RenameActionAnnotation>(s).Single()));
foreach (var nodeOrToken in syntaxRoot.GetAnnotatedNodesAndTokens(RenameAnnotation.Kind))
{
var annotation = _renameAnnotations.GetAnnotations<RenameActionAnnotation>(nodeOrToken).FirstOrDefault();

if (annotation != null)
yield return (nodeOrToken, annotation);
}
}

private async Task<bool> CheckForConflictAsync(
Expand Down