提交 c2ebd055 编写于 作者: A Andrew Hall (METAL)

Change ignoreChildNode to fast pass on AreNullableDirectivesEquivalent. Fix...

Change ignoreChildNode to fast pass on AreNullableDirectivesEquivalent. Fix comparison of imports to ignore nullable trivia
上级 29028223
......@@ -218,6 +218,12 @@ private static bool AreEquivalentRecursive(GreenNode before, GreenNode after, Fu
private static bool AreNullableDirectivesEquivalent(GreenNode before, GreenNode after, Func<SyntaxKind, bool> ignoreChildNode)
{
// Fast path for when the caller does not care about nullable directives. This can happen in some IDE refactorings.
if (ignoreChildNode is object && ignoreChildNode(SyntaxKind.NullableDirectiveTrivia))
{
return true;
}
using var beforeDirectivesEnumerator = ((Green.CSharpSyntaxNode)before).GetDirectives().GetEnumerator();
using var afterDirectivesEnumerator = ((Green.CSharpSyntaxNode)after).GetDirectives().GetEnumerator();
while (true)
......@@ -240,8 +246,7 @@ static Green.DirectiveTriviaSyntax getNextNullableDirective(IEnumerator<Green.Di
while (enumerator.MoveNext())
{
var current = enumerator.Current;
if (current.Kind == SyntaxKind.NullableDirectiveTrivia &&
(ignoreChildNode is null || !ignoreChildNode(current.Kind)))
if (current.Kind == SyntaxKind.NullableDirectiveTrivia)
{
return current;
}
......
......@@ -72,7 +72,7 @@ protected override SyntaxList<ExternAliasDirectiveSyntax> GetExterns(SyntaxNode
protected override bool IsEquivalentImport(SyntaxNode a, SyntaxNode b)
{
return a.IsEquivalentTo(b, topLevel: false);
return SyntaxFactory.AreEquivalent(a, b, kind => kind == SyntaxKind.NullableDirectiveTrivia);
}
private class Rewriter : CSharpSyntaxRewriter
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册