提交 3335f003 编写于 作者: P Petr Houska

PR feedback cleenup.

上级 52115efa
......@@ -8,7 +8,12 @@
namespace Microsoft.CodeAnalysis.CSharp.CodeRefactorings
{
[ExportLanguageService(typeof(IRefactoringHelpersService), LanguageNames.CSharp), Shared]
internal class CSharpRefactoringHelpersService : AbstractRefactoringHelpersService<PropertyDeclarationSyntax, ParameterSyntax, MethodDeclarationSyntax, LocalDeclarationStatementSyntax, LocalFunctionStatementSyntax>
internal class CSharpRefactoringHelpersService : AbstractRefactoringHelpersService<
PropertyDeclarationSyntax,
ParameterSyntax,
MethodDeclarationSyntax,
LocalDeclarationStatementSyntax,
LocalFunctionStatementSyntax>
{
}
}
......@@ -362,10 +362,6 @@ protected virtual IEnumerable<SyntaxNode> DefaultNodesExtractor(SyntaxNode node,
foreach (var headerNode in ExtractNodesOfHeader(node, syntaxFacts))
{
yield return headerNode;
foreach (var extractedNode in ExtractNodesSimple(headerNode, syntaxFacts))
{
yield return extractedNode;
}
}
}
}
......@@ -403,7 +399,7 @@ protected virtual IEnumerable<SyntaxNode> ExtractNodesSimple(SyntaxNode node, IS
// var `a = b`;
// -> `var a = b`;
if (node.Parent != null && syntaxFacts.IsLocalDeclarationStatement(node.Parent))
if (syntaxFacts.IsLocalDeclarationStatement(node?.Parent))
{
// Check if there's only one variable being declared, otherwise following transformation
// would go through which isn't reasonable. If there's specifically selected just one,
......@@ -446,7 +442,7 @@ protected virtual IEnumerable<SyntaxNode> ExtractNodesOfHeader(SyntaxNode node,
}
// Header: `static C([Test]int a = 42)` {}
if (syntaxFacts.IsInLocalFunctionHeader(node, syntaxFacts))
if (syntaxFacts.IsInLocalFunctionHeader(node))
{
yield return node.GetAncestorOrThis<TLocalFunctionStatementSyntax>();
}
......
......@@ -1824,7 +1824,7 @@ public bool IsInMethodHeader(SyntaxNode node)
return IsInHeader(node, containingMethod, containingMethod.ParameterList);
}
public bool IsInLocalFunctionHeader(SyntaxNode node, ISyntaxFactsService syntaxFacts)
public bool IsInLocalFunctionHeader(SyntaxNode node)
{
var containingLocalFunction = node.GetAncestorOrThis<LocalFunctionStatementSyntax>();
if (containingLocalFunction == null)
......@@ -1832,7 +1832,7 @@ public bool IsInLocalFunctionHeader(SyntaxNode node, ISyntaxFactsService syntaxF
return false;
}
return syntaxFacts.IsInHeader(node, containingLocalFunction, containingLocalFunction.ParameterList);
return IsInHeader(node, containingLocalFunction, containingLocalFunction.ParameterList);
}
public bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position)
......
......@@ -416,7 +416,7 @@ internal interface ISyntaxFactsService : ILanguageService
bool IsInPropertyDeclarationHeader(SyntaxNode node);
bool IsInParameterHeader(SyntaxNode node);
bool IsInMethodHeader(SyntaxNode node);
bool IsInLocalFunctionHeader(SyntaxNode node, ISyntaxFactsService syntaxFacts);
bool IsInLocalFunctionHeader(SyntaxNode node);
bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position);
// Walks the tree, starting from contextNode, looking for the first construct
......
......@@ -1785,7 +1785,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return IsInHeader(node, method, method)
End Function
Public Function IsInLocalFunctionHeader(node As SyntaxNode, syntaxFacts As ISyntaxFactsService) As Boolean Implements ISyntaxFactsService.IsInLocalFunctionHeader
Public Function IsInLocalFunctionHeader(node As SyntaxNode) As Boolean Implements ISyntaxFactsService.IsInLocalFunctionHeader
' No local functions in VisualBasic
Return False
End Function
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册