microsoft / vscode-java-dependency

Manage Java projects in Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-dependency
MIT License
140 stars 68 forks source link

[Navigation] - When navigating to Library Inner Class/Interface it won't sync Java projects View #833

Open mamilic opened 2 months ago

mamilic commented 2 months ago

Type: Bug

Steps:

  1. Clone this project https://github.com/nipafx/nox.zone
  2. Navigate to JDK StringTemplate.class
  3. Go to 447 line of code, Processor<StringTemplate, RuntimeException> RAW = st -> st;
  4. CTRL + Left Click to naviagate to Processor interface

After navigating to Processor it will lose sync with Java Projects view, and will open a new tab with StringTemplate$Processor.class file. While it is poiting to correct line of code where Processor is located, it should not open a new tab, it should navigate to StringTemplate.class.

Extension version: 0.23.6 VS Code version: Code 1.89.0 (b58957e67ee1e712cebf466b995adf4c5307b2bd, 2024-05-01T02:08:25.066Z) OS version: Linux x64 6.8.9-zen1-1-zen Modes:

System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 5 PRO 4650U with Radeon Graphics (12 x 3990)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|2, 2, 2| |Memory (System)|38.55GB (22.61GB free)| |Process Argv|| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|gnome| |XDG_CURRENT_DESKTOP|GNOME| |XDG_SESSION_DESKTOP|gnome| |XDG_SESSION_TYPE|wayland|
jdneo commented 2 months ago

Looks like it's something related with the upsteam JDT. Looks like it is not aware that they belong to the same source file, though the compiled class files are two different ones.


Update:

It's because in the implementation, StringTemplate and StringTemplate$Processor points to two different uris(with jdt scheme). So far there is no good way to determine whether they actually points to the same source file, since $ is a valid character for the class name as well.

One workaround I'm thinking is that when it comes to a class with name containing $, try to get the source of that class file and the source of the class file without $xxx if it's available. And compare the source to check if they come from the same source file.

rgrunber commented 1 month ago

Some possible limitations with classes containing '$' in the name : https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2441 to be aware of.