From c4be1376a6e0465ef35f3dd44267659f5d1f104e Mon Sep 17 00:00:00 2001 From: Fredric Silberberg Date: Tue, 7 Jul 2020 15:51:16 -0700 Subject: [PATCH] PR Feedback: * Revert unneeded publicapi file changes. * Simplify handling in some IDE code. --- .../CSharp/Portable/PublicAPI.Shipped.txt | 3 +++ .../ReadOnlyKeywordRecommender.cs | 3 +-- .../ContextQuery/SyntaxTreeExtensions.cs | 16 +++++----------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/Compilers/CSharp/Portable/PublicAPI.Shipped.txt b/src/Compilers/CSharp/Portable/PublicAPI.Shipped.txt index 6aa612f8966f0..ab1cb7856ea7c 100644 --- a/src/Compilers/CSharp/Portable/PublicAPI.Shipped.txt +++ b/src/Compilers/CSharp/Portable/PublicAPI.Shipped.txt @@ -1721,8 +1721,11 @@ Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax.WithParameters(Microsof Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax.AddAttributeLists(params Microsoft.CodeAnalysis.CSharp.Syntax.AttributeListSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax.AddModifiers(params Microsoft.CodeAnalysis.SyntaxToken[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax +Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax.AttributeLists.get -> Microsoft.CodeAnalysis.SyntaxList Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax.Default.get -> Microsoft.CodeAnalysis.CSharp.Syntax.EqualsValueClauseSyntax Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax.Identifier.get -> Microsoft.CodeAnalysis.SyntaxToken +Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax.Modifiers.get -> Microsoft.CodeAnalysis.SyntaxTokenList +Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax.Type.get -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax.Update(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.CSharp.Syntax.EqualsValueClauseSyntax default) -> Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax.WithAttributeLists(Microsoft.CodeAnalysis.SyntaxList attributeLists) -> Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax.WithDefault(Microsoft.CodeAnalysis.CSharp.Syntax.EqualsValueClauseSyntax default) -> Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax diff --git a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ReadOnlyKeywordRecommender.cs b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ReadOnlyKeywordRecommender.cs index 974ee641c4fa1..af17a9a0ec8b2 100644 --- a/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ReadOnlyKeywordRecommender.cs +++ b/src/Features/CSharp/Portable/Completion/KeywordRecommenders/ReadOnlyKeywordRecommender.cs @@ -42,8 +42,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context private static bool IsRefReadOnlyContext(CSharpSyntaxContext context) => context.TargetToken.IsKind(SyntaxKind.RefKeyword) && - (context.TargetToken.Parent.IsKind(SyntaxKind.RefType) || - (context.TargetToken.Parent.IsKind(SyntaxKind.FunctionPointerParameter) && context.IsFunctionPointerTypeArgumentContext)); + (context.TargetToken.Parent.IsKind(SyntaxKind.RefType) || context.IsFunctionPointerTypeArgumentContext); private static bool IsValidContextForType(CSharpSyntaxContext context, CancellationToken cancellationToken) { diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs index eafa9143ac207..4bab51f9e3ebc 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs @@ -956,7 +956,6 @@ public static bool IsFunctionPointerTypeArgumentContext( var token = tokenOnLeftOfPosition; token = token.GetPreviousTokenIfTouchingWord(position); - // https://github.com/dotnet/roslyn/issues/39865: When the syntax rewrite is done, the parents here will need to change. switch (token.Kind()) { case SyntaxKind.LessThanToken: @@ -964,22 +963,17 @@ public static bool IsFunctionPointerTypeArgumentContext( return token.Parent is FunctionPointerParameterListSyntax; } - return token.IsFunctionPointerParameterOrReturnType(); -#else - return false; -#endif - } - - public static bool IsFunctionPointerParameterOrReturnType(this SyntaxToken syntaxToken) - { - return syntaxToken switch + return token switch { // ref modifiers { Parent: { RawKind: (int)SyntaxKindEx.FunctionPointerParameter } } => true, // Regular type specifiers - { Parent: { Parent: { RawKind: (int)SyntaxKindEx.FunctionPointerParameter } } } => true, + { Parent: TypeSyntax { Parent: { RawKind: (int)SyntaxKindEx.FunctionPointerParameter } } } => true, _ => false }; +#else + return false; +#endif } public static bool IsGenericTypeArgumentContext(