提交 9fc091e1 编写于 作者: C Cyrus Najmabadi

Remove unused parameters

上级 1fcb4464
......@@ -67,7 +67,7 @@ private Rewriter(bool isAllThrowStatements)
Debug.Assert(_assignmentTargetOpt != null);
return generateDeclaration
? GenerateVariableDeclaration(switchExpression, leadingTrivia, declaratorToRemoveTypeOpt)
? GenerateVariableDeclaration(switchExpression, declaratorToRemoveTypeOpt)
: GenerateAssignment(switchExpression, nodeToGenerate, leadingTrivia);
}
......@@ -82,7 +82,7 @@ private ExpressionStatementSyntax GenerateAssignment(ExpressionSyntax switchExpr
.WithLeadingTrivia(leadingTrivia);
}
private StatementSyntax GenerateVariableDeclaration(ExpressionSyntax switchExpression, SyntaxTriviaList leadingTrivia, ITypeSymbol declaratorToRemoveTypeOpt)
private StatementSyntax GenerateVariableDeclaration(ExpressionSyntax switchExpression, ITypeSymbol declaratorToRemoveTypeOpt)
{
Debug.Assert(_assignmentTargetOpt is IdentifierNameSyntax);
......
......@@ -74,14 +74,10 @@ internal static bool IsTriggerCharacter(SourceText text, int characterPosition,
internal static ImmutableHashSet<char> CommonTriggerCharactersWithArgumentList { get; } = ImmutableHashSet.Create('.', '#', '>', ':', '(', '[', ' ');
internal static bool IsTriggerCharacterOrArgumentListCharacter(SourceText text, int characterPosition, OptionSet options)
{
return IsTriggerCharacter(text, characterPosition, options) || IsArgumentListCharacter(text, characterPosition, options);
}
=> IsTriggerCharacter(text, characterPosition, options) || IsArgumentListCharacter(text, characterPosition);
private static bool IsArgumentListCharacter(SourceText text, int characterPosition, OptionSet options)
{
return IsArgumentListCharacter(text[characterPosition]);
}
private static bool IsArgumentListCharacter(SourceText text, int characterPosition)
=> IsArgumentListCharacter(text[characterPosition]);
internal static bool IsArgumentListCharacter(char ch)
{
......
......@@ -98,7 +98,7 @@ public override async Task ProvideCompletionsAsync(CompletionContext context)
var serializedOptions = ImmutableDictionary<string, string>.Empty.Add(HideAdvancedMembers, hideAdvancedMembers.ToString());
var items = CreateCompletionItems(document.Project.Solution.Workspace,
semanticModel, symbols, token, span, position, serializedOptions);
semanticModel, symbols, token, position, serializedOptions);
context.AddItems(items);
}
......@@ -270,15 +270,15 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
}
private IEnumerable<CompletionItem> CreateCompletionItems(
Workspace workspace, SemanticModel semanticModel, ImmutableArray<ISymbol> symbols, SyntaxToken token, TextSpan itemSpan, int position, ImmutableDictionary<string, string> options)
Workspace workspace, SemanticModel semanticModel, ImmutableArray<ISymbol> symbols, SyntaxToken token, int position, ImmutableDictionary<string, string> options)
{
var builder = SharedPools.Default<StringBuilder>().Allocate();
try
{
foreach (var symbol in symbols)
{
yield return CreateItem(workspace, semanticModel, symbol, token, position, builder, options);
if (TryCreateSpecialTypeItem(workspace, semanticModel, symbol, token, position, builder, options, out var item))
yield return CreateItem(semanticModel, symbol, token, position, builder, options);
if (TryCreateSpecialTypeItem(semanticModel, symbol, token, position, builder, options, out var item))
{
yield return item;
}
......@@ -291,7 +291,7 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
}
private bool TryCreateSpecialTypeItem(
Workspace workspace, SemanticModel semanticModel, ISymbol symbol, SyntaxToken token, int position, StringBuilder builder,
SemanticModel semanticModel, ISymbol symbol, SyntaxToken token, int position, StringBuilder builder,
ImmutableDictionary<string, string> options, out CompletionItem item)
{
// If the type is a SpecialType, create an additional item using
......@@ -299,7 +299,7 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
var typeSymbol = symbol as ITypeSymbol;
if (typeSymbol.IsSpecialType())
{
item = CreateItem(workspace, semanticModel, symbol, token, position, builder, options, CrefFormatForSpecialTypes);
item = CreateItem(semanticModel, symbol, token, position, builder, options, CrefFormatForSpecialTypes);
return true;
}
......@@ -308,15 +308,15 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
}
private CompletionItem CreateItem(
Workspace workspace, SemanticModel semanticModel, ISymbol symbol, SyntaxToken token, int position, StringBuilder builder, ImmutableDictionary<string, string> options)
SemanticModel semanticModel, ISymbol symbol, SyntaxToken token, int position, StringBuilder builder, ImmutableDictionary<string, string> options)
{
// For every symbol, we create an item that uses the regular CrefFormat,
// which uses intrinsic type keywords
return CreateItem(workspace, semanticModel, symbol, token, position, builder, options, CrefFormat);
return CreateItem(semanticModel, symbol, token, position, builder, options, CrefFormat);
}
private CompletionItem CreateItem(
Workspace workspace, SemanticModel semanticModel, ISymbol symbol, SyntaxToken token, int position, StringBuilder builder, ImmutableDictionary<string, string> options,
SemanticModel semanticModel, ISymbol symbol, SyntaxToken token, int position, StringBuilder builder, ImmutableDictionary<string, string> options,
SymbolDisplayFormat unqualifiedCrefFormat)
{
builder.Clear();
......
......@@ -49,21 +49,21 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
var semanticModel = await document.GetSemanticModelForSpanAsync(new Text.TextSpan(token.SpanStart, 0), cancellationToken).ConfigureAwait(false);
var typeInferenceService = document.GetLanguageService<ITypeInferenceService>();
if (IsTupleTypeElement(token, semanticModel, position, cancellationToken, out var result)
|| IsParameterDeclaration(token, semanticModel, position, cancellationToken, out result)
|| IsTypeParameterDeclaration(token, semanticModel, position, out result)
|| IsLocalFunctionDeclaration(token, semanticModel, position, cancellationToken, out result)
|| IsLocalVariableDeclaration(token, semanticModel, position, cancellationToken, out result)
|| IsEmbeddedVariableDeclaration(token, semanticModel, position, cancellationToken, out result)
|| IsForEachVariableDeclaration(token, semanticModel, position, cancellationToken, out result)
|| IsIncompleteMemberDeclaration(token, semanticModel, position, cancellationToken, out result)
|| IsFieldDeclaration(token, semanticModel, position, cancellationToken, out result)
|| IsMethodDeclaration(token, semanticModel, position, cancellationToken, out result)
|| IsPropertyDeclaration(token, semanticModel, position, cancellationToken, out result)
|| IsPossibleOutVariableDeclaration(token, semanticModel, position, typeInferenceService, cancellationToken, out result)
|| IsTupleLiteralElement(token, semanticModel, position, cancellationToken, out result)
|| IsPossibleVariableOrLocalMethodDeclaration(token, semanticModel, position, cancellationToken, out result)
|| IsPatternMatching(token, semanticModel, position, cancellationToken, out result))
if (IsTupleTypeElement(token, semanticModel, cancellationToken, out var result)
|| IsParameterDeclaration(token, semanticModel, cancellationToken, out result)
|| IsTypeParameterDeclaration(token, out result)
|| IsLocalFunctionDeclaration(token, semanticModel, cancellationToken, out result)
|| IsLocalVariableDeclaration(token, semanticModel, cancellationToken, out result)
|| IsEmbeddedVariableDeclaration(token, semanticModel, cancellationToken, out result)
|| IsForEachVariableDeclaration(token, semanticModel, cancellationToken, out result)
|| IsIncompleteMemberDeclaration(token, semanticModel, cancellationToken, out result)
|| IsFieldDeclaration(token, semanticModel, cancellationToken, out result)
|| IsMethodDeclaration(token, semanticModel, cancellationToken, out result)
|| IsPropertyDeclaration(token, semanticModel, cancellationToken, out result)
|| IsPossibleOutVariableDeclaration(token, semanticModel, typeInferenceService, cancellationToken, out result)
|| IsTupleLiteralElement(token, semanticModel, cancellationToken, out result)
|| IsPossibleVariableOrLocalMethodDeclaration(token, semanticModel, cancellationToken, out result)
|| IsPatternMatching(token, semanticModel, cancellationToken, out result))
{
return result;
}
......@@ -72,7 +72,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private static bool IsTupleTypeElement(
SyntaxToken token, SemanticModel semanticModel, int position,
SyntaxToken token, SemanticModel semanticModel,
CancellationToken cancellationToken, out NameDeclarationInfo result)
{
result = IsFollowingTypeOrComma<TupleElementSyntax>(
......@@ -86,7 +86,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private static bool IsTupleLiteralElement(
SyntaxToken token, SemanticModel semanticModel, int position,
SyntaxToken token, SemanticModel semanticModel,
CancellationToken cancellationToken, out NameDeclarationInfo result)
{
// Incomplete code like
......@@ -110,7 +110,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
return false;
}
private static bool IsPossibleOutVariableDeclaration(SyntaxToken token, SemanticModel semanticModel, int position,
private static bool IsPossibleOutVariableDeclaration(SyntaxToken token, SemanticModel semanticModel,
ITypeInferenceService typeInferenceService, CancellationToken cancellationToken, out NameDeclarationInfo result)
{
if (!token.IsKind(SyntaxKind.IdentifierToken) || !token.Parent.IsKind(SyntaxKind.IdentifierName))
......@@ -146,7 +146,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private static bool IsPossibleVariableOrLocalMethodDeclaration(
SyntaxToken token, SemanticModel semanticModel, int position,
SyntaxToken token, SemanticModel semanticModel,
CancellationToken cancellationToken, out NameDeclarationInfo result)
{
result = IsLastTokenOfType<ExpressionStatementSyntax>(
......@@ -161,7 +161,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private static bool IsPropertyDeclaration(SyntaxToken token, SemanticModel semanticModel,
int position, CancellationToken cancellationToken, out NameDeclarationInfo result)
CancellationToken cancellationToken, out NameDeclarationInfo result)
{
result = IsLastTokenOfType<PropertyDeclarationSyntax>(
token,
......@@ -175,7 +175,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private static bool IsMethodDeclaration(SyntaxToken token, SemanticModel semanticModel,
int position, CancellationToken cancellationToken, out NameDeclarationInfo result)
CancellationToken cancellationToken, out NameDeclarationInfo result)
{
result = IsLastTokenOfType<MethodDeclarationSyntax>(
token,
......@@ -276,7 +276,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private static bool IsFieldDeclaration(SyntaxToken token, SemanticModel semanticModel,
int position, CancellationToken cancellationToken, out NameDeclarationInfo result)
CancellationToken cancellationToken, out NameDeclarationInfo result)
{
result = IsFollowingTypeOrComma<VariableDeclarationSyntax>(token, semanticModel,
v => v.Type,
......@@ -287,7 +287,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private static bool IsIncompleteMemberDeclaration(SyntaxToken token, SemanticModel semanticModel,
int position, CancellationToken cancellationToken, out NameDeclarationInfo result)
CancellationToken cancellationToken, out NameDeclarationInfo result)
{
result = IsLastTokenOfType<IncompleteMemberSyntax>(token, semanticModel,
i => i.Type,
......@@ -298,7 +298,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private static bool IsLocalFunctionDeclaration(SyntaxToken token, SemanticModel semanticModel,
int position, CancellationToken cancellationToken, out NameDeclarationInfo result)
CancellationToken cancellationToken, out NameDeclarationInfo result)
{
result = IsLastTokenOfType<LocalFunctionStatementSyntax>(token, semanticModel,
typeSyntaxGetter: f => f.ReturnType,
......@@ -309,7 +309,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private static bool IsLocalVariableDeclaration(SyntaxToken token, SemanticModel semanticModel,
int position, CancellationToken cancellationToken, out NameDeclarationInfo result)
CancellationToken cancellationToken, out NameDeclarationInfo result)
{
// If we only have a type, this can still end up being a local function (depending on the modifiers).
var possibleDeclarationComputer = token.IsKind(SyntaxKind.CommaToken)
......@@ -328,7 +328,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private static bool IsEmbeddedVariableDeclaration(SyntaxToken token, SemanticModel semanticModel,
int position, CancellationToken cancellationToken, out NameDeclarationInfo result)
CancellationToken cancellationToken, out NameDeclarationInfo result)
{
result = IsFollowingTypeOrComma<VariableDeclarationSyntax>(token, semanticModel,
typeSyntaxGetter: v => v.Type,
......@@ -341,7 +341,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private static bool IsForEachVariableDeclaration(SyntaxToken token, SemanticModel semanticModel,
int position, CancellationToken cancellationToken, out NameDeclarationInfo result)
CancellationToken cancellationToken, out NameDeclarationInfo result)
{
// This is parsed as ForEachVariableStatementSyntax:
// foreach (int $$
......@@ -356,8 +356,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
return result.Type != null;
}
private static bool IsTypeParameterDeclaration(SyntaxToken token, SemanticModel semanticModel,
int position, out NameDeclarationInfo result)
private static bool IsTypeParameterDeclaration(SyntaxToken token, out NameDeclarationInfo result)
{
if (token.IsKind(SyntaxKind.LessThanToken, SyntaxKind.CommaToken) &&
token.Parent.IsKind(SyntaxKind.TypeParameterList))
......@@ -377,7 +376,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private static bool IsParameterDeclaration(SyntaxToken token, SemanticModel semanticModel,
int position, CancellationToken cancellationToken, out NameDeclarationInfo result)
CancellationToken cancellationToken, out NameDeclarationInfo result)
{
result = IsLastTokenOfType<ParameterSyntax>(
token, semanticModel,
......@@ -389,7 +388,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private static bool IsPatternMatching(SyntaxToken token, SemanticModel semanticModel,
int position, CancellationToken cancellationToken, out NameDeclarationInfo result)
CancellationToken cancellationToken, out NameDeclarationInfo result)
{
result = default;
if (token.Parent.IsParentKind(SyntaxKind.IsExpression))
......
......@@ -24,7 +24,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
if (context.ContainingTypeDeclaration != null)
{
return
IsConstructorInitializerContext(position, context) ||
IsConstructorInitializerContext(context) ||
IsInstanceExpressionOrStatement(context);
}
......@@ -41,7 +41,7 @@ private static bool IsInstanceExpressionOrStatement(CSharpSyntaxContext context)
return false;
}
private bool IsConstructorInitializerContext(int position, CSharpSyntaxContext context)
private bool IsConstructorInitializerContext(CSharpSyntaxContext context)
{
// cases:
// Goo() : |
......
......@@ -37,12 +37,11 @@ public override void Convert(SyntaxEditor editor, bool convertToQuery, Cancellat
editor.ReplaceNode(
ForEachInfo.ForEachStatement,
CreateDefaultReplacementStatement(ForEachInfo, identifiersUsedInStatements, block, convertToQuery)
CreateDefaultReplacementStatement(identifiersUsedInStatements, block, convertToQuery)
.WithAdditionalAnnotations(Formatter.Annotation));
}
private StatementSyntax CreateDefaultReplacementStatement(
ForEachInfo<ForEachStatementSyntax, StatementSyntax> forEachInfo,
IEnumerable<SyntaxToken> identifiers,
BlockSyntax block,
bool convertToQuery)
......
......@@ -163,12 +163,12 @@ private bool CanEncapsulate(FieldDeclarationSyntax field)
if (newPropertyName == field.Name)
{
// If we wind up with the field's old name, give the field the unique version of its current name.
return Tuple.Create(MakeUnique(GenerateFieldName(field, field.Name), field.ContainingType), newPropertyName);
return Tuple.Create(MakeUnique(GenerateFieldName(field.Name), field.ContainingType), newPropertyName);
}
// Otherwise, ensure the property's name is unique.
newPropertyName = MakeUnique(newPropertyName, field.ContainingType);
var newFieldName = GenerateFieldName(field, newPropertyName);
var newFieldName = GenerateFieldName(newPropertyName);
// If converting the new property's name into a field name results in the old field name, we're done.
if (newFieldName == field.Name)
......@@ -186,12 +186,10 @@ private bool IsNew(IFieldSymbol field)
return field.DeclaringSyntaxReferences.Any(d => d.GetSyntax().GetAncestor<FieldDeclarationSyntax>().Modifiers.Any(SyntaxKind.NewKeyword));
}
private string GenerateFieldName(IFieldSymbol field, string correspondingPropertyName)
{
return char.ToLower(correspondingPropertyName[0]).ToString() + correspondingPropertyName.Substring(1);
}
private string GenerateFieldName(string correspondingPropertyName)
=> char.ToLower(correspondingPropertyName[0]).ToString() + correspondingPropertyName.Substring(1);
protected string MakeUnique(string baseName, INamedTypeSymbol containingType, bool considerBaseMembers = true)
protected string MakeUnique(string baseName, INamedTypeSymbol containingType)
{
var containingTypeMemberNames = containingType.GetAccessibleMembersInThisAndBaseTypes<ISymbol>(containingType).Select(m => m.Name);
return NameGenerator.GenerateUniqueName(baseName, containingTypeMemberNames.ToSet(), StringComparer.Ordinal);
......
......@@ -7,12 +7,12 @@ namespace Microsoft.CodeAnalysis.CSharp.GenerateMember.GenerateParameterizedMemb
{
internal static class CSharpCommonGenerationServiceMethods
{
public static bool AreSpecialOptionsActive(SemanticModel semanticModel)
public static bool AreSpecialOptionsActive()
{
return false;
}
public static bool IsValidSymbol(ISymbol symbol, SemanticModel semanticModel)
public static bool IsValidSymbol()
{
return false;
}
......
......@@ -51,14 +51,10 @@ protected override bool ContainingTypesOrSelfHasUnsafeKeyword(INamedTypeSymbol c
}
protected override bool AreSpecialOptionsActive(SemanticModel semanticModel)
{
return CSharpCommonGenerationServiceMethods.AreSpecialOptionsActive(semanticModel);
}
=> CSharpCommonGenerationServiceMethods.AreSpecialOptionsActive();
protected override bool IsValidSymbol(ISymbol symbol, SemanticModel semanticModel)
{
return CSharpCommonGenerationServiceMethods.IsValidSymbol(symbol, semanticModel);
}
=> CSharpCommonGenerationServiceMethods.IsValidSymbol();
protected override bool TryInitializeImplicitConversionState(
SemanticDocument document,
......
......@@ -27,9 +27,9 @@ protected override AbstractInvocationInfo CreateInvocationMethodInfo(SemanticDoc
=> new CSharpGenerateParameterizedMemberService<CSharpGenerateDeconstructMethodService>.InvocationExpressionInfo(document, state);
protected override bool AreSpecialOptionsActive(SemanticModel semanticModel)
=> CSharpCommonGenerationServiceMethods.AreSpecialOptionsActive(semanticModel);
=> CSharpCommonGenerationServiceMethods.AreSpecialOptionsActive();
protected override bool IsValidSymbol(ISymbol symbol, SemanticModel semanticModel)
=> CSharpCommonGenerationServiceMethods.IsValidSymbol(symbol, semanticModel);
=> CSharpCommonGenerationServiceMethods.IsValidSymbol();
}
}
......@@ -41,10 +41,10 @@ protected override AbstractInvocationInfo CreateInvocationMethodInfo(SemanticDoc
}
protected override bool AreSpecialOptionsActive(SemanticModel semanticModel)
=> CSharpCommonGenerationServiceMethods.AreSpecialOptionsActive(semanticModel);
=> CSharpCommonGenerationServiceMethods.AreSpecialOptionsActive();
protected override bool IsValidSymbol(ISymbol symbol, SemanticModel semanticModel)
=> CSharpCommonGenerationServiceMethods.IsValidSymbol(symbol, semanticModel);
=> CSharpCommonGenerationServiceMethods.IsValidSymbol();
protected override bool TryInitializeExplicitInterfaceState(
SemanticDocument document,
......
......@@ -619,7 +619,7 @@ protected override bool IsConversionImplicit(Compilation compilation, ITypeSymbo
afterThisLocation);
}
private NamespaceDeclarationSyntax GetDeclaringNamespace(List<string> containers, int indexDone, CompilationUnitSyntax compilationUnit)
private NamespaceDeclarationSyntax GetDeclaringNamespace(List<string> containers, CompilationUnitSyntax compilationUnit)
{
foreach (var member in compilationUnit.Members)
{
......
......@@ -68,7 +68,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
// type of the out-var-decl affects overload resolution or generic instantiation).
var originalRoot = editor.OriginalRoot;
var originalNodes = diagnostics.SelectAsArray(diagnostic => FindDiagnosticNodes(document, diagnostic, options, cancellationToken));
var originalNodes = diagnostics.SelectAsArray(diagnostic => FindDiagnosticNodes(diagnostic, cancellationToken));
await editor.ApplyExpressionLevelSemanticEditsAsync(
document,
......@@ -85,13 +85,12 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
(semanticModel, currentRoot, t, currentNode)
=> ReplaceIdentifierWithInlineDeclaration(
options, semanticModel, currentRoot, t.declarator,
t.identifier, t.invocationOrCreation, currentNode, declarationsToRemove),
t.identifier, currentNode, declarationsToRemove),
cancellationToken).ConfigureAwait(false);
}
private (VariableDeclaratorSyntax declarator, IdentifierNameSyntax identifier, SyntaxNode invocationOrCreation) FindDiagnosticNodes(
Document document, Diagnostic diagnostic,
OptionSet options, CancellationToken cancellationToken)
Diagnostic diagnostic, CancellationToken cancellationToken)
{
// Recover the nodes we care about.
var declaratorLocation = diagnostic.AdditionalLocations[0];
......@@ -110,8 +109,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
private SyntaxNode ReplaceIdentifierWithInlineDeclaration(
OptionSet options, SemanticModel semanticModel,
SyntaxNode currentRoot, VariableDeclaratorSyntax declarator,
IdentifierNameSyntax identifier, SyntaxNode invocationOrCreation,
SyntaxNode currentNode, HashSet<StatementSyntax> declarationsToRemove)
IdentifierNameSyntax identifier, SyntaxNode currentNode, HashSet<StatementSyntax> declarationsToRemove)
{
declarator = currentRoot.GetCurrentNode(declarator);
identifier = currentRoot.GetCurrentNode(identifier);
......@@ -234,7 +232,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
sourceText, identifier, newType, singleDeclarator ? null : declarator);
// Check if using out-var changed problem semantics.
var semanticsChanged = SemanticsChanged(semanticModel, currentRoot, currentNode, identifier, declarationExpression);
var semanticsChanged = SemanticsChanged(semanticModel, currentNode, identifier, declarationExpression);
if (semanticsChanged)
{
// Switching to 'var' changed semantics. Just use the original type of the local.
......@@ -326,7 +324,6 @@ private static IEnumerable<SyntaxTrivia> MassageTrivia(IEnumerable<SyntaxTrivia>
private bool SemanticsChanged(
SemanticModel semanticModel,
SyntaxNode root,
SyntaxNode nodeToReplace,
IdentifierNameSyntax identifier,
DeclarationExpressionSyntax declarationExpression)
......
......@@ -186,7 +186,7 @@ protected virtual TextSpan GetTextSpan(SyntaxToken genericIdentifier, SyntaxToke
symbol.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormattingService),
GetPreambleParts(namedType, semanticModel, position),
GetSeparatorParts(),
GetPostambleParts(namedType),
GetPostambleParts(),
namedType.TypeParameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService, cancellationToken)).ToList());
}
else
......@@ -222,14 +222,13 @@ protected virtual TextSpan GetTextSpan(SyntaxToken genericIdentifier, SyntaxToke
isOptional: false,
documentationFactory: parameter.GetDocumentationPartsFactory(semanticModel, position, formatter),
displayParts: parameter.ToMinimalDisplayParts(semanticModel, position, s_minimallyQualifiedFormat),
selectedDisplayParts: GetSelectedDisplayParts(parameter, semanticModel, position, cancellationToken));
selectedDisplayParts: GetSelectedDisplayParts(parameter, semanticModel, position));
}
private IList<SymbolDisplayPart> GetSelectedDisplayParts(
ITypeParameterSymbol typeParam,
SemanticModel semanticModel,
int position,
CancellationToken cancellationToken)
int position)
{
var parts = new List<SymbolDisplayPart>();
......
......@@ -22,10 +22,7 @@ internal partial class GenericNameSignatureHelpProvider
return result;
}
private IList<SymbolDisplayPart> GetPostambleParts(INamedTypeSymbol namedType)
{
return SpecializedCollections.SingletonList(
Punctuation(SyntaxKind.GreaterThanToken));
}
private IList<SymbolDisplayPart> GetPostambleParts()
=> SpecializedCollections.SingletonList(Punctuation(SyntaxKind.GreaterThanToken));
}
}
......@@ -81,7 +81,7 @@ protected override async Task<SignatureHelpItems> GetItemsWorkerAsync(Document d
var syntaxFacts = document.GetLanguageService<ISyntaxFactsService>();
var (items, selectedItem) = type.TypeKind == TypeKind.Delegate
? GetDelegateTypeConstructors(objectCreationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, type, within, cancellationToken)
? GetDelegateTypeConstructors(objectCreationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, type, cancellationToken)
: GetNormalTypeConstructors(document, objectCreationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, documentationCommentFormattingService, type, within, cancellationToken);
return CreateSignatureHelpItems(items, textSpan,
......
......@@ -19,7 +19,6 @@ internal partial class ObjectCreationExpressionSignatureHelpProvider
ISymbolDisplayService symbolDisplayService,
IAnonymousTypeDisplayService anonymousTypeDisplayService,
INamedTypeSymbol delegateType,
INamedTypeSymbol containingType,
CancellationToken cancellationToken)
{
var invokeMethod = delegateType.DelegateInvokeMethod;
......@@ -36,8 +35,8 @@ internal partial class ObjectCreationExpressionSignatureHelpProvider
documentationFactory: null,
prefixParts: GetDelegateTypePreambleParts(invokeMethod, semanticModel, position),
separatorParts: GetSeparatorParts(),
suffixParts: GetDelegateTypePostambleParts(invokeMethod),
parameters: GetDelegateTypeParameters(invokeMethod, semanticModel, position, cancellationToken));
suffixParts: GetDelegateTypePostambleParts(),
parameters: GetDelegateTypeParameters(invokeMethod, semanticModel, position));
return (SpecializedCollections.SingletonList(item), 0);
}
......@@ -52,7 +51,7 @@ private IList<SymbolDisplayPart> GetDelegateTypePreambleParts(IMethodSymbol invo
return result;
}
private IList<SignatureHelpSymbolParameter> GetDelegateTypeParameters(IMethodSymbol invokeMethod, SemanticModel semanticModel, int position, CancellationToken cancellationToken)
private IList<SignatureHelpSymbolParameter> GetDelegateTypeParameters(IMethodSymbol invokeMethod, SemanticModel semanticModel, int position)
{
const string TargetName = "target";
......@@ -86,10 +85,7 @@ private IList<SignatureHelpSymbolParameter> GetDelegateTypeParameters(IMethodSym
displayParts: parts));
}
private IList<SymbolDisplayPart> GetDelegateTypePostambleParts(IMethodSymbol invokeMethod)
{
return SpecializedCollections.SingletonList(
Punctuation(SyntaxKind.CloseParenToken));
}
private IList<SymbolDisplayPart> GetDelegateTypePostambleParts()
=> SpecializedCollections.SingletonList(Punctuation(SyntaxKind.CloseParenToken));
}
}
......@@ -77,7 +77,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
if (resultOpt != null)
{
var result = resultOpt.Value;
var updatedNode = FixOne(result, cancellationToken);
var updatedNode = FixOne(result);
if (updatedNode != null)
{
return currentRoot.ReplaceNode(result.Invocation, updatedNode);
......@@ -91,7 +91,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
private static InvocationExpressionSyntax GetInvocationExpression(Diagnostic d, CancellationToken cancellationToken)
=> (InvocationExpressionSyntax)d.AdditionalLocations[0].FindNode(getInnermostNodeForTie: true, cancellationToken);
private ExpressionSyntax FixOne(Result result, CancellationToken cancellationToken)
private ExpressionSyntax FixOne(Result result)
{
var invocation = result.Invocation;
var expression = invocation.Expression is MemberAccessExpressionSyntax memberAccess
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册