提交 a666d272 编写于 作者: J Jan Finkenzeller

Refactored AnstractRmoveUnusedVariableCodeFixProvider

上级 86b766f0
......@@ -47,9 +47,6 @@ protected override SyntaxNode GetNodeToRemoveOrReplace(SyntaxNode node)
return null;
}
protected override LocalDeclarationStatementSyntax GetCandidateLocalDeclarationForRemoval(VariableDeclaratorSyntax declarator)
=> declarator.Parent?.Parent as LocalDeclarationStatementSyntax;
protected override void RemoveOrReplaceNode(SyntaxEditor editor, SyntaxNode node, ISyntaxFactsService syntaxFacts)
{
switch (node.Kind())
......
......@@ -156,8 +156,8 @@ private void MergeNodesToRemove(HashSet<SyntaxNode> nodesToRemove)
{
// Parents of the variable declarator could be candaditaes for removal for example
// if all declarators in a declaration will be removed.
var candidate = GetCandidateLocalDeclarationForRemoval(variableDeclarator);
if (candidate != null)
if (variableDeclarator.Parent?.Parent is TLocalDeclarationStatement candidate)
{
candidateLocalDeclarationsToRemove.Add(candidate);
}
......@@ -186,8 +186,6 @@ private void MergeNodesToRemove(HashSet<SyntaxNode> nodesToRemove)
}
}
protected abstract TLocalDeclarationStatement GetCandidateLocalDeclarationForRemoval(TVariableDeclarator declarator);
private class MyCodeAction : CodeAction.DocumentChangeAction
{
public MyCodeAction(Func<CancellationToken, Task<Document>> createChangedDocument)
......
......@@ -41,9 +41,5 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.RemoveUnusedVariable
Protected Overrides Function GetVariables(localDeclarationStatement As LocalDeclarationStatementSyntax) As SeparatedSyntaxList(Of SyntaxNode)
Return localDeclarationStatement.Declarators
End Function
Protected Overrides Function GetCandidateLocalDeclarationForRemoval(declarator As ModifiedIdentifierSyntax) As LocalDeclarationStatementSyntax
Return Nothing
End Function
End Class
End Namespace
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册