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

Add semicolon as a commit character for object creation and symbol completion #48851

Merged
merged 41 commits into from
Nov 14, 2020

Conversation

Cosifne
Copy link
Member

@Cosifne Cosifne commented Oct 22, 2020

When trying to complete a method or a type in object creation context by a semicolon, append ();
Put the caret between parenthesis based on if the method/constructor takes a parameter.

Partially resolved #12363

Also need to sync with the intellicode team to make some similar changes to PythiaCompletionProvider.

@Cosifne Cosifne requested a review from a team as a code owner October 22, 2020 18:24
@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@Cosifne
Copy link
Member Author

Cosifne commented Oct 23, 2020

Tag @genlu in case you didn't see this PR 😀

@genlu
Copy link
Member

genlu commented Oct 23, 2020

Also need to sync with the intellicode team to make some similar changes to PythiaCompletionProvider.

In addition to that, I think this could be supported by import completion as well. For those items, we either can recover the symbol from item (for extension methods) or have the fully qualified name to find the symbol from compilation (for type).

Copy link
Member

@genlu genlu left a comment

Choose a reason for hiding this comment

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

I have some perf concerns, let's figure out if the calculation can be reduced and delay to commit time (also, it might worth to get some perf traces to confirm it.) And ideally, I'd like to implement this feature in all relevant providers to ensure a consistent user experience, at least for the ones we own if coordinating with intellicode team takes time.

Also, I remember we spent a bunch of time dogfooding the statement completion feature, do we want to do the same for this (either dogfooding private built vsix or via experiment)?

@Cosifne Cosifne requested a review from genlu November 11, 2020 20:29
@Cosifne
Copy link
Member Author

Cosifne commented Nov 12, 2020

tag @genlu in case you didn't see this

@genlu
Copy link
Member

genlu commented Nov 12, 2020

The code is much easier to understand now, thanks :)

@genlu
Copy link
Member

genlu commented Nov 12, 2020

Consider add a few tests to CSharpCompletionCommandHandlerTests. Those tests behave like semi-integration tests since they go through async completion layer as well.

@genlu
Copy link
Member

genlu commented Nov 12, 2020

LGTM, just some minor comments. Are you planning to add "." support next?

@Cosifne
Copy link
Member Author

Cosifne commented Nov 12, 2020

LGTM, just some minor comments. Are you planning to add "." support next?

@genlu
Planning to do it in a separate PR.
I think it would be almost the same as ";".

item = item
.AddProperty("SymbolKind", ((int)symbol.Kind).ToString())
.AddProperty("SymbolName", symbol.Name);

return isGeneric ? item.AddProperty("IsGeneric", isGeneric.ToString()) : item;
}

public static CompletionItem AddShouldProvideParenthesisCompletion(CompletionItem item)
Copy link
Member

Choose a reason for hiding this comment

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

Add comment that this is used like a flag so value doesn't matter

@@ -53,6 +53,9 @@ public static Task<CompletionDescription> GetDescriptionAsync(CompletionItem ite
public static CompletionDescription GetDescription(CompletionItem item)
=> CommonCompletionItem.GetDescription(item);

public static bool GetShouldProvideParenthesisCompletion(CompletionItem item)
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if you added this because you saw my (now deleted) comment, but I think this is actually unnecessary, since intelliccode controls both creation of the item and create the change

// However, for an extension method like
// static class C { public static int ToInt(this Bar b) => 1; }
// it can only be used as like: bar.ToInt();
// bar.ToInt is illegal since it can't be assign to delegate.
Copy link
Member

Choose a reason for hiding this comment

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

TIL this is not allowed :)

Copy link
Member

@genlu genlu left a comment

Choose a reason for hiding this comment

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

:shipit:

@Cosifne Cosifne merged commit d701176 into dotnet:master Nov 14, 2020
@ghost ghost added this to the Next milestone Nov 14, 2020
@allisonchou allisonchou modified the milestones: Next, 16.9.P2 Nov 24, 2020
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.

IDE: Intellisense: Insert full method call
7 participants