Skip to content
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 1 commit into from
Jan 9, 2018
Merged

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented Jan 7, 2018

Customer scenario

Type a custom operator. When you reach the parameters, in should be offered as a completion.

Bugs this fixes

Fixes #24079

Workarounds, if any

Type in despite lack of completion.

Risk

Performance impact

Low. Adding a syntax kind check to a method that is used for recommending in. That method is only used by similar recommenders (out and such) and those skip the new logic.

Is this a regression from a previous update?

No.

How was the bug found?

Reported by customer.

@jcouv jcouv added the Area-IDE label Jan 7, 2018
@jcouv jcouv added this to the 15.6 milestone Jan 7, 2018
@jcouv jcouv self-assigned this Jan 7, 2018
@jcouv jcouv requested a review from a team as a code owner January 7, 2018 19:33
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)
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member Author

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 and ref in places where they are not applicable.
Sure. I'll remove the parameter.

Copy link
Member

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.

@jcouv
Copy link
Member Author

jcouv commented Jan 8, 2018

@dotnet/roslyn-ide for review. Thanks

{
await VerifyAbsenceAsync(
await VerifyKeywordAsync(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❗️ params is not valid in this context (CS1670).

public async Task TestNotAfterOperator()
{
await VerifyAbsenceAsync(
await VerifyKeywordAsync(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❗️ out is not valid in this context (CS0631).

{
await VerifyAbsenceAsync(
await VerifyKeywordAsync(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❗️ ref is not valid in this context (CS0631).

@sharwell
Copy link
Member

sharwell commented Jan 8, 2018

@jcouv Considering we were not working around a performance problem, I'd rather implement this correctly instead of approximately (i.e. revert the last commit which caused regressions for ref, out, and params).

@jcouv
Copy link
Member Author

jcouv commented Jan 8, 2018

I'll let @CyrusNajmabadi comment. I don't know what is the general rule for recommenders in terms of simplicity vs. tightness trade-offs.

@CyrusNajmabadi
Copy link
Member

The general rule was: whatever i felt like when i originally implemented it :D

The next most general was: the more parameters i needed to add, and the more special cases, the less i wanted to do it.

This started out simply a long time ago: If method/constructor do X. Now it's a lot of different cases and stuff to try to continually maintain as the language becomes more permissive. I think it's reasonable to just say "when typing arguments, let people write this". Importantly, the completion list doesn't serve to tell you exactly what's legal, but to help speed up typing. That's still accomplished even when extra items are shown.

--

Then again. I don't really care. if @sharwell feels even slightly strong about this, that's fine with me :)

@jcouv
Copy link
Member Author

jcouv commented Jan 9, 2018

@sharwell Removed the second commit. Please review. Thanks
I'll also retarget to new 15.6 branch.

@jcouv jcouv changed the base branch from master to dev15.6.x January 9, 2018 03:10
@jcouv
Copy link
Member Author

jcouv commented Jan 9, 2018

Retest windows_debug_vs-integration_prtest please

@jcouv
Copy link
Member Author

jcouv commented Jan 9, 2018

Retest ubuntu_14_debug_prtest please

@jcouv
Copy link
Member Author

jcouv commented Jan 9, 2018

@Pilchie for approval. Thanks
(Sam notified infra about the ubuntu14 issue which is affecting multiple PRs)

@Pilchie
Copy link
Member

Pilchie commented Jan 9, 2018

Approved - but needs to be retargeted to the 15.6 branch if you want to ship in that release.

@jcouv
Copy link
Member Author

jcouv commented Jan 9, 2018

@Pilchie This PR was already retargeted to dev15.6.x branch. I'll go ahead and merge. Thanks

@jcouv jcouv merged commit bb5d373 into dotnet:dev15.6.x Jan 9, 2018
@jcouv jcouv deleted the in-completion branch January 9, 2018 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants