Skip to content

Commit 8565a6b

Browse files
committed
refactor: scope stack-trace linkify to untitled documents only
Drop the `log` language and `**/*.log` selectors so linkification only targets pasted traces in untitled (scratch) documents. A `.log` opened without a Java project can't resolve frames anyway, so scanning them (or every plaintext file) adds no value. Keeps the feature narrow to the two intended paste flows: a new tab and the Analyze Stack Trace command. Copilot-Session: d80e7a97-119d-4f89-a02a-be25b076e806
1 parent 96ed5c6 commit 8565a6b

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/stackTraceLinkProvider.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,19 @@ import { getJavaExtensionAPI, isJavaExtEnabled, ServerMode } from "./utility";
1111
const ANALYZE_STACK_TRACE_COMMAND = "java.debug.analyzeStackTrace";
1212
const NAVIGATE_TO_STACK_FRAME_COMMAND = "_java.debug.navigateToStackFrame";
1313

14-
// Documents we linkify: pasted traces (untitled), the `log` language, and `.log` files. Kept
15-
// narrow on purpose so we don't scan every plaintext file the user opens.
14+
// Only linkify pasted traces in untitled (scratch) documents - including the one opened by the
15+
// `Analyze Stack Trace` command. Kept deliberately narrow: a `.log` opened without a Java project
16+
// couldn't resolve anyway, so we don't scan `.log` files or every plaintext file the user opens.
1617
const STACK_TRACE_DOCUMENT_SELECTOR: DocumentSelector = [
1718
{ scheme: "untitled" },
18-
{ language: "log" },
19-
{ pattern: "**/*.log" },
2019
];
2120

2221
// Matches a Java stack frame such as `at module/com.foo.Bar.baz(Bar.java:42)`.
2322
// Group 2: optional module prefix, group 3: fully-qualified method, group 5: `File.java:line`.
2423
const STACK_FRAME_REGEX = /(\sat\s+)([\w$.]+\/)?(([\w$]+\.)+[<\w$>]+)\(([\w-$]+\.java:\d+)\)/;
2524

2625
// Guard against pathological input: cap the length of a scanned line (mitigates ReDoS on the
27-
// nested-quantifier regex) and the number of links produced for very large logs.
26+
// nested-quantifier regex) and the number of links produced for very large pasted traces.
2827
const MAX_SCANNED_LINE_LENGTH = 1000;
2928
const MAX_LINKS_PER_DOCUMENT = 2000;
3029

@@ -41,10 +40,10 @@ interface IStackFrameLinkArgs {
4140
}
4241

4342
/**
44-
* Linkifies Java stack frames in text documents (e.g. pasted traces or opened `.log` files),
45-
* so that each frame can be clicked to jump to the corresponding source line - without requiring
46-
* an active debug session. Resolution reuses the session-independent `resolveSourceUri` backend
47-
* and is performed lazily, only when a link is clicked.
43+
* Linkifies Java stack frames pasted into untitled (scratch) documents, so that each frame can be
44+
* clicked to jump to the corresponding source line - without requiring an active debug session.
45+
* Resolution reuses the session-independent `resolveSourceUri` backend and is performed lazily,
46+
* only when a link is clicked.
4847
*/
4948
export class JavaStackTraceLinkProvider implements DocumentLinkProvider {
5049
public provideDocumentLinks(document: TextDocument, token: CancellationToken): ProviderResult<DocumentLink[]> {

0 commit comments

Comments
 (0)