提交 73a80651 编写于 作者: C Cyrus Najmabadi

Remove unnecessary 'this' expressions

上级 5d72eb34
......@@ -66,7 +66,7 @@ protected override IndexerDeclarationSyntax WithGenerateBody(SemanticModel seman
out ArrowExpressionClauseSyntax arrowExpression,
out SyntaxToken semicolonToken)
{
return this.TryConvertToExpressionBodyForBaseProperty(
return TryConvertToExpressionBodyForBaseProperty(
declaration, options, conversionPreference,
out arrowExpression, out semicolonToken);
}
......
......@@ -66,7 +66,7 @@ protected override PropertyDeclarationSyntax WithGenerateBody(SemanticModel sema
out ArrowExpressionClauseSyntax arrowExpression,
out SyntaxToken semicolonToken)
{
return this.TryConvertToExpressionBodyForBaseProperty(
return TryConvertToExpressionBodyForBaseProperty(
declaration, options, conversionPreference,
out arrowExpression, out semicolonToken);
}
......
......@@ -80,7 +80,7 @@ public override Location GetDiagnosticLocation(SyntaxNode declaration)
=> GetDiagnosticLocation((TDeclaration)declaration);
protected virtual Location GetDiagnosticLocation(TDeclaration declaration)
=> this.GetBody(declaration).Statements[0].GetLocation();
=> GetBody(declaration).Statements[0].GetLocation();
public bool CanOfferUseExpressionBody(
OptionSet optionSet, TDeclaration declaration, bool forAnalyzer)
......@@ -95,7 +95,7 @@ protected virtual Location GetDiagnosticLocation(TDeclaration declaration)
// If the analyzer is disabled completely, the refactoring is enabled in both directions.
if (userPrefersExpressionBodies == forAnalyzer || (!forAnalyzer && analyzerDisabled))
{
var expressionBody = this.GetExpressionBody(declaration);
var expressionBody = GetExpressionBody(declaration);
if (expressionBody == null)
{
// They don't have an expression body. See if we could convert the block they
......@@ -127,7 +127,7 @@ protected virtual Location GetDiagnosticLocation(TDeclaration declaration)
SyntaxNode declaration, ParseOptions options, ExpressionBodyPreference conversionPreference,
out ArrowExpressionClauseSyntax expressionWhenOnSingleLine, out SyntaxToken semicolonWhenOnSingleLine)
{
var body = this.GetBody(declaration);
var body = GetBody(declaration);
return body.TryConvertToArrowExpressionBody(
declaration.Kind(), options, conversionPreference,
......@@ -140,7 +140,7 @@ protected virtual Location GetDiagnosticLocation(TDeclaration declaration)
out ArrowExpressionClauseSyntax arrowExpression,
out SyntaxToken semicolonToken)
{
if (this.TryConvertToExpressionBodyWorker(
if (TryConvertToExpressionBodyWorker(
declaration, options, conversionPreference,
out arrowExpression, out semicolonToken))
{
......@@ -167,7 +167,7 @@ protected virtual Location GetDiagnosticLocation(TDeclaration declaration)
var userPrefersBlockBodies = preference == ExpressionBodyPreference.Never;
var analyzerDisabled = currentOptionValue.Notification.Severity == ReportDiagnostic.Suppress;
var expressionBodyOpt = this.GetExpressionBody(declaration);
var expressionBodyOpt = GetExpressionBody(declaration);
var canOffer = expressionBodyOpt?.TryConvertToBlock(
SyntaxFactory.Token(SyntaxKind.SemicolonToken), false, block: out _) == true;
if (!canOffer)
......
......@@ -110,7 +110,7 @@ private class MyCodeAction : CustomCodeActions.DocumentChangeAction
CodeActionPriority priority)
: base(title, createChangedDocument, title)
{
this.Priority = priority;
Priority = priority;
}
internal override CodeActionPriority Priority { get; }
......
......@@ -115,7 +115,7 @@ public MyCodeAction(string title, Func<CancellationToken, Task<Document>> create
public MyCodeAction(string title, CodeActionPriority priority, Func<CancellationToken, Task<Document>> createChangedDocument)
: base(title, createChangedDocument)
{
this.Priority = priority;
Priority = priority;
}
#endif
}
......
......@@ -84,7 +84,7 @@ public override SyntaxNode VisitAnonymousObjectMemberDeclarator(AnonymousObjectM
// Should become:
// var a = new { x = 42; };
nameEquals = SyntaxFactory.NameEquals(identifier);
expression = (ExpressionSyntax)this.Visit(expression);
expression = (ExpressionSyntax)Visit(expression);
return node.Update(nameEquals, expression).WithAdditionalAnnotations(Simplifier.Annotation, Formatter.Annotation);
}
......
......@@ -88,7 +88,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
context.RegisterRefactoring(
new MyCodeAction(
CSharpFeaturesResources.Inline_temporary_variable,
c => this.InlineTemporaryAsync(document, variableDeclarator, c)),
c => InlineTemporaryAsync(document, variableDeclarator, c)),
variableDeclarator.Span);
}
......
......@@ -22,7 +22,7 @@ internal abstract class AbstractSpecialTypePreselectingKeywordRecommender : Abst
protected override bool ShouldPreselect(CSharpSyntaxContext context, CancellationToken cancellationToken)
{
return context.InferredTypes.Any(t => t.SpecialType == this.SpecialType);
return context.InferredTypes.Any(t => t.SpecialType == SpecialType);
}
}
}
......@@ -25,9 +25,9 @@ internal abstract partial class AbstractSyntacticSingleKeywordRecommender : IKey
bool isValidInPreprocessorContext = false,
bool shouldFormatOnCommit = false)
{
this.KeywordKind = keywordKind;
KeywordKind = keywordKind;
_isValidInPreprocessorContext = isValidInPreprocessorContext;
this.ShouldFormatOnCommit = shouldFormatOnCommit;
ShouldFormatOnCommit = shouldFormatOnCommit;
}
protected virtual Task<bool> IsValidContextAsync(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
......@@ -42,12 +42,12 @@ protected virtual Task<bool> IsValidContextAsync(int position, CSharpSyntaxConte
CSharpSyntaxContext context,
CancellationToken cancellationToken)
{
var syntaxKind = await this.RecommendKeywordAsync(position, context, cancellationToken).ConfigureAwait(false);
var syntaxKind = await RecommendKeywordAsync(position, context, cancellationToken).ConfigureAwait(false);
if (syntaxKind.HasValue)
{
return SpecializedCollections.SingletonEnumerable(
new RecommendedKeyword(SyntaxFacts.GetText(syntaxKind.Value),
shouldFormatOnCommit: this.ShouldFormatOnCommit,
shouldFormatOnCommit: ShouldFormatOnCommit,
matchPriority: ShouldPreselect(context, cancellationToken) ? SymbolMatchPriority.Keyword : MatchPriority.Default));
}
......@@ -72,7 +72,7 @@ protected virtual Task<bool> IsValidContextAsync(int position, CSharpSyntaxConte
return null;
}
return this.KeywordKind;
return KeywordKind;
}
internal TestAccessor GetTestAccessor()
......
......@@ -94,7 +94,7 @@ private Task<Document> ConvertToRegularStringAsync(Document document, TStringExp
protected void AddVerbatimStringText(
IVirtualCharService charService, StringBuilder sb, SyntaxToken stringToken)
{
var isInterpolation = this.IsInterpolation;
var isInterpolation = IsInterpolation;
var chars = charService.TryConvertToVirtualChars(stringToken);
foreach (var vc in chars)
......@@ -128,7 +128,7 @@ private static bool IsOpenOrCloseBrace(char ch)
protected void AddRegularStringText(
IVirtualCharService charService, StringBuilder sb, SyntaxToken stringToken)
{
var isInterpolation = this.IsInterpolation;
var isInterpolation = IsInterpolation;
var chars = charService.TryConvertToVirtualChars(stringToken);
foreach (var vc in chars)
......
......@@ -48,7 +48,7 @@ protected override bool HasMethodBody(IMethodSymbol method, CancellationToken ca
out IList<NameAndArity> nameParts,
out int? parameterCount)
{
var text = this.Text;
var text = Text;
Debug.Assert(text != null);
......
......@@ -92,7 +92,7 @@ protected override int GetIndexOfVariableInfoToUseAsReturnValue(IList<VariableIn
protected override ITypeSymbol GetRangeVariableType(SemanticModel model, IRangeVariableSymbol symbol)
{
var info = model.GetSpeculativeTypeInfo(this.SelectionResult.FinalSpan.Start, SyntaxFactory.ParseName(symbol.Name), SpeculativeBindingOption.BindAsExpression);
var info = model.GetSpeculativeTypeInfo(SelectionResult.FinalSpan.Start, SyntaxFactory.ParseName(symbol.Name), SpeculativeBindingOption.BindAsExpression);
if (Microsoft.CodeAnalysis.Shared.Extensions.ISymbolExtensions.IsErrorType(info.Type))
{
return null;
......@@ -105,7 +105,7 @@ protected override ITypeSymbol GetRangeVariableType(SemanticModel model, IRangeV
protected override Tuple<SyntaxNode, SyntaxNode> GetFlowAnalysisNodeRange()
{
var csharpSelectionResult = this.SelectionResult as CSharpSelectionResult;
var csharpSelectionResult = SelectionResult as CSharpSelectionResult;
var first = csharpSelectionResult.GetFirstStatement();
var last = csharpSelectionResult.GetLastStatement();
......@@ -130,13 +130,13 @@ protected override bool ContainsReturnStatementInSelectedCode(IEnumerable<Syntax
protected override bool ReadOnlyFieldAllowed()
{
var scope = this.SelectionResult.GetContainingScopeOf<ConstructorDeclarationSyntax>();
var scope = SelectionResult.GetContainingScopeOf<ConstructorDeclarationSyntax>();
return scope == null;
}
protected override ITypeSymbol GetSymbolType(SemanticModel semanticModel, ISymbol symbol)
{
var selectionOperation = semanticModel.GetOperation(this.SelectionResult.GetContainingScope());
var selectionOperation = semanticModel.GetOperation(SelectionResult.GetContainingScope());
switch (symbol)
{
......
......@@ -125,7 +125,7 @@ public override SyntaxNode VisitLocalDeclarationStatement(LocalDeclarationStatem
// for every kind of extract methods
public override SyntaxNode VisitBlock(BlockSyntax node)
{
if (node != this.ContainerOfStatementsOrFieldToReplace)
if (node != ContainerOfStatementsOrFieldToReplace)
{
// make sure we visit nodes under the block
return base.VisitBlock(node);
......@@ -136,7 +136,7 @@ public override SyntaxNode VisitBlock(BlockSyntax node)
public override SyntaxNode VisitSwitchSection(SwitchSectionSyntax node)
{
if (node != this.ContainerOfStatementsOrFieldToReplace)
if (node != ContainerOfStatementsOrFieldToReplace)
{
// make sure we visit nodes under the switch section
return base.VisitSwitchSection(node);
......@@ -148,7 +148,7 @@ public override SyntaxNode VisitSwitchSection(SwitchSectionSyntax node)
// only for single statement or expression
public override SyntaxNode VisitLabeledStatement(LabeledStatementSyntax node)
{
if (node != this.ContainerOfStatementsOrFieldToReplace)
if (node != ContainerOfStatementsOrFieldToReplace)
{
return base.VisitLabeledStatement(node);
}
......@@ -158,7 +158,7 @@ public override SyntaxNode VisitLabeledStatement(LabeledStatementSyntax node)
public override SyntaxNode VisitElseClause(ElseClauseSyntax node)
{
if (node != this.ContainerOfStatementsOrFieldToReplace)
if (node != ContainerOfStatementsOrFieldToReplace)
{
return base.VisitElseClause(node);
}
......@@ -168,7 +168,7 @@ public override SyntaxNode VisitElseClause(ElseClauseSyntax node)
public override SyntaxNode VisitIfStatement(IfStatementSyntax node)
{
if (node != this.ContainerOfStatementsOrFieldToReplace)
if (node != ContainerOfStatementsOrFieldToReplace)
{
return base.VisitIfStatement(node);
}
......@@ -180,7 +180,7 @@ public override SyntaxNode VisitIfStatement(IfStatementSyntax node)
public override SyntaxNode VisitLockStatement(LockStatementSyntax node)
{
if (node != this.ContainerOfStatementsOrFieldToReplace)
if (node != ContainerOfStatementsOrFieldToReplace)
{
return base.VisitLockStatement(node);
}
......@@ -191,7 +191,7 @@ public override SyntaxNode VisitLockStatement(LockStatementSyntax node)
public override SyntaxNode VisitFixedStatement(FixedStatementSyntax node)
{
if (node != this.ContainerOfStatementsOrFieldToReplace)
if (node != ContainerOfStatementsOrFieldToReplace)
{
return base.VisitFixedStatement(node);
}
......@@ -202,7 +202,7 @@ public override SyntaxNode VisitFixedStatement(FixedStatementSyntax node)
public override SyntaxNode VisitUsingStatement(UsingStatementSyntax node)
{
if (node != this.ContainerOfStatementsOrFieldToReplace)
if (node != ContainerOfStatementsOrFieldToReplace)
{
return base.VisitUsingStatement(node);
}
......@@ -214,7 +214,7 @@ public override SyntaxNode VisitUsingStatement(UsingStatementSyntax node)
public override SyntaxNode VisitForEachStatement(ForEachStatementSyntax node)
{
if (node != this.ContainerOfStatementsOrFieldToReplace)
if (node != ContainerOfStatementsOrFieldToReplace)
{
return base.VisitForEachStatement(node);
}
......@@ -225,7 +225,7 @@ public override SyntaxNode VisitForEachStatement(ForEachStatementSyntax node)
public override SyntaxNode VisitForEachVariableStatement(ForEachVariableStatementSyntax node)
{
if (node != this.ContainerOfStatementsOrFieldToReplace)
if (node != ContainerOfStatementsOrFieldToReplace)
{
return base.VisitForEachVariableStatement(node);
}
......@@ -236,7 +236,7 @@ public override SyntaxNode VisitForEachVariableStatement(ForEachVariableStatemen
public override SyntaxNode VisitForStatement(ForStatementSyntax node)
{
if (node != this.ContainerOfStatementsOrFieldToReplace)
if (node != ContainerOfStatementsOrFieldToReplace)
{
return base.VisitForStatement(node);
}
......@@ -250,7 +250,7 @@ public override SyntaxNode VisitForStatement(ForStatementSyntax node)
public override SyntaxNode VisitDoStatement(DoStatementSyntax node)
{
if (node != this.ContainerOfStatementsOrFieldToReplace)
if (node != ContainerOfStatementsOrFieldToReplace)
{
return base.VisitDoStatement(node);
}
......@@ -261,7 +261,7 @@ public override SyntaxNode VisitDoStatement(DoStatementSyntax node)
public override SyntaxNode VisitWhileStatement(WhileStatementSyntax node)
{
if (node != this.ContainerOfStatementsOrFieldToReplace)
if (node != ContainerOfStatementsOrFieldToReplace)
{
return base.VisitWhileStatement(node);
}
......@@ -349,7 +349,7 @@ private SyntaxList<MemberDeclarationSyntax> ReplaceMembers(SyntaxList<MemberDecl
public override SyntaxNode VisitGlobalStatement(GlobalStatementSyntax node)
{
if (node != this.ContainerOfStatementsOrFieldToReplace)
if (node != ContainerOfStatementsOrFieldToReplace)
{
return base.VisitGlobalStatement(node);
}
......@@ -359,7 +359,7 @@ public override SyntaxNode VisitGlobalStatement(GlobalStatementSyntax node)
public override SyntaxNode VisitConstructorDeclaration(ConstructorDeclarationSyntax node)
{
if (node != this.ContainerOfStatementsOrFieldToReplace)
if (node != ContainerOfStatementsOrFieldToReplace)
{
return base.VisitConstructorDeclaration(node);
}
......@@ -370,7 +370,7 @@ public override SyntaxNode VisitConstructorDeclaration(ConstructorDeclarationSyn
public override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node)
{
if (node != this.ContainerOfStatementsOrFieldToReplace)
if (node != ContainerOfStatementsOrFieldToReplace)
{
return base.VisitClassDeclaration(node);
}
......@@ -381,7 +381,7 @@ public override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node)
public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax node)
{
if (node != this.ContainerOfStatementsOrFieldToReplace)
if (node != ContainerOfStatementsOrFieldToReplace)
{
return base.VisitStructDeclaration(node);
}
......@@ -392,7 +392,7 @@ public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax node)
public override SyntaxNode VisitAccessorList(AccessorListSyntax node)
{
if (node != this.ContainerOfStatementsOrFieldToReplace)
if (node != ContainerOfStatementsOrFieldToReplace)
{
return base.VisitAccessorList(node);
}
......@@ -403,7 +403,7 @@ public override SyntaxNode VisitAccessorList(AccessorListSyntax node)
public override SyntaxNode VisitCompilationUnit(CompilationUnitSyntax node)
{
if (node != this.ContainerOfStatementsOrFieldToReplace.Parent)
if (node != ContainerOfStatementsOrFieldToReplace.Parent)
{
// make sure we visit nodes under the block
return base.VisitCompilationUnit(node);
......
......@@ -44,11 +44,11 @@ protected override SyntaxToken CreateMethodName()
{
var methodName = GenerateMethodNameFromUserPreference();
var containingScope = this.CSharpSelectionResult.GetContainingScope();
var containingScope = CSharpSelectionResult.GetContainingScope();
methodName = GetMethodNameBasedOnExpression(methodName, containingScope);
var semanticModel = this.SemanticDocument.SemanticModel;
var semanticModel = SemanticDocument.SemanticModel;
var nameGenerator = new UniqueNameGenerator(semanticModel);
return SyntaxFactory.Identifier(nameGenerator.CreateUniqueMethodName(containingScope, methodName));
}
......@@ -99,13 +99,13 @@ private string GetMethodNameBasedOnExpression(string methodName, SyntaxNode expr
protected override IEnumerable<StatementSyntax> GetInitialStatementsForMethodDefinitions()
{
Contract.ThrowIfFalse(IsExtractMethodOnExpression(this.CSharpSelectionResult));
Contract.ThrowIfFalse(IsExtractMethodOnExpression(CSharpSelectionResult));
ExpressionSyntax expression = null;
// special case for array initializer
var returnType = this.AnalyzerResult.ReturnType;
var containingScope = this.CSharpSelectionResult.GetContainingScope();
var returnType = AnalyzerResult.ReturnType;
var containingScope = CSharpSelectionResult.GetContainingScope();
if (returnType.TypeKind == TypeKind.Array && containingScope is InitializerExpressionSyntax)
{
......@@ -118,7 +118,7 @@ protected override IEnumerable<StatementSyntax> GetInitialStatementsForMethodDef
expression = containingScope as ExpressionSyntax;
}
if (this.AnalyzerResult.HasReturnType)
if (AnalyzerResult.HasReturnType)
{
return SpecializedCollections.SingletonEnumerable<StatementSyntax>(
SyntaxFactory.ReturnStatement(
......@@ -134,7 +134,7 @@ protected override IEnumerable<StatementSyntax> GetInitialStatementsForMethodDef
private ExpressionSyntax WrapInCheckedExpressionIfNeeded(ExpressionSyntax expression)
{
var kind = this.CSharpSelectionResult.UnderCheckedExpressionContext();
var kind = CSharpSelectionResult.UnderCheckedExpressionContext();
if (kind == SyntaxKind.None)
{
return expression;
......@@ -158,7 +158,7 @@ protected override SyntaxNode GetOutermostCallSiteContainerToProcess(Cancellatio
private SyntaxNode GetCallSiteContainerFromExpression()
{
var container = this.CSharpSelectionResult.GetInnermostStatementContainer();
var container = CSharpSelectionResult.GetInnermostStatementContainer();
Contract.ThrowIfNull(container);
Contract.ThrowIfFalse(container.IsStatementContainerNode() ||
......@@ -171,22 +171,22 @@ private SyntaxNode GetCallSiteContainerFromExpression()
protected override SyntaxNode GetFirstStatementOrInitializerSelectedAtCallSite()
{
var scope = (SyntaxNode)this.CSharpSelectionResult.GetContainingScopeOf<StatementSyntax>();
var scope = (SyntaxNode)CSharpSelectionResult.GetContainingScopeOf<StatementSyntax>();
if (scope == null)
{
scope = this.CSharpSelectionResult.GetContainingScopeOf<FieldDeclarationSyntax>();
scope = CSharpSelectionResult.GetContainingScopeOf<FieldDeclarationSyntax>();
}
if (scope == null)
{
scope = this.CSharpSelectionResult.GetContainingScopeOf<ConstructorInitializerSyntax>();
scope = CSharpSelectionResult.GetContainingScopeOf<ConstructorInitializerSyntax>();
}
if (scope == null)
{
// This is similar to FieldDeclaration case but we only want to do this
// if the member has an expression body.
scope = this.CSharpSelectionResult.GetContainingScopeOf<ArrowExpressionClauseSyntax>().Parent;
scope = CSharpSelectionResult.GetContainingScopeOf<ArrowExpressionClauseSyntax>().Parent;
}
return scope;
......@@ -202,7 +202,7 @@ protected override SyntaxNode GetLastStatementOrInitializerSelectedAtCallSite()
var callSignature = CreateCallSignature().WithAdditionalAnnotations(callSiteAnnotation);
var invocation = callSignature.IsKind(SyntaxKind.AwaitExpression, out AwaitExpressionSyntax awaitExpr) ? awaitExpr.Expression : callSignature;
var sourceNode = this.CSharpSelectionResult.GetContainingScope();
var sourceNode = CSharpSelectionResult.GetContainingScope();
Contract.ThrowIfTrue(
sourceNode.Parent is MemberAccessExpressionSyntax && ((MemberAccessExpressionSyntax)sourceNode.Parent).Name == sourceNode,
"invalid scope. given scope is not an expression");
......@@ -211,7 +211,7 @@ protected override SyntaxNode GetLastStatementOrInitializerSelectedAtCallSite()
// code, we make the enclosing statement semantically explicit. This ends up being a little
// bit more work because we need to annotate the sourceNode so that we can get back to it
// after rewriting the enclosing statement.
var updatedDocument = this.SemanticDocument.Document;
var updatedDocument = SemanticDocument.Document;
var sourceNodeAnnotation = new SyntaxAnnotation();
var enclosingStatementAnnotation = new SyntaxAnnotation();
var newEnclosingStatement = enclosingStatement
......
......@@ -50,8 +50,8 @@ public static bool IsExtractMethodOnMultipleStatements(SelectionResult code)
protected override IEnumerable<StatementSyntax> GetInitialStatementsForMethodDefinitions()
{
var firstSeen = false;
var firstStatementUnderContainer = this.CSharpSelectionResult.GetFirstStatementUnderContainer();
var lastStatementUnderContainer = this.CSharpSelectionResult.GetLastStatementUnderContainer();
var firstStatementUnderContainer = CSharpSelectionResult.GetFirstStatementUnderContainer();
var lastStatementUnderContainer = CSharpSelectionResult.GetLastStatementUnderContainer();
var list = new List<StatementSyntax>();
foreach (var statement in GetStatementsFromContainer(firstStatementUnderContainer.Parent))
......@@ -89,7 +89,7 @@ protected override SyntaxNode GetOutermostCallSiteContainerToProcess(Cancellatio
}
else
{
var firstStatement = this.CSharpSelectionResult.GetFirstStatementUnderContainer();
var firstStatement = CSharpSelectionResult.GetFirstStatementUnderContainer();
return firstStatement.Parent;
}
}
......@@ -109,12 +109,12 @@ private SyntaxList<StatementSyntax> GetStatementsFromContainer(SyntaxNode node)
protected override SyntaxNode GetFirstStatementOrInitializerSelectedAtCallSite()
{
return this.CSharpSelectionResult.GetFirstStatementUnderContainer();
return CSharpSelectionResult.GetFirstStatementUnderContainer();
}
protected override SyntaxNode GetLastStatementOrInitializerSelectedAtCallSite()
{
return this.CSharpSelectionResult.GetLastStatementUnderContainer();
return CSharpSelectionResult.GetLastStatementUnderContainer();
}
protected override Task<SyntaxNode> GetStatementOrInitializerContainingInvocationToExtractedMethodAsync(
......
......@@ -41,9 +41,9 @@ public static bool IsExtractMethodOnSingleStatement(SelectionResult code)
protected override IEnumerable<StatementSyntax> GetInitialStatementsForMethodDefinitions()
{
Contract.ThrowIfFalse(IsExtractMethodOnSingleStatement(this.CSharpSelectionResult));
Contract.ThrowIfFalse(IsExtractMethodOnSingleStatement(CSharpSelectionResult));
return SpecializedCollections.SingletonEnumerable<StatementSyntax>(this.CSharpSelectionResult.GetFirstStatement());
return SpecializedCollections.SingletonEnumerable<StatementSyntax>(CSharpSelectionResult.GetFirstStatement());
}
protected override SyntaxNode GetOutermostCallSiteContainerToProcess(CancellationToken cancellationToken)
......@@ -55,21 +55,21 @@ protected override SyntaxNode GetOutermostCallSiteContainerToProcess(Cancellatio
}
else
{
var firstStatement = this.CSharpSelectionResult.GetFirstStatement();
var firstStatement = CSharpSelectionResult.GetFirstStatement();
return firstStatement.Parent;
}
}
protected override SyntaxNode GetFirstStatementOrInitializerSelectedAtCallSite()
{
return this.CSharpSelectionResult.GetFirstStatement();
return CSharpSelectionResult.GetFirstStatement();
}
protected override SyntaxNode GetLastStatementOrInitializerSelectedAtCallSite()
{
// it is a single statement case. either first statement is same as last statement or
// last statement belongs (embedded statement) to the first statement.
return this.CSharpSelectionResult.GetFirstStatement();
return CSharpSelectionResult.GetFirstStatement();
}
protected override Task<SyntaxNode> GetStatementOrInitializerContainingInvocationToExtractedMethodAsync(
......
......@@ -81,20 +81,20 @@ private abstract partial class CSharpCodeGenerator : CodeGenerator<StatementSynt
bool localFunction)
: base(insertionPoint, selectionResult, analyzerResult, options, localFunction)
{
Contract.ThrowIfFalse(this.SemanticDocument == selectionResult.SemanticDocument);
Contract.ThrowIfFalse(SemanticDocument == selectionResult.SemanticDocument);
var nameToken = CreateMethodName();
_methodName = nameToken.WithAdditionalAnnotations(this.MethodNameAnnotation);
_methodName = nameToken.WithAdditionalAnnotations(MethodNameAnnotation);
}
private CSharpSelectionResult CSharpSelectionResult
{
get { return (CSharpSelectionResult)this.SelectionResult; }
get { return (CSharpSelectionResult)SelectionResult; }
}
protected override SyntaxNode GetPreviousMember(SemanticDocument document)
{
var node = this.InsertionPoint.With(document).GetContext();
var node = InsertionPoint.With(document).GetContext();
return (node.Parent is GlobalStatementSyntax) ? node.Parent : node;
}
......@@ -106,7 +106,7 @@ protected override OperationStatus<IMethodSymbol> GenerateMethodDefinition(bool
attributes: ImmutableArray<AttributeData>.Empty,
accessibility: Accessibility.Private,
modifiers: CreateMethodModifiers(),
returnType: this.AnalyzerResult.ReturnType,
returnType: AnalyzerResult.ReturnType,
refKind: RefKind.None,
explicitInterfaceImplementations: default,
name: _methodName.ToString(),
......@@ -116,15 +116,15 @@ protected override OperationStatus<IMethodSymbol> GenerateMethodDefinition(bool
methodKind: localFunction ? MethodKind.LocalFunction : MethodKind.Ordinary);
return result.With(
this.MethodDefinitionAnnotation.AddAnnotationToSymbol(
MethodDefinitionAnnotation.AddAnnotationToSymbol(
Formatter.Annotation.AddAnnotationToSymbol(methodSymbol)));
}
protected override async Task<SyntaxNode> GenerateBodyForCallSiteContainerAsync(CancellationToken cancellationToken)
{
var container = this.GetOutermostCallSiteContainerToProcess(cancellationToken);
var container = GetOutermostCallSiteContainerToProcess(cancellationToken);
var variableMapToRemove = CreateVariableDeclarationToRemoveMap(
this.AnalyzerResult.GetVariablesToMoveIntoMethodDefinition(cancellationToken), cancellationToken);
AnalyzerResult.GetVariablesToMoveIntoMethodDefinition(cancellationToken), cancellationToken);
var firstStatementToRemove = GetFirstStatementOrInitializerSelectedAtCallSite();
var lastStatementToRemove = GetLastStatementOrInitializerSelectedAtCallSite();
......@@ -145,7 +145,7 @@ protected override async Task<SyntaxNode> GenerateBodyForCallSiteContainerAsync(
private async Task<IEnumerable<SyntaxNode>> CreateStatementsOrInitializerToInsertAtCallSiteAsync(CancellationToken cancellationToken)
{
var selectedNode = this.GetFirstStatementOrInitializerSelectedAtCallSite();
var selectedNode = GetFirstStatementOrInitializerSelectedAtCallSite();
// field initializer, constructor initializer, expression bodied member case
if (selectedNode is ConstructorInitializerSyntax ||
......@@ -153,13 +153,13 @@ private async Task<IEnumerable<SyntaxNode>> CreateStatementsOrInitializerToInser
IsExpressionBodiedMember(selectedNode) ||
IsExpressionBodiedAccessor(selectedNode))
{
var statement = await GetStatementOrInitializerContainingInvocationToExtractedMethodAsync(this.CallSiteAnnotation, cancellationToken).ConfigureAwait(false);
var statement = await GetStatementOrInitializerContainingInvocationToExtractedMethodAsync(CallSiteAnnotation, cancellationToken).ConfigureAwait(false);
return SpecializedCollections.SingletonEnumerable(statement);
}
// regular case
var semanticModel = this.SemanticDocument.SemanticModel;
var context = this.InsertionPoint.GetContext();
var semanticModel = SemanticDocument.SemanticModel;
var context = InsertionPoint.GetContext();
var postProcessor = new PostProcessor(semanticModel, context.SpanStart);
var statements = SpecializedCollections.EmptyEnumerable<StatementSyntax>();
......@@ -180,18 +180,18 @@ private bool IsExpressionBodiedAccessor(SyntaxNode node)
private SimpleNameSyntax CreateMethodNameForInvocation()
{
return this.AnalyzerResult.MethodTypeParametersInDeclaration.Count == 0
return AnalyzerResult.MethodTypeParametersInDeclaration.Count == 0
? (SimpleNameSyntax)SyntaxFactory.IdentifierName(_methodName)
: SyntaxFactory.GenericName(_methodName, SyntaxFactory.TypeArgumentList(CreateMethodCallTypeVariables()));
}
private SeparatedSyntaxList<TypeSyntax> CreateMethodCallTypeVariables()
{
Contract.ThrowIfTrue(this.AnalyzerResult.MethodTypeParametersInDeclaration.Count == 0);
Contract.ThrowIfTrue(AnalyzerResult.MethodTypeParametersInDeclaration.Count == 0);
// propagate any type variable used in extracted code
var typeVariables = new List<TypeSyntax>();
foreach (var methodTypeParameter in this.AnalyzerResult.MethodTypeParametersInDeclaration)
foreach (var methodTypeParameter in AnalyzerResult.MethodTypeParametersInDeclaration)
{
typeVariables.Add(SyntaxFactory.ParseTypeName(methodTypeParameter.Name));
}
......@@ -207,7 +207,7 @@ protected SyntaxNode GetCallSiteContainerFromOutermostMoveInVariable(Cancellatio
return null;
}
var idToken = outmostVariable.GetIdentifierTokenAtDeclaration(this.SemanticDocument);
var idToken = outmostVariable.GetIdentifierTokenAtDeclaration(SemanticDocument);
var declStatement = idToken.GetAncestor<LocalDeclarationStatementSyntax>();
Contract.ThrowIfNull(declStatement);
Contract.ThrowIfFalse(declStatement.Parent.IsStatementContainerNode());
......@@ -217,15 +217,15 @@ protected SyntaxNode GetCallSiteContainerFromOutermostMoveInVariable(Cancellatio
private DeclarationModifiers CreateMethodModifiers()
{
var isUnsafe = this.CSharpSelectionResult.ShouldPutUnsafeModifier();
var isAsync = this.CSharpSelectionResult.ShouldPutAsyncModifier();
var isStatic = !this.AnalyzerResult.UseInstanceMember;
var isReadOnly = this.AnalyzerResult.ShouldBeReadOnly;
var isUnsafe = CSharpSelectionResult.ShouldPutUnsafeModifier();
var isAsync = CSharpSelectionResult.ShouldPutAsyncModifier();
var isStatic = !AnalyzerResult.UseInstanceMember;
var isReadOnly = AnalyzerResult.ShouldBeReadOnly;
// Static local functions are only supported in C# 8.0 and later
var languageVersion = ((CSharpParseOptions)this.SemanticDocument.SyntaxTree.Options).LanguageVersion;
var languageVersion = ((CSharpParseOptions)SemanticDocument.SyntaxTree.Options).LanguageVersion;
if (LocalFunction && (!this.Options.GetOption(CSharpCodeStyleOptions.PreferStaticLocalFunction).Value || languageVersion < LanguageVersion.CSharp8))
if (LocalFunction && (!Options.GetOption(CSharpCodeStyleOptions.PreferStaticLocalFunction).Value || languageVersion < LanguageVersion.CSharp8))
{
isStatic = false;
}
......@@ -261,7 +261,7 @@ private OperationStatus<ImmutableArray<SyntaxNode>> CreateMethodBody(Cancellatio
private IEnumerable<StatementSyntax> WrapInCheckStatementIfNeeded(IEnumerable<StatementSyntax> statements)
{
var kind = this.CSharpSelectionResult.UnderCheckedStatementContext();
var kind = CSharpSelectionResult.UnderCheckedStatementContext();
if (kind == SyntaxKind.None)
{
return statements;
......@@ -282,8 +282,8 @@ private IEnumerable<StatementSyntax> WrapInCheckStatementIfNeeded(IEnumerable<St
private IEnumerable<StatementSyntax> CleanupCode(IEnumerable<StatementSyntax> statements)
{
var semanticModel = this.SemanticDocument.SemanticModel;
var context = this.InsertionPoint.GetContext();
var semanticModel = SemanticDocument.SemanticModel;
var context = InsertionPoint.GetContext();
var postProcessor = new PostProcessor(semanticModel, context.SpanStart);
statements = postProcessor.RemoveRedundantBlock(statements);
......@@ -333,7 +333,7 @@ private OperationStatus CheckActiveStatements(IEnumerable<StatementSyntax> state
IEnumerable<StatementSyntax> statements, CancellationToken cancellationToken)
{
var variableToRemoveMap = CreateVariableDeclarationToRemoveMap(
this.AnalyzerResult.GetVariablesToMoveOutToCallSiteOrDelete(cancellationToken), cancellationToken);
AnalyzerResult.GetVariablesToMoveOutToCallSiteOrDelete(cancellationToken), cancellationToken);
statements = statements.Select(s => FixDeclarationExpressionsAndDeclarationPatterns(s, variableToRemoveMap));
......@@ -521,8 +521,8 @@ private static SyntaxToken ApplyTriviaFromDeclarationToAssignmentIdentifier(Loca
IEnumerable<StatementSyntax> statements,
CancellationToken cancellationToken)
{
var semanticModel = this.SemanticDocument.SemanticModel;
var context = this.InsertionPoint.GetContext();
var semanticModel = SemanticDocument.SemanticModel;
var context = InsertionPoint.GetContext();
var postProcessor = new PostProcessor(semanticModel, context.SpanStart);
var declStatements = CreateDeclarationStatements(AnalyzerResult.GetVariablesToSplitOrMoveIntoMethodDefinition(cancellationToken), cancellationToken);
......@@ -541,7 +541,7 @@ private ExpressionSyntax CreateAssignmentExpression(SyntaxToken identifier, Expr
protected override bool LastStatementOrHasReturnStatementInReturnableConstruct()
{
var lastStatement = this.GetLastStatementOrInitializerSelectedAtCallSite();
var lastStatement = GetLastStatementOrInitializerSelectedAtCallSite();
var container = lastStatement.GetAncestorsOrThis<SyntaxNode>().FirstOrDefault(n => n.IsReturnableConstruct());
if (container == null)
{
......@@ -584,7 +584,7 @@ protected override ExpressionSyntax CreateCallSignature()
var methodName = CreateMethodNameForInvocation().WithAdditionalAnnotations(Simplifier.Annotation);
var arguments = new List<ArgumentSyntax>();
foreach (var argument in this.AnalyzerResult.MethodParameters)
foreach (var argument in AnalyzerResult.MethodParameters)
{
var modifier = GetParameterRefSyntaxKind(argument.ParameterModifier);
var refOrOut = modifier == SyntaxKind.None ? default : SyntaxFactory.Token(modifier);
......@@ -595,15 +595,15 @@ protected override ExpressionSyntax CreateCallSignature()
var invocation = SyntaxFactory.InvocationExpression(methodName,
SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList(arguments)));
var shouldPutAsyncModifier = this.CSharpSelectionResult.ShouldPutAsyncModifier();
var shouldPutAsyncModifier = CSharpSelectionResult.ShouldPutAsyncModifier();
if (!shouldPutAsyncModifier)
{
return invocation;
}
if (this.CSharpSelectionResult.ShouldCallConfigureAwaitFalse())
if (CSharpSelectionResult.ShouldCallConfigureAwaitFalse())
{
if (this.AnalyzerResult.ReturnType.GetMembers().Any(x => x is IMethodSymbol
if (AnalyzerResult.ReturnType.GetMembers().Any(x => x is IMethodSymbol
{
Name: nameof(Task.ConfigureAwait),
Parameters: { Length: 1 } parameters
......@@ -632,7 +632,7 @@ protected override StatementSyntax CreateAssignmentExpressionStatement(SyntaxTok
ExpressionSyntax initialValue,
CancellationToken cancellationToken)
{
var type = variable.GetVariableType(this.SemanticDocument);
var type = variable.GetVariableType(SemanticDocument);
var typeNode = type.GenerateTypeSyntax();
var equalsValueClause = initialValue == null ? null : SyntaxFactory.EqualsValueClause(value: initialValue);
......@@ -650,7 +650,7 @@ protected override async Task<GeneratedCode> CreateGeneratedCodeAsync(OperationS
// here, we explicitly insert newline at the end of "{" of auto generated method decl so that anchor knows how to find out
// indentation of inserted statements (from users code) with user code style preserved
var root = newDocument.Root;
var methodDefinition = root.GetAnnotatedNodes<SyntaxNode>(this.MethodDefinitionAnnotation).First();
var methodDefinition = root.GetAnnotatedNodes<SyntaxNode>(MethodDefinitionAnnotation).First();
SyntaxNode newMethodDefinition = methodDefinition switch
{
......@@ -698,9 +698,9 @@ protected StatementSyntax GetStatementContainingInvocationToExtractedMethodWorke
{
var callSignature = CreateCallSignature();
if (this.AnalyzerResult.HasReturnType)
if (AnalyzerResult.HasReturnType)
{
Contract.ThrowIfTrue(this.AnalyzerResult.HasVariableToUseAsReturnValue);
Contract.ThrowIfTrue(AnalyzerResult.HasVariableToUseAsReturnValue);
return SyntaxFactory.ReturnStatement(callSignature);
}
......@@ -799,14 +799,14 @@ static bool ReturnOperationBelongsToMethod(SyntaxNode returnOperationSyntax, Syn
protected SyntaxToken GenerateMethodNameForStatementGenerators()
{
var semanticModel = this.SemanticDocument.SemanticModel;
var semanticModel = SemanticDocument.SemanticModel;
var nameGenerator = new UniqueNameGenerator(semanticModel);
var scope = this.CSharpSelectionResult.GetContainingScope();
var scope = CSharpSelectionResult.GetContainingScope();
// If extracting a local function, we want to ensure all local variables are considered when generating a unique name.
if (LocalFunction)
{
scope = this.CSharpSelectionResult.GetFirstTokenInSelection().Parent;
scope = CSharpSelectionResult.GetFirstTokenInSelection().Parent;
}
return SyntaxFactory.Identifier(nameGenerator.CreateUniqueMethodName(scope, GenerateMethodNameFromUserPreference()));
......@@ -821,7 +821,7 @@ protected string GenerateMethodNameFromUserPreference()
}
// For local functions, pascal case and camel case should be the most common and therefore we only consider those cases.
var namingPreferences = this.Options.GetOption(NamingStyleOptions.NamingPreferences, LanguageNames.CSharp);
var namingPreferences = Options.GetOption(NamingStyleOptions.NamingPreferences, LanguageNames.CSharp);
var localFunctionPreferences = namingPreferences.SymbolSpecifications.Where(symbol => symbol.AppliesTo(new SymbolKindOrTypeKind(MethodKind.LocalFunction), CreateMethodModifiers(), null));
var namingRules = namingPreferences.Rules.NamingRules;
......
......@@ -64,7 +64,7 @@ protected override async Task<InsertionPoint> GetInsertionPointAsync(SemanticDoc
if (memberNode is GlobalStatementSyntax globalStatement)
{
// check whether we are extracting whole global statement out
if (this.OriginalSelectionResult.FinalSpan.Contains(memberNode.Span))
if (OriginalSelectionResult.FinalSpan.Contains(memberNode.Span))
{
return await InsertionPoint.CreateAsync(document, globalStatement.Parent, cancellationToken).ConfigureAwait(false);
}
......
......@@ -40,11 +40,11 @@ public override bool ContainingScopeHasAsyncKeyword()
public override SyntaxNode? GetContainingScope()
{
Contract.ThrowIfNull(this.SemanticDocument);
Contract.ThrowIfFalse(this.SelectionInExpression);
Contract.ThrowIfNull(SemanticDocument);
Contract.ThrowIfFalse(SelectionInExpression);
var firstToken = this.GetFirstTokenInSelection();
var lastToken = this.GetLastTokenInSelection();
var firstToken = GetFirstTokenInSelection();
var lastToken = GetLastTokenInSelection();
return firstToken.GetCommonRoot(lastToken).GetAncestorOrThis<ExpressionSyntax>();
}
......@@ -55,7 +55,7 @@ public override bool ContainingScopeHasAsyncKeyword()
throw ExceptionUtilities.Unreachable;
}
var model = this.SemanticDocument.SemanticModel;
var model = SemanticDocument.SemanticModel;
// special case for array initializer and explicit cast
if (node.IsArrayInitializer())
......
......@@ -31,7 +31,7 @@ private class StatementResult : CSharpSelectionResult
public override bool ContainingScopeHasAsyncKeyword()
{
var node = this.GetContainingScope();
var node = GetContainingScope();
return node switch
{
......@@ -46,11 +46,11 @@ public override bool ContainingScopeHasAsyncKeyword()
public override SyntaxNode GetContainingScope()
{
Contract.ThrowIfNull(this.SemanticDocument);
Contract.ThrowIfTrue(this.SelectionInExpression);
Contract.ThrowIfNull(SemanticDocument);
Contract.ThrowIfTrue(SelectionInExpression);
// it contains statements
var firstToken = this.GetFirstTokenInSelection();
var firstToken = GetFirstTokenInSelection();
return firstToken.GetAncestors<SyntaxNode>().FirstOrDefault(n =>
{
return n is AccessorDeclarationSyntax ||
......@@ -66,10 +66,10 @@ public override SyntaxNode GetContainingScope()
public override ITypeSymbol GetContainingScopeType()
{
Contract.ThrowIfTrue(this.SelectionInExpression);
Contract.ThrowIfTrue(SelectionInExpression);
var node = this.GetContainingScope();
var semanticModel = this.SemanticDocument.SemanticModel;
var node = GetContainingScope();
var semanticModel = SemanticDocument.SemanticModel;
switch (node)
{
......
......@@ -111,9 +111,9 @@ public StatementSyntax GetLastStatement()
public StatementSyntax GetFirstStatementUnderContainer()
{
Contract.ThrowIfTrue(this.SelectionInExpression);
Contract.ThrowIfTrue(SelectionInExpression);
var firstToken = this.GetFirstTokenInSelection();
var firstToken = GetFirstTokenInSelection();
var statement = firstToken.Parent.GetStatementUnderContainer();
Contract.ThrowIfNull(statement);
......@@ -122,13 +122,13 @@ public StatementSyntax GetFirstStatementUnderContainer()
public StatementSyntax GetLastStatementUnderContainer()
{
Contract.ThrowIfTrue(this.SelectionInExpression);
Contract.ThrowIfTrue(SelectionInExpression);
var lastToken = this.GetLastTokenInSelection();
var lastToken = GetLastTokenInSelection();
var statement = lastToken.Parent.GetStatementUnderContainer();
Contract.ThrowIfNull(statement);
var firstStatementUnderContainer = this.GetFirstStatementUnderContainer();
var firstStatementUnderContainer = GetFirstStatementUnderContainer();
Contract.ThrowIfFalse(statement.Parent == firstStatementUnderContainer.Parent);
return statement;
......@@ -136,8 +136,8 @@ public StatementSyntax GetLastStatementUnderContainer()
public SyntaxNode GetInnermostStatementContainer()
{
Contract.ThrowIfFalse(this.SelectionInExpression);
var containingScope = this.GetContainingScope();
Contract.ThrowIfFalse(SelectionInExpression);
var containingScope = GetContainingScope();
var statements = containingScope.GetAncestorsOrThis<StatementSyntax>();
StatementSyntax last = null;
......@@ -152,23 +152,23 @@ public SyntaxNode GetInnermostStatementContainer()
}
// expression bodied member case
var expressionBodiedMember = this.GetContainingScopeOf<ArrowExpressionClauseSyntax>();
var expressionBodiedMember = GetContainingScopeOf<ArrowExpressionClauseSyntax>();
if (expressionBodiedMember != null)
{
// the class/struct declaration is the innermost statement container, since the
// member does not have a block body
return this.GetContainingScopeOf<TypeDeclarationSyntax>();
return GetContainingScopeOf<TypeDeclarationSyntax>();
}
// constructor initializer case
var constructorInitializer = this.GetContainingScopeOf<ConstructorInitializerSyntax>();
var constructorInitializer = GetContainingScopeOf<ConstructorInitializerSyntax>();
if (constructorInitializer != null)
{
return constructorInitializer.Parent;
}
// field initializer case
var field = this.GetContainingScopeOf<FieldDeclarationSyntax>();
var field = GetContainingScopeOf<FieldDeclarationSyntax>();
if (field != null)
{
return field.Parent;
......@@ -181,7 +181,7 @@ public SyntaxNode GetInnermostStatementContainer()
public bool ShouldPutUnsafeModifier()
{
var token = this.GetFirstTokenInSelection();
var token = GetFirstTokenInSelection();
var ancestors = token.GetAncestors<SyntaxNode>();
// if enclosing type contains unsafe keyword, we don't need to put it again
......@@ -207,7 +207,7 @@ public SyntaxKind UnderCheckedStatementContext()
private SyntaxKind UnderCheckedContext<T>() where T : SyntaxNode
{
var token = this.GetFirstTokenInSelection();
var token = GetFirstTokenInSelection();
var contextNode = token.Parent.GetAncestor<T>();
if (contextNode == null)
{
......
......@@ -32,15 +32,15 @@ internal partial class CSharpSelectionValidator : SelectionValidator
public override async Task<SelectionResult> GetValidSelectionAsync(CancellationToken cancellationToken)
{
if (!this.ContainsValidSelection)
if (!ContainsValidSelection)
{
return NullSelection;
}
var text = this.SemanticDocument.Text;
var root = this.SemanticDocument.Root;
var model = this.SemanticDocument.SemanticModel;
var doc = this.SemanticDocument;
var text = SemanticDocument.Text;
var root = SemanticDocument.Root;
var model = SemanticDocument.SemanticModel;
var doc = SemanticDocument;
// go through pipe line and calculate information about the user selection
var selectionInfo = GetInitialSelectionInfo(root, text);
......@@ -80,7 +80,7 @@ public override async Task<SelectionResult> GetValidSelectionAsync(CancellationT
selectionInfo.Status,
selectionInfo.OriginalSpan,
selectionInfo.FinalSpan,
this.Options,
Options,
selectionInfo.SelectionInExpression,
doc,
selectionInfo.FirstTokenInFinalSpan,
......@@ -163,7 +163,7 @@ private TextSpan GetControlFlowSpan(SelectionInfo selectionInfo)
private SelectionInfo GetInitialSelectionInfo(SyntaxNode root, SourceText text)
{
var adjustedSpan = GetAdjustedSpan(text, this.OriginalSpan);
var adjustedSpan = GetAdjustedSpan(text, OriginalSpan);
var firstTokenInSelection = root.FindTokenOnRightOfPosition(adjustedSpan.Start, includeSkipped: false);
var lastTokenInSelection = root.FindTokenOnLeftOfPosition(adjustedSpan.End, includeSkipped: false);
......@@ -486,14 +486,14 @@ public SelectionInfo WithStatus(Func<OperationStatus, OperationStatus> statusGet
public SelectionInfo With(Action<SelectionInfo> valueSetter)
{
var newInfo = this.Clone();
var newInfo = Clone();
valueSetter(newInfo);
return newInfo;
}
public SelectionInfo Clone()
{
return (SelectionInfo)this.MemberwiseClone();
return (SelectionInfo)MemberwiseClone();
}
}
}
......
......@@ -36,7 +36,7 @@ public InvocationExpressionInfo(SemanticDocument document, State state)
protected override ImmutableArray<ParameterName> DetermineParameterNames(CancellationToken cancellationToken)
{
return this.Document.SemanticModel.GenerateParameterNames(
return Document.SemanticModel.GenerateParameterNames(
_invocationExpression.ArgumentList, cancellationToken);
}
......@@ -47,17 +47,17 @@ protected override ITypeSymbol DetermineReturnTypeWorker(CancellationToken cance
{
// Defer to the type inferrer to figure out what the return type of this new method
// should be.
var typeInference = this.Document.Document.GetLanguageService<ITypeInferenceService>();
var typeInference = Document.Document.GetLanguageService<ITypeInferenceService>();
var inferredType = typeInference.InferType(
this.Document.SemanticModel, _invocationExpression, objectAsDefault: true,
name: this.State.IdentifierToken.ValueText, cancellationToken: cancellationToken);
Document.SemanticModel, _invocationExpression, objectAsDefault: true,
name: State.IdentifierToken.ValueText, cancellationToken: cancellationToken);
return inferredType;
}
protected override ImmutableArray<ITypeParameterSymbol> GetCapturedTypeParameters(CancellationToken cancellationToken)
{
var result = new List<ITypeParameterSymbol>();
var semanticModel = this.Document.SemanticModel;
var semanticModel = Document.SemanticModel;
foreach (var argument in _invocationExpression.ArgumentList.Arguments)
{
var type = argument.DetermineParameterType(semanticModel, cancellationToken);
......@@ -75,8 +75,8 @@ protected override ImmutableArray<ITypeParameterSymbol> GenerateTypeParameters(C
//
// TODO(cyrusn): If we do capture method type variables, then we should probably
// capture their constraints as well.
var genericName = (GenericNameSyntax)this.State.SimpleNameOpt;
var semanticModel = this.Document.SemanticModel;
var genericName = (GenericNameSyntax)State.SimpleNameOpt;
var semanticModel = Document.SemanticModel;
if (genericName.TypeArgumentList.Arguments.Count == 1)
{
......@@ -121,7 +121,7 @@ private ITypeParameterSymbol GetMethodTypeParameter(TypeSyntax type, Cancellatio
{
if (type is IdentifierNameSyntax)
{
var info = this.Document.SemanticModel.GetTypeInfo(type, cancellationToken);
var info = Document.SemanticModel.GetTypeInfo(type, cancellationToken);
if (info.Type is ITypeParameterSymbol typeParameter &&
typeParameter.TypeParameterKind == TypeParameterKind.Method)
{
......@@ -147,7 +147,7 @@ protected override ImmutableArray<ITypeSymbol> DetermineParameterTypes(Cancellat
ArgumentSyntax argument,
CancellationToken cancellationToken)
{
return argument.DetermineParameterType(this.Document.SemanticModel, cancellationToken);
return argument.DetermineParameterType(Document.SemanticModel, cancellationToken);
}
protected override ImmutableArray<bool> DetermineParameterOptionality(CancellationToken cancellationToken)
......@@ -155,7 +155,7 @@ protected override ImmutableArray<bool> DetermineParameterOptionality(Cancellati
protected override bool IsIdentifierName()
{
return this.State.SimpleNameOpt.Kind() == SyntaxKind.IdentifierName;
return State.SimpleNameOpt.Kind() == SyntaxKind.IdentifierName;
}
protected override bool IsImplicitReferenceConversion(Compilation compilation, ITypeSymbol sourceType, ITypeSymbol targetType)
......@@ -172,7 +172,7 @@ protected override ImmutableArray<ITypeSymbol> DetermineTypeArguments(Cancellati
{
foreach (var typeArgument in ((GenericNameSyntax)State.SimpleNameOpt).TypeArgumentList.Arguments)
{
var typeInfo = this.Document.SemanticModel.GetTypeInfo(typeArgument, cancellationToken);
var typeInfo = Document.SemanticModel.GetTypeInfo(typeArgument, cancellationToken);
result.Add(typeInfo.Type);
}
}
......
......@@ -505,7 +505,7 @@ private IMethodSymbol GetMethodSymbolIfPresent(SemanticModel semanticModel, Expr
var typeArguments = state.SimpleName.Arity == genericName.TypeArgumentList.Arguments.Count
? genericName.TypeArgumentList.Arguments.OfType<SyntaxNode>().ToList()
: Enumerable.Repeat<SyntaxNode>(null, state.SimpleName.Arity);
return this.GetTypeParameters(state, semanticModel, typeArguments, cancellationToken);
return GetTypeParameters(state, semanticModel, typeArguments, cancellationToken);
}
return ImmutableArray<ITypeParameterSymbol>.Empty;
......
......@@ -43,7 +43,7 @@ internal partial class CSharpIntroduceVariableService
var declarationStatement = SyntaxFactory.LocalDeclarationStatement(
modifiers,
SyntaxFactory.VariableDeclaration(
this.GetTypeSyntax(document, expression, cancellationToken),
GetTypeSyntax(document, expression, cancellationToken),
SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator(
newLocalNameToken.WithAdditionalAnnotations(RenameAnnotation.Create()),
null,
......
......@@ -169,7 +169,7 @@ private void SyntaxNodeAction(SyntaxNodeAnalysisContext syntaxContext)
var nextToken = expressionStatement.GetLastToken().GetNextToken();
// Fade out the code up to the expression statement.
syntaxContext.ReportDiagnostic(Diagnostic.Create(this.UnnecessaryWithSuggestionDescriptor,
syntaxContext.ReportDiagnostic(Diagnostic.Create(UnnecessaryWithSuggestionDescriptor,
Location.Create(tree, TextSpan.FromBounds(firstStatement.SpanStart, previousToken.Span.End)),
additionalLocations, properties));
......@@ -183,7 +183,7 @@ private void SyntaxNodeAction(SyntaxNodeAnalysisContext syntaxContext)
// If the if-statement extends past the expression statement, then fade out the rest.
if (nextToken.Span.Start < ifStatement.Span.End)
{
syntaxContext.ReportDiagnostic(Diagnostic.Create(this.UnnecessaryWithSuggestionDescriptor,
syntaxContext.ReportDiagnostic(Diagnostic.Create(UnnecessaryWithSuggestionDescriptor,
Location.Create(tree, TextSpan.FromBounds(nextToken.Span.Start, ifStatement.Span.End)),
additionalLocations, properties));
}
......
......@@ -105,7 +105,7 @@ protected override void AddAwaitableExtensionPrefix()
{
EqualsValueClauseSyntax initializer = null;
var variableDeclarator = await this.GetFirstDeclarationAsync<VariableDeclaratorSyntax>(symbol).ConfigureAwait(false);
var variableDeclarator = await GetFirstDeclarationAsync<VariableDeclaratorSyntax>(symbol).ConfigureAwait(false);
if (variableDeclarator != null)
{
initializer = variableDeclarator.Initializer;
......@@ -113,7 +113,7 @@ protected override void AddAwaitableExtensionPrefix()
if (initializer == null)
{
var enumMemberDeclaration = await this.GetFirstDeclarationAsync<EnumMemberDeclarationSyntax>(symbol).ConfigureAwait(false);
var enumMemberDeclaration = await GetFirstDeclarationAsync<EnumMemberDeclarationSyntax>(symbol).ConfigureAwait(false);
if (enumMemberDeclaration != null)
{
initializer = enumMemberDeclaration.EqualsValue;
......@@ -131,7 +131,7 @@ protected override void AddAwaitableExtensionPrefix()
private async Task<ImmutableArray<SymbolDisplayPart>> GetInitializerSourcePartsAsync(
ILocalSymbol symbol)
{
var syntax = await this.GetFirstDeclarationAsync<VariableDeclaratorSyntax>(symbol).ConfigureAwait(false);
var syntax = await GetFirstDeclarationAsync<VariableDeclaratorSyntax>(symbol).ConfigureAwait(false);
if (syntax != null)
{
return await GetInitializerSourcePartsAsync(syntax.Initializer).ConfigureAwait(false);
......@@ -143,7 +143,7 @@ protected override void AddAwaitableExtensionPrefix()
private async Task<ImmutableArray<SymbolDisplayPart>> GetInitializerSourcePartsAsync(
IParameterSymbol symbol)
{
var syntax = await this.GetFirstDeclarationAsync<ParameterSyntax>(symbol).ConfigureAwait(false);
var syntax = await GetFirstDeclarationAsync<ParameterSyntax>(symbol).ConfigureAwait(false);
if (syntax != null)
{
return await GetInitializerSourcePartsAsync(syntax.Default).ConfigureAwait(false);
......@@ -156,7 +156,7 @@ protected override void AddAwaitableExtensionPrefix()
{
foreach (var syntaxRef in symbol.DeclaringSyntaxReferences)
{
var syntax = await syntaxRef.GetSyntaxAsync(this.CancellationToken).ConfigureAwait(false);
var syntax = await syntaxRef.GetSyntaxAsync(CancellationToken).ConfigureAwait(false);
if (syntax is T tSyntax)
{
return tSyntax;
......@@ -176,7 +176,7 @@ protected override void AddAwaitableExtensionPrefix()
{
return await Classifier.GetClassifiedSymbolDisplayPartsAsync(
semanticModel, equalsValue.Value.Span,
this.Workspace, cancellationToken: this.CancellationToken).ConfigureAwait(false);
Workspace, cancellationToken: CancellationToken).ConfigureAwait(false);
}
}
......
......@@ -28,7 +28,7 @@ public override ImmutableArray<SymbolDisplayPart> ToMinimalDisplayParts(Semantic
protected override AbstractSymbolDescriptionBuilder CreateDescriptionBuilder(Workspace workspace, SemanticModel semanticModel, int position, CancellationToken cancellationToken)
{
return new SymbolDescriptionBuilder(this, semanticModel, position, workspace, this.AnonymousTypeDisplayService, cancellationToken);
return new SymbolDescriptionBuilder(this, semanticModel, position, workspace, AnonymousTypeDisplayService, cancellationToken);
}
}
}
......@@ -44,7 +44,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
{
context.RegisterCodeFix(
new MyCodeAction(CSharpFeaturesResources.Use_is_null_check,
c => this.FixAsync(context.Document, diagnostic, c)),
c => FixAsync(context.Document, diagnostic, c)),
context.Diagnostics);
}
......
......@@ -98,7 +98,7 @@ private void SyntaxNodeAction(SyntaxNodeAnalysisContext context)
context.ReportDiagnostic(
DiagnosticHelper.Create(
this.Descriptor, isExpression.GetLocation(),
Descriptor, isExpression.GetLocation(),
styleOption.Notification.Severity,
SpecializedCollections.EmptyCollection<Location>(),
ImmutableDictionary<string, string>.Empty));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册