microsoft / microsoft/vscode-java-pack

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

オープン
#1,408 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

ai-triaged bug language-server
主要言語
TypeScript
スター
352
フォーク
166
平均マージ
17時間 47分
マージ済み PR(30日)
32

説明

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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、settings.json で java.project.sourcePaths を使用し、src/main/java と src/test/java を含む Maven スタイルの Java プロジェクトで問題を再現します。Java Projects ビューで Java: Clean Language Server Workspace を実行した後、Find All References と Call Hierarchy の結果を比較します。src/test/java のような未指定のディレクトリが一貫して除外されれば作業完了です。Issue では、リポジトリのファイルやテストは特定されていません。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java, vscode
領域
developer-experience, tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。