feat: linkify Java stack traces in text documents (#1654)#1657
Draft
wenytang-ms wants to merge 6 commits into
Draft
feat: linkify Java stack traces in text documents (#1654)#1657wenytang-ms wants to merge 6 commits into
wenytang-ms wants to merge 6 commits into
Conversation
Add a DocumentLinkProvider that makes Java stack frames clickable in untitled documents and .log files, so a trace pasted from a log/CI/bug report can be navigated to source without an active debug session. Reuses the session-independent resolveSourceUri backend; frames are resolved lazily on click, with a source-scheme allowlist and length/ReDoS guards. Also adds an optional 'Java: Analyze Stack Trace' command that opens a scratch document prefilled from the clipboard.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
… usage Add three content-free telemetry events (with __GDPR__ annotations) forming an adoption funnel: provideJavaStackTraceLinks (reach, deduped once per document), navigateToJavaStackFrame (click engagement, with documentSource + resolution outcome), and analyzeJavaStackTrace (command entry usage, with prefilledFromClipboard). All dimensions are categorical; the pasted trace text is never recorded. Also bound clipboard scanning length.
…events Simplify to one usage signal (navigateToJavaStackFrame with a documentSource dimension), mirroring the existing handleJavaTerminalLink pattern. Drop the per-document reach event (and its WeakSet) and the manual command event - command invocations are already auto-instrumented by instrumentOperationAsVsCodeCommand.
…ault Add workspaceContains:**/*.java so the passive DocumentLinkProvider is registered as soon as a Java project is opened - without waiting for the user to open a .java file or run a command. This matches exactly the scope where resolveSourceUri can resolve frames to source, so the feature is automatic wherever it can deliver value.
Frame resolution (resolveSourceUri) requires a fully-loaded workspace, so registering the document link provider before jdtls is ready produces links that cannot resolve. Defer provider registration until ServerMode.STANDARD via redhat.java's onDidServerModeChange, mirroring initializeCodeLensProvider. Commands stay registered immediately.
…lick count The single navigateToJavaStackFrame event is enough to measure adoption; the documentSource breakdown is not needed. Remove the dimension, the IStackFrameLinkArgs field, and the categorizeDocumentSource helper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1654 (draft for design review — not ready to merge).
What & why
Developers frequently receive Java stack traces from log files, CI failures, bug reports, chat messages, and production logs. Eclipse ("Java Stack Trace Console") and IntelliJ ("Analyze Stack Trace") both let you take such an external trace and click each frame to jump to source — without a running debug session. VS Code has no equivalent today: our existing linkifier only works on text that has already flowed through the integrated terminal.
This PR adds that missing surface.
Approach (passive-first, reuse-first)
DocumentLinkProvider(src/stackTraceLinkProvider.ts) linkifies stack frames on its own, mirroring howregisterTerminalLinkProvideris already wired inextension.ts.activationEventsnow includesworkspaceContains:**/*.java, so the extension wakes up as soon as a Java project is opened — the user does not have to open a.javafile first or run any command.redhat.javareachesServerMode.STANDARD(viaonDidServerModeChange), mirroringinitializeCodeLensProvider. Frame resolution goes through jdtls (resolveSourceUri), which needs a fully-loaded workspace; registering earlier would produce links that cannot resolve. Commands stay registered immediately, soJava: Analyze Stack Traceis always available and any already-open doc gets linkified the moment the server becomes ready.resolveSourceUri->vscode.java.resolveSourceUri. Zero backend changes.provideDocumentLinksonly does a cheap per-line regex and emits acommand:link; the (more expensive) source resolution runs only when a link is clicked.Java: Analyze Stack Traceopens a scratch document, prefilled from the clipboard when it looks like a trace.Scope of matching (kept narrow on purpose)
DocumentSelector =
untitled+loglanguage +**/*.log. This covers the two natural flows (paste into a new tab / open a.log) without scanning every plaintext file the user opens.Safety
file/jdt) returned by the language server.Telemetry
A single content-free event tracks usage, mirroring the existing
handleJavaTerminalLinkproxy metric:navigateToJavaStackFrame— emitted when a user clicks a linkified frame. No dimensions — just a click count for adoption. Pasted trace text / class names / paths are never recorded.The
Java: Analyze Stack Tracecommand is already auto-instrumented viainstrumentOperationAsVsCodeCommand, so no extra event is added for it.Not in scope (deliberately)
Thread-dump analysis, de-obfuscation/unscramble, dSYM, and multi-project same-named-class disambiguation (backend currently returns the first match). These are IntelliJ super-set features / a separate backend change and can be follow-ups.
How to test
at com.foo.Bar.baz(Bar.java:42)); each frame becomes a clickable link -> jumps to the source line..logcontaining a trace -> frames are linkified in place.Open questions for reviewers
.logopened with no Java project won't linkify (and couldn't resolve anyway). Do we also wantonLanguage:logactivation to cover that edge, accepting activation in non-Java windows?