Skip to content

Commit

Permalink
PR Feedback:
Browse files Browse the repository at this point in the history
* Revert unneeded publicapi file changes.
* Simplify handling in some IDE code.
  • Loading branch information
333fred committed Jul 7, 2020
1 parent 4f740fa commit c4be137
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
3 changes: 3 additions & 0 deletions src/Compilers/CSharp/Portable/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.AttributeListSyntax>
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<Microsoft.CodeAnalysis.CSharp.Syntax.AttributeListSyntax> 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<Microsoft.CodeAnalysis.CSharp.Syntax.AttributeListSyntax> attributeLists) -> Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax
Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax.WithDefault(Microsoft.CodeAnalysis.CSharp.Syntax.EqualsValueClauseSyntax default) -> Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -956,30 +956,24 @@ 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:
case SyntaxKind.CommaToken:
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(
Expand Down

0 comments on commit c4be137

Please sign in to comment.