-
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
Remove duplicate listing of Symbols #3452
Remove duplicate listing of Symbols #3452
Comments
I'm able to reproduce this by creating a multi-module Maven project where modules have different compiler requirements. For example, one project has source/target 1.8 while another has 17. When I search for [
...
...
{
"name": "ArrayList",
"kind": 5,
"location": {
"uri": "jdt://contents/rt.jar/java.util/ArrayList.class?=com.example.project-eight-my-app/%5C/usr%5C/lib%5C/jvm%5C/java-1.8.0-openjdk-1.8.0.392.b08-7.fc39.x86_64%5C/jre%5C/lib%5C/rt.jar=/javadoc_location=/https:%5C/%5C/docs.oracle.com%5C/javase%5C/8%5C/docs%5C/api%5C/=/=/maven.pomderived=/true=/%3Cjava.util(ArrayList.class",
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 0,
"character": 0
}
}
},
"containerName": "java.util"
},
{
"name": "ArrayList",
"kind": 5,
"location": {
"uri": "jdt://contents/java.base/java.util/ArrayList.class?=com.example.project-two-my-app/%5C/usr%5C/lib%5C/jvm%5C/java-17-openjdk%5C/lib%5C/jrt-fs.jar%60java.base=/javadoc_location=/https:%5C/%5C/docs.oracle.com%5C/en%5C/java%5C/javase%5C/17%5C/docs%5C/api%5C/=/=/maven.pomderived=/true=/%3Cjava.util(ArrayList.class",
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 0,
"character": 0
}
}
},
"containerName": "java.util"
}
] In your case, the paths probably look even more similar because in your case, the 2 JREs are above version 9 (so it'd be a module path). If you can confirm that's what's happening in your case, I think this still raises a good point. If someone has 2 Types (or even visible member) coming from different libraries that look identical, we should probably add version information to how its displayed to make it more clear. |
My java project is based off a maven project, I am only using java 21. As for a working solution, I makes sense to see items from the version used in the project. It's possible the local installed version of java could differ from the one the project is getting built with and run off. As a developer, I only care for what the version the project is based on, which could be:
I use SDKMAN to install different java versions, but I don't think this is the cause of what getting shown in vscode for symbols. I'm not sure how VSCode determines where to find the java/jdk to use? Not sure what is setting JAVA_BINDIR, JAVA_ROOT value? or is VSCode even uses these values. $ set|grep JAVA
JAVA_BINDIR=/usr/lib64/jvm/jre-openjdk/bin
JAVA_HOME=/home/yadav/.sdkman/candidates/java/current
JAVA_ROOT=/usr/lib64/jvm/jre-openjdk
$ set|grep JRE
JRE_HOME=/home/yadav/.sdkman/candidates/java/current/bin SDKMAN version: $ sdk current java
Using java version 21-tem Current java version $ java -version
openjdk version "21" 2023-09-19 LTS
OpenJDK Runtime Environment Temurin-21+35 (build 21+35-LTS)
OpenJDK 64-Bit Server VM Temurin-21+35 (build 21+35-LTS, mixed mode, sharing) Maven POMProject java version is set to 21 <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.1</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.ninja</groupId>
<artifactId>collection</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>h2-jpa-maven</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project> Let me know if there is any other investigation I can help with, like any log file or debug output vscode might show. |
That
(you can search for "query": "ArrayList" as a search term, and everything below it should be elements that matched that query.) You should probably see 2 entries (among a few others) whose
which are clearly |
Hi here is what I am seeing
|
The 2 entries aren't duplicates though. One is |
So why does vscode show each 2 times in the snapshot? |
@rajinder-yadav was the trace you pasted really complete? Please attach the entire json response |
I can reproduce this. I took a single-module Maven project and simply set the compiler runtime to something other than 17. It's also reproducible with Gradle.
The interesting part is : You were right @fbricon , it looks like the default project's classpath is part of the search. I would guess it should be disabled when the project isn't invisible.. or it should also react to the change to keep everything the same. I wouldn't mind having @rajinder-yadav post that extra symbol data to confirm but this is very likely the cause. |
|
Thanks! Yup, it looks like the same issue. Your "collections" project is configured with Java 21 but the "default" project (jdt.ls-java-project) is set to Java 11.
There's 2 things we should probably do as part of this :
|
Type: Bug
When searching for Symbols in workspace, IDE will show duplicates.
Open a Java source file, then perform a Symbol lookup in the workspace.
Search for "ArrayList" and you will see several duplicates in the list.
Extension version: 1.25.1
VS Code version: Code - Insiders 1.86.0-insider (9621add46007f7a1ab37d1fce9bcdcecca62aeb0, 2023-12-20T05:36:34.875Z)
OS version: Linux x64 6.6.7-1-default
Modes:
System Info
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
A/B Experiments
The text was updated successfully, but these errors were encountered: