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

Introduce completion item collapse for method overloads #3053

Merged
merged 1 commit into from
Feb 22, 2024

Conversation

hopehadfield
Copy link
Contributor

@hopehadfield hopehadfield commented Feb 9, 2024

Fixes #2282

Before:
Screenshot from 2024-02-09 13-36-36

After:
Screenshot from 2024-02-09 13-37-21

The list of methods should ideally be displayed in signature help after selecting the completion item, though there exists a bug in which this isn't always the case.

@rgrunber
Copy link
Contributor

rgrunber commented Feb 13, 2024

A few oddities I noticed :

image

  • append & format show up (when typing out the first p and filtering to print) because their filterText includes PrintStream, but we now hide that (in favour of the "overloads .." section in this mode. It's something to think about. (ignore the weird bold text, that's a separate client issue)

  • When this feature is enabled, and combined with java.completion.guessMethodArguments, there is a slight difference in behaviour of which constructor gets displayed. When guessing is off, it seems like it's always the first (no-arg?) that gets displayed so that's what gets activated for signature help. When it's parameter/best-guess, it's often one of the 1-arg (or greater) options. Is this expected ?

@hopehadfield hopehadfield force-pushed the 2282-overloads branch 2 times, most recently from 88ce96a to 19d03b9 Compare February 15, 2024 17:20
@@ -319,20 +328,33 @@ private static final StringBuilder appendParameterSignature(StringBuilder buffer
*/
private void createMethodProposalLabel(CompletionProposal methodProposal, CompletionItem item) {
StringBuilder description = this.createMethodProposalDescription(methodProposal);
String proposalName = String.valueOf(methodProposal.getName());
boolean skipDetail = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you do this because you noticed that the regular detail field was being set for completion items that were using the labelDetails field, so you tried to preserve that behaviour for regular methods ? But opted to eliminate it for collapsed types ?

According to https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItem I don't really see anything that says label details make the regular detail field obsolete so I guess we opted to keep it around.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I didn't want to alter the behaviour for non-collapsed proposals, but removed it for the collapsed proposals because it contained proposal details that would only be related to one of multiple collapsed proposals. There was nothing relevant to include in the field so I just left it as null.

Copy link
Contributor

@rgrunber rgrunber Feb 22, 2024

Choose a reason for hiding this comment

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

Yeah, I guess that's fine. Also skipDetail seems to be true only when a type should be collapsed & is not a constructor so you probably could have used the exact same check, or used skipDetail even earlier to avoid the other check.

I guess I was aiming towards moving the if (!skipDetail) block into the block above, but because it's used in 2/4 cases, might as well save space like we are now.

@rgrunber rgrunber merged commit 657442b into eclipse-jdtls:master Feb 22, 2024
7 checks passed
@hopehadfield hopehadfield deleted the 2282-overloads branch April 23, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hide method overloads and return types in autocompletion
2 participants