提交 06f91f3b 编写于 作者: J Jared Parsons

PR feedback

上级 4cfa2a16
......@@ -291,27 +291,27 @@ protected override SyntaxNode FindStatementAndPartner(SyntaxNode declarationBody
position = declarationBody.SpanStart;
}
SyntaxNode? node;
SyntaxNode node;
if (partnerDeclarationBody != null)
{
SyntaxUtilities.FindLeafNodeAndPartner(declarationBody, position, partnerDeclarationBody, out node, out partner);
}
else
{
node = declarationBody.FindToken(position).Parent;
node = declarationBody.FindToken(position).Parent!;
partner = null;
}
while (node != declarationBody && !StatementSyntaxComparer.HasLabel(node!) && !LambdaUtilities.IsLambdaBodyStatementOrExpression(node))
while (node != declarationBody && !StatementSyntaxComparer.HasLabel(node) && !LambdaUtilities.IsLambdaBodyStatementOrExpression(node))
{
node = node!.Parent;
node = node.Parent!;
if (partner != null)
{
partner = partner.Parent;
}
}
switch (node!.Kind())
switch (node.Kind())
{
case SyntaxKind.Block:
statementPart = (int)GetStatementPart((BlockSyntax)node!, position);
......@@ -3218,7 +3218,7 @@ private static SyntaxNode FindContainingStatementPart(SyntaxNode node)
RoslynDebug.Assert(node is object);
RoslynDebug.Assert(node.Parent is object);
switch (node.Parent!.Kind())
switch (node.Parent.Kind())
{
case SyntaxKind.ForStatement:
case SyntaxKind.ForEachStatement:
......
......@@ -1955,19 +1955,20 @@ private static int IndexOfEquivalent<TSyntaxNode>(SyntaxNode newNode, List<Synta
return -1;
}
private static List<SyntaxNode?>? GetAncestors(SyntaxNode? root, SyntaxNode? node, Func<SyntaxNode, bool> nodeSelector)
private static List<SyntaxNode?>? GetAncestors(SyntaxNode? root, SyntaxNode node, Func<SyntaxNode, bool> nodeSelector)
{
List<SyntaxNode?>? list = null;
SyntaxNode? current = node;
while (node is object && node != root)
while (current is object && current != root)
{
if (nodeSelector(node))
if (nodeSelector(current))
{
list ??= new List<SyntaxNode?>();
list.Add(node);
list.Add(current);
}
node = node.Parent;
current = current.Parent;
}
list?.Reverse();
......
......@@ -27,7 +27,7 @@ public static bool CanSafelyMoveLocalToBlock(this ILocalSymbol localSymbol, Synt
return true;
bool HasTypeParameterWithName(SyntaxNode? node, string name)
static bool HasTypeParameterWithName(SyntaxNode? node, string name)
{
SeparatedSyntaxList<TypeParameterSyntax>? typeParameters;
switch (node)
......
......@@ -169,12 +169,7 @@ private void GetContainers(SyntaxNode root, SyntaxNode contextLocation, out Synt
{
var usingDirective = contextNode.GetAncestor<TUsingOrAliasSyntax>();
SyntaxNode? node = contextNode;
if (usingDirective != null)
{
node = usingDirective.Parent!;
}
SyntaxNode? node = usingDirective != null ? usingDirective.Parent! : contextNode;
return node.GetAncestor<TNamespaceDeclarationSyntax>() ??
(SyntaxNode?)node.GetAncestorOrThis<TCompilationUnitSyntax>();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册