vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

"Go to symbol" should prioritize local classes

Open gsturov opened this issue 1 year ago • 1 comments

I have local Start class in my source code. When I use "Go to symbol" dialog to navigate to that class and type "Start" I have a bunch of Start classes from different libs on the top of the list and my class on the bottom. The assumption should be that by default I am interested in my own class, so that class should be on the top of the list.

gsturov avatar Jun 05 '24 15:06 gsturov

I think the client itself (VS Code ) is controlling this. We have had issues in the past simply getting the client to show certain symbols we felt should be included (eg. *) that the client interpreted literally. See also issues like https://github.com/microsoft/vscode/issues/98125 .

Here's the order of elements from the language server for a given example :

sun.security.tools.jarsigner.Main
com.sun.tools.script.shell.Main
jdk.jfr.internal.tool.Main
sun.net.httpserver.simpleserver.Main
com.sun.tools.jdeps.Main
sun.security.tools.keytool.Main
javax.swing.colorchooser.DefaultSwatchChooserPanel.MainSwatchListener
jdk.jpackage.main.Main
com.sun.tools.javac.Main
jdk.internal.misc.MainMethodFinder
com.sun.tools.javac.main.Main
com.sun.tools.javap.Main
jdk.tools.jlink.internal.Main
javax.swing.colorchooser.DefaultSwatchChooserPanel.MainSwatchKeyListener
com.sun.tools.javac.launcher.Main
jdk.tools.jimage.Main
jdk.tools.jmod.Main
sun.tools.jar.Main
org.example.Main
jdk.javadoc.internal.tool.Main
org.example.Main.main
sun.jvm.hotspot.utilities.WorkerThread.MainLoop
javax.swing.colorchooser.MainSwatchPanel
com.sun.tools.jdeprscan.Main
com.sun.tools.javac.launcher.Main.MainClassListener

and here's the actual displayed order :

image

rgrunber avatar Jun 06 '24 14:06 rgrunber

I would love to see this corrected. It's waste of extra keystrokes, plus you end up with glassy eyes when what you expect is not sorted closes to the top, and you need to scan the entire unsorted list.

I use symbol lookup frequently to see other class APIs.

rajinder-yadav avatar Jan 07 '25 21:01 rajinder-yadav

@rajinder-yadav Is it still an issue? It seems to work fine for me. My local com.example.deno.Start class comes 1st.

Image

I even tried changing the package name to xom.* and it still shows on top.

fbricon avatar Oct 14 '25 09:10 fbricon

@fbricon yes, the sorting looks correct, thanks!

Image

rajinder-yadav avatar Oct 15 '25 22:10 rajinder-yadav

@rajinder-yadav your screenshot is not showing local classes 1st. But if you think this is no longer an issue, I'll close this one.

fbricon avatar Oct 16 '25 07:10 fbricon

@fbricon I think it's safe to close, there was no local Arrays in the project I did a check in. However I try again with a local class #Student and it seems to be sorted and appears at the top correctly.

Image

rajinder-yadav avatar Nov 02 '25 09:11 rajinder-yadav