提交 7c8ff856 编写于 作者: C Cyrus Najmabadi

NRT

上级 3b7b80b9
...@@ -284,7 +284,7 @@ private void SyntaxNodeAction(SyntaxNodeAnalysisContext syntaxContext) ...@@ -284,7 +284,7 @@ private void SyntaxNodeAction(SyntaxNodeAnalysisContext syntaxContext)
{ {
localSymbol = semanticModel.GetSymbolInfo(identifier).Symbol as ILocalSymbol; localSymbol = semanticModel.GetSymbolInfo(identifier).Symbol as ILocalSymbol;
declarator = localSymbol?.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax() as VariableDeclaratorSyntax; declarator = localSymbol?.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax() as VariableDeclaratorSyntax;
return declarator != null; return localSymbol != null && declarator != null;
} }
private static ExpressionSyntax? GetNullCheckOperand(ExpressionSyntax left, SyntaxKind comparisonKind, SyntaxNode right) private static ExpressionSyntax? GetNullCheckOperand(ExpressionSyntax left, SyntaxKind comparisonKind, SyntaxNode right)
......
...@@ -29,7 +29,7 @@ internal partial class CSharpParameterWrapper ...@@ -29,7 +29,7 @@ internal partial class CSharpParameterWrapper
protected override SeparatedSyntaxList<ParameterSyntax> GetListItems(BaseParameterListSyntax listSyntax) protected override SeparatedSyntaxList<ParameterSyntax> GetListItems(BaseParameterListSyntax listSyntax)
=> listSyntax.Parameters; => listSyntax.Parameters;
protected override BaseParameterListSyntax TryGetApplicableList(SyntaxNode node) protected override BaseParameterListSyntax? TryGetApplicableList(SyntaxNode node)
=> node.GetParameterList(); => node.GetParameterList();
protected override bool PositionIsApplicable( protected override bool PositionIsApplicable(
......
...@@ -2,12 +2,15 @@ ...@@ -2,12 +2,15 @@
// The .NET Foundation licenses this file to you under the MIT license. // The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
#nullable enable
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Microsoft.CodeAnalysis.Wrapping.SeparatedSyntaxList namespace Microsoft.CodeAnalysis.Wrapping.SeparatedSyntaxList
{ {
using Microsoft.CodeAnalysis.Indentation; using Microsoft.CodeAnalysis.Indentation;
using Microsoft.CodeAnalysis.Shared.Extensions;
/// <summary> /// <summary>
/// Base type for all wrappers that involve wrapping a comma-separated list of items. /// Base type for all wrappers that involve wrapping a comma-separated list of items.
...@@ -39,12 +42,12 @@ protected AbstractSeparatedSyntaxListWrapper(IIndentationService indentationServ ...@@ -39,12 +42,12 @@ protected AbstractSeparatedSyntaxListWrapper(IIndentationService indentationServ
{ {
} }
protected abstract TListSyntax TryGetApplicableList(SyntaxNode node); protected abstract TListSyntax? TryGetApplicableList(SyntaxNode node);
protected abstract SeparatedSyntaxList<TListItemSyntax> GetListItems(TListSyntax listSyntax); protected abstract SeparatedSyntaxList<TListItemSyntax> GetListItems(TListSyntax listSyntax);
protected abstract bool PositionIsApplicable( protected abstract bool PositionIsApplicable(
SyntaxNode root, int position, SyntaxNode declaration, TListSyntax listSyntax); SyntaxNode root, int position, SyntaxNode declaration, TListSyntax listSyntax);
public override async Task<ICodeActionComputer> TryCreateComputerAsync( public override async Task<ICodeActionComputer?> TryCreateComputerAsync(
Document document, int position, SyntaxNode declaration, CancellationToken cancellationToken) Document document, int position, SyntaxNode declaration, CancellationToken cancellationToken)
{ {
var listSyntax = TryGetApplicableList(declaration); var listSyntax = TryGetApplicableList(declaration);
...@@ -53,7 +56,7 @@ protected AbstractSeparatedSyntaxListWrapper(IIndentationService indentationServ ...@@ -53,7 +56,7 @@ protected AbstractSeparatedSyntaxListWrapper(IIndentationService indentationServ
return null; return null;
} }
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
if (!PositionIsApplicable(root, position, declaration, listSyntax)) if (!PositionIsApplicable(root, position, declaration, listSyntax))
{ {
return null; return null;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册