-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Offer 'in' as completion in operator #24089
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 15 additions & 9 deletions
24
src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxNodeExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,32 @@ | ||
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using Microsoft.CodeAnalysis.CSharp; | ||
using Microsoft.CodeAnalysis.CSharp.Symbols; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
using Microsoft.CodeAnalysis.Text; | ||
|
||
namespace Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery | ||
{ | ||
internal static class SyntaxNodeExtensions | ||
{ | ||
public static bool IsDelegateOrConstructorOrLocalFunctionOrMethodParameterList(this SyntaxNode node) | ||
public static bool IsDelegateOrConstructorOrLocalFunctionOrMethodOrOperatorParameterList(this SyntaxNode node, bool includeOperators) | ||
{ | ||
if (!node.IsKind(SyntaxKind.ParameterList)) | ||
{ | ||
return false; | ||
} | ||
|
||
return | ||
node.IsParentKind(SyntaxKind.MethodDeclaration) || | ||
if (node.IsParentKind(SyntaxKind.MethodDeclaration) || | ||
node.IsParentKind(SyntaxKind.LocalFunctionStatement) || | ||
node.IsParentKind(SyntaxKind.ConstructorDeclaration) || | ||
node.IsParentKind(SyntaxKind.DelegateDeclaration); | ||
node.IsParentKind(SyntaxKind.DelegateDeclaration)) | ||
{ | ||
return true; | ||
} | ||
|
||
if (includeOperators) | ||
{ | ||
return | ||
node.IsParentKind(SyntaxKind.OperatorDeclaration) || | ||
node.IsParentKind(SyntaxKind.ConversionOperatorDeclaration); | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need the extra parameter? What's the consequence of just returning true for all of the operators as well all of the time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, it's not terrible if we offer keywords even when not always applicable. That's still much better than not offering it. Then, we could just make this cod really simple. Basically: "offer these things if it's in a parameter list", even if that allows some things when not applicable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The impact is offering
out
andref
in places where they are not applicable.Sure. I'll remove the parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah... at this point i think it's fine to offer in all argument cases. It's unlikely anyone would notice. And the worst impact is they type something that the compiler then tells you is not valid.