Skip to content

fix: prefer sourcePaths before JDT source URIs#629

Merged
wenytang-ms merged 2 commits into
mainfrom
fix/sourcepaths-before-jdt
Jun 9, 2026
Merged

fix: prefer sourcePaths before JDT source URIs#629
wenytang-ms merged 2 commits into
mainfrom
fix/sourcepaths-before-jdt

Conversation

@wenytang-ms

@wenytang-ms wenytang-ms commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #455.

Summary

  • Prefer debug sourcePaths before returning non-file JDT source URIs such as jdt://.
  • Preserve the existing jdt:// fallback when no matching source file exists in sourcePaths.
  • Convert sourcePaths matches to the client-requested path format and use a null-safe SourceType comparison.
  • Add regression coverage for cached JDT URI results, URI clients, and null source types.

Validation

  • mvn -pl com.microsoft.java.debug.core -Dtest=StackTraceRequestHandlerTest test
  • mvn -pl com.microsoft.java.debug.core test
  • mvn -pl com.microsoft.java.debug.core checkstyle:check '-Dcheckstyle.includes=src/test/java/com/microsoft/java/debug/core/adapter/handler/StackTraceRequestHandlerTest.java'

Note: full core checkstyle still fails on existing CRLF baseline issues outside this change.

When JDT source lookup returns a non-file URI, check debug sourcePaths before returning that URI to the client.

Add a regression test covering cached JDT URI results being overridden by sourcePaths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates stack trace source resolution so that when the debugger/JDT source lookup yields a non-file URI (e.g., jdt://...), the adapter will first attempt to resolve a real local source file via user-provided sourcePaths, while keeping the existing URI fallback when no local match exists.

Changes:

  • Prefer resolving sources from sourcePaths before returning non-file: URIs from the source lookup cache.
  • Refactor source resolution into small helper methods (getSourceReference, resolveSourceFromSourcePaths).
  • Add a regression test ensuring a cached jdt:// source can be overridden by sourcePaths when a matching local file exists.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/StackTraceRequestHandler.java Adjusts source selection order to prefer sourcePaths over non-file URIs; refactors helper logic.
com.microsoft.java.debug.core/src/test/java/com/microsoft/java/debug/core/adapter/handler/StackTraceRequestHandlerTest.java Adds regression coverage for cached jdt:// URIs being overridden by sourcePaths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Use a null-safe SourceType comparison and convert sourcePaths matches to the client's expected path format.

Extend regression coverage for URI clients and null source types.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@wenytang-ms wenytang-ms changed the title Prefer sourcePaths before JDT source URIs fix: prefer sourcePaths before JDT source URIs Jun 9, 2026
@wenytang-ms wenytang-ms merged commit 3f03453 into main Jun 9, 2026
4 checks passed
@wenytang-ms wenytang-ms deleted the fix/sourcepaths-before-jdt branch June 9, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sourcePaths no longer work after #354

3 participants