eclipse-jdt / eclipse.jdt.ui

Eclipse Public License 2.0
37 stars 92 forks source link

Enable code mining for method references by default #1802

Open vogella opened 3 days ago

vogella commented 3 days ago

Code minings in Eclipse are hard to discover for users, other IDEs enable (some) of them by default, hence making it obvious that they have it. In a recent workshop my clients were really surprised that the Eclipse IDE also has these.

I setting which I find useful and non-disruptive is the display of a method usage on top of methods.

image

Maybe we should enable this by default? This would signal to the user that we also support this.

cc @mickaelistria @jjohnstn

jukzi commented 3 days ago

I had tried code mining once and disabled it because it behaved slow and looked more like an animation then a static text editor. Just tried it again with the setting suggested: while scrolling through a .java file it constantly moves lines around inserting the "x reference" Lines. I would only use it if it would not move lines around (possibly reserving the needed space ahead until number is available). It does not give enough value to justify the distraction.

mickaelistria commented 3 days ago

For some cases, like error reports or parameter names, I do love code mining because they give me an information I almost always find useful while reading code. However I think that the "references" code mining is pretty useless to me in most cases; particularly if I already have a warning for unused variables/methods (the only case I care about is "0 reference" and is already reported as warning). So if only one code mining were to be enabled by default, I would instead suggest the error markers and/or method parameter names. However, the implementation of code minings can still sometimes slightly annoying as described by @jukzi (and several concrete issues against eclipse.platform.ui repo). Note that some of the concerns mentioned above might have been fixed in the meantime and stand not true any more so they should be verified and confirmed before making them a criterion of a decision. For example the scrolling strategy got improved a couple of years ago so the line that has caret shouldn't move usually.

jukzi commented 3 days ago

Thanks for the suggestion @vogella. I would really like to see a seamlessly working parameter name! Unfortunately it is not yet seamlessly working for me though :-(

vogella commented 3 days ago

I find the parameter name code mining super annoying during development and super helpful during reading code. The method reference annotation is the only one I find always super helpful, as it allows me to navigate to the callers of the code and I see if a public method is not called in the workspace (can therefore can be deleted in most client implementations as they rarely define external API).

HannesWell commented 2 days ago

AFAIK another issue with displaying the number of references is that it can require a lot of computational resources for public methods.

But if everything would work well it would be nice to have.