java.project.sourcePaths Setting Fails to Exclude Test Directory from References and Call Hierarchy

Open
#1,408 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java, vscode

Research direction

Start by reproducing the issue in a Maven-style Java project with src/main/java and src/test/java, using java.project.sourcePaths in settings.json. Compare Find All References and Call Hierarchy results after running Java: Clean Language Server Workspace with the Java Projects view; the work is done when unspecified directories such as src/test/java are consistently excluded. No repository file or test is identified in the issue.

Written by the indexing model from the issue text.

Description

ai-triaged bug language-server

Description
Describe the bug

When configuring the java.project.sourcePaths setting in settings.json to exclude the test directory (e.g., src/test/java) from being indexed, the "Find All References" and "Call Hierarchy" features still include results from the test directory. This persists even after cleaning the language server workspace and restarting VS Code.

To Reproduce

Steps to reproduce the behavior:

Open a Java project in VS Code (e.g., a Maven project with src/main/java and src/test/java).
Add the following to settings.json (workspace scope):
json
Wrap
Copy
{
"java.project.sourcePaths": ["src/main/java"]
}
Run Java: Clean Language Server Workspace and restart VS Code.
Right-click a class in src/main/java and select "Find All References" or "Call Hierarchy."
Observe that references from src/test/java are still included in the results.
Expected behavior

The java.project.sourcePaths setting should limit the scope of "Find All References" and "Call Hierarchy" to only the specified directories (e.g., src/main/java), excluding src/test/java.

Actual behavior

References and call hierarchy results still include files from src/test/java, despite the java.project.sourcePaths configuration.

Environment

OS: [e.g., Windows 11, macOS 14, Ubuntu 22.04]
VS Code version: [e.g., 1.87.0]
Java extension version: [e.g., redhat.java v1.XX.X]
JDK version: [e.g., OpenJDK 17]
Project type: [e.g., Maven, Gradle, or plain Java project]
Additional context

No .classpath file exists in the project.
Cleaning the language server cache (Java: Clean Language Server Workspace) and manually deleting the cache folder (e.g., ~/.vscode/extensions/redhat.java-/server/data) did not resolve the issue.
The project structure is standard (e.g., src/main/java for source, src/test/java for tests).
Possible workaround

Manually removing src/test/java from the source path via the "Java Projects" view works temporarily, but this is not a persistent solution across sessions.

Suggested fix

Ensure the java.project.sourcePaths setting is respected by the language server when generating references and call hierarchy, excluding unspecified directories like src/test/java.

Dominant language
TypeScript
Stars
352
Forks
166
Avg merge
17h 47m
Merged PRs (30d)
32

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/vscode-java-pack

All issues in microsoft/vscode-java-pack

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.