-
Notifications
You must be signed in to change notification settings - Fork 454
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
Some parameter names of method invocations are not useful #2412
Comments
It's a new feature introduced in 1.5.0, called If you do not want to have them in your editor, you can set the setting |
There are also inlay hints in Line 6 ~ Line 10, but user is not complaining about it, because they do provide useful information. Just some thoughts, shall we maintain a list and hardcode to exclude system.out.print/println? as inlay hints for these functions don't provide much help. |
Sure, an exclude list can be added for such case, which is also the way that IntelliJ and Eclipse do. |
It would be great to also add a right-click context menu to ignore some of the methods we wrote. |
Thank you :) |
Would it be safe to assume that a 1 or 2 character length parameter hint is useless and just hide those ? I don't think Eclipse has an exclude list. I checked the preferences and only saw the ability to enable/disable whether parameter names are shown. They do ignore methods with only 1 parameter though. |
The Eclipse embedded code miningonly contains basic support, so it does not have the exclude list. But it can be available once the jdt code mining plugin is installed. |
I also think that we should not display parameters that only have 1 or 2 characters, and I think we should not display an inlay hint when there is only one parameter (at least have a setting for the latter). |
Looks good to me to have a setting for that. Or maybe just hide it and wait for users' feedback.
It makes sense to me to hide parameters only have 1 char. While I'm not sure about 2 characters. Since there are still some words with 2 characters which have a clear meaning. For example: |
So ideally :
We can definitely adopt (1) & (2) with no settings and see later if users want further options. (3) would be nice if possible, especially given the code is mostly written. |
After discussing with the team, we think (3) should be the final goal we would like to achieve. The reason is that we still can figure out some cases that option (1) and (2) cannot satisfied. option (1)Think about the constructor of ArrayList: Here though the invocation has only one parameter but it's still helpful to tell user that the integer denotes for the capacity. option (2)Imagine that for a GUI application, it may have some APIs like this: Here though |
I guess with (1), part of my assumption is that any ambiguity in what the parameter represents would be cleared up by the name of the method. I'm open to removing this restriction, though even the example, being a constructor, for a class that stores multiple elements is a hint at some form of size. Also this case doesn't suffer from the issue of having to guess the order of parameters, which is really where this feature starts to shine. Agreed that showing the counter-example for (2) is a benefit. The method name, parameter types, and implicit assumption about ordering (x before y) does help a bit. Like you said, I think (3) will ultimately solve our problems. |
I'll try to support the exclusion list for the inlay hint in this month |
I also found another interesting example: camel case and snake case should be considered as matching (suppressWhenArgumentMatchesName). |
Thanks @gruvw That could be another improvement for the logic here: https://github.com/eclipse/eclipse.jdt.ls/blob/2130d70af2c39cbf7c6da825f89580456361608a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/InlayHintVisitor.java#L274 |
It looks like the feature by default is empty, so going forward we may want to collect a list of values to exclude. Maybe even just use the |
Just a comment on this issue as a new user: hiding short parameter hints makes sense, but the real problem that I had (and that the creator of this issue had) is that to a new user it might be completely unclear as to what these annotations are. Although they are used in several IDEs, if you haven't come across them before they are confusing. If it's possible to have some kind of hovertext or right click information just to say "this is an inlay hint", that would be enough information for a user to find out what they are and disable them if wanted. |
I just tried this modification and it works : diff --git a/src/inlayHintsProvider.ts b/src/inlayHintsProvider.ts
index e409343..43c7c09 100644
--- a/src/inlayHintsProvider.ts
+++ b/src/inlayHintsProvider.ts
@@ -91,5 +91,6 @@ function asInlayHint(value: LSInlayHint, client: LanguageClient): InlayHint {
const result = new InlayHint(client.protocol2CodeConverter.asPosition(value.position), label);
result.paddingRight = true;
result.kind = InlayHintKind.Parameter;
+ result.tooltip = 'This is an inlay hint. This is not a drill.';
return result;
} We could also do it properly on the JDT-LS side with the inlay hints proposed API. and it'll work. Supported by https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#inlayHint . @jdneo , do you really see a sizeable amount of users confused by inlay hints currently ? |
I didn't see many feedbacks about inlay hint recently. Let's track it as a feature request first: #2691 |
[provide a description of the issue]
I was getting an error saying .java file was not a project file. I looked it up and it said to use Clean java language server, after I did that these were highlighted things like s: and x: are showing up randomly throughout my code. Its not the biggest deal its just distracting. I uninstalled all of the extensions and deleted VScode itself but that didn't work.
Environment
Issue Type: Performance Issue
I was trying to get rid of the error saying .Java is a non-project file and saw something that suggested Clean Java Server Workspace. After selecting that my code has things all over the place such as "x:" in my println, "s:" in my print and my variable names showing up in parameters. I've completly deleted all vs code files but when I downloaded it back it was still here. Please help
VS Code version: Code 1.66.2 (Universal) (dfd34e8260c270da74b5c2d86d61aee4b6d56977, 2022-04-11T07:49:20.994Z)
OS version: Darwin arm64 21.4.0
Restricted Mode: No
System Info
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Process Info
Workspace Info
Extensions (15)
A/B Experiments
Steps To Reproduce
[Please attach a sample project reproducing the error]
Please attach logs
Current Result
System.out.println(x:"random thing");
Expected Result
System.out.println("random thing");
Additional Informations
You can't delete the things either. Im sorry if I messed anything up this is my first time filing a report.
The text was updated successfully, but these errors were encountered: