Skip to content

Commit ad975c4

Browse files
authored
Regression fix in (#688)
#608 Invalid links generated with multiple spaces Fixes : #687
1 parent f523213 commit ad975c4

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

org.eclipse.jdt.debug.tests/console tests/org/eclipse/jdt/debug/tests/console/JavaStackTraceAmbiguityTest.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,59 @@ public void testLinkNavigationTrueForLinksWithMultiSpaceBeforeSignature() throws
488488
project.getProject().delete(force, new NullProgressMonitor());
489489
}
490490
}
491+
492+
public void testLinkNavigationTrueForLinksWithTimeStamps1() throws Exception {
493+
String projectName = "StackTest";
494+
IJavaProject project = createProject(projectName, "testfiles/AmbiguityTest/", JavaProjectHelper.JAVA_SE_1_8_EE_NAME, false);
495+
waitForBuild();
496+
waitForJobs();
497+
consoleDocumentWithText("250420 12:59:13.999 (SampleGenerics.java:25) Hello");
498+
IHyperlink[] hyperlinks = fConsole.getHyperlinks();
499+
assertEquals("Wrong hyperlinks, listing all links: " + allLinks(), 1, hyperlinks.length);
500+
String expectedText = "System.out.print(\"EXPECTED_GENERICS\");";
501+
try {
502+
for (IHyperlink hyperlink : hyperlinks) {
503+
closeAllEditors();
504+
hyperlink.linkActivated();
505+
IEditorPart editor = waitForEditorOpen();
506+
String[] selectedText = new String[1];
507+
sync(() -> selectedText[0] = getSelectedText(editor));
508+
selectedText[0] = selectedText[0].trim();
509+
assertEquals("Wrong text selected after hyperlink navigation", expectedText, selectedText[0]);
510+
511+
}
512+
} finally {
513+
closeAllEditors();
514+
boolean force = true;
515+
project.getProject().delete(force, new NullProgressMonitor());
516+
}
517+
}
518+
public void testLinkNavigationTrueForLinksWithTimeStamps2() throws Exception {
519+
String projectName = "StackTest";
520+
IJavaProject project = createProject(projectName, "testfiles/AmbiguityTest/", JavaProjectHelper.JAVA_SE_1_8_EE_NAME, false);
521+
waitForBuild();
522+
waitForJobs();
523+
consoleDocumentWithText("2025-04-20 12.01.23 (SampleGenerics.java:25) Hello");
524+
IHyperlink[] hyperlinks = fConsole.getHyperlinks();
525+
assertEquals("Wrong hyperlinks, listing all links: " + allLinks(), 1, hyperlinks.length);
526+
String expectedText = "System.out.print(\"EXPECTED_GENERICS\");";
527+
try {
528+
for (IHyperlink hyperlink : hyperlinks) {
529+
closeAllEditors();
530+
hyperlink.linkActivated();
531+
IEditorPart editor = waitForEditorOpen();
532+
String[] selectedText = new String[1];
533+
sync(() -> selectedText[0] = getSelectedText(editor));
534+
selectedText[0] = selectedText[0].trim();
535+
assertEquals("Wrong text selected after hyperlink navigation", expectedText, selectedText[0]);
536+
537+
}
538+
} finally {
539+
closeAllEditors();
540+
boolean force = true;
541+
project.getProject().delete(force, new NullProgressMonitor());
542+
}
543+
}
491544
private void waitForJobs() throws Exception {
492545
TestUtil.waitForJobs(getName(), 250, 10_000);
493546
}

org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/console/JavaStackTraceHyperlink.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ protected String getLinkText() throws CoreException {
726726
linkStart = line.lastIndexOf('\t', regionOffsetInLine);
727727
}
728728
String extractedTrace = line.substring(linkStart == -1 ? 0 : linkStart + 1, linkEnd + 1).trim();
729-
if (extractedTrace.charAt(0) == '(') {
729+
if (extractedTrace.charAt(0) == '(' && line.startsWith("at")) { //$NON-NLS-1$
730730
int lastOpen = line.lastIndexOf('(');
731731
if (lastOpen > 0) {
732732
if (Character.isWhitespace(line.charAt(lastOpen - 1))) {

0 commit comments

Comments
 (0)