|
28 | 28 | import org.eclipse.core.runtime.CoreException; |
29 | 29 | import org.eclipse.core.runtime.FileLocator; |
30 | 30 | import org.eclipse.core.runtime.IPath; |
| 31 | +import org.eclipse.core.runtime.IStatus; |
| 32 | +import org.eclipse.core.runtime.Status; |
31 | 33 | import org.eclipse.debug.core.DebugEvent; |
32 | 34 | import org.eclipse.debug.core.DebugPlugin; |
33 | 35 | import org.eclipse.debug.core.ILaunch; |
34 | 36 | import org.eclipse.debug.core.ILaunchConfiguration; |
35 | 37 | import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
36 | 38 | import org.eclipse.debug.core.ILaunchManager; |
37 | 39 | import org.eclipse.debug.core.model.IProcess; |
| 40 | +import org.eclipse.debug.internal.ui.views.console.ProcessConsole; |
38 | 41 | import org.eclipse.jdt.core.IJavaProject; |
39 | 42 | import org.eclipse.jdt.core.JavaCore; |
40 | 43 | import org.eclipse.jface.text.BadLocationException; |
|
45 | 48 | import org.eclipse.jface.text.Position; |
46 | 49 | import org.eclipse.swt.graphics.Color; |
47 | 50 | import org.eclipse.swt.widgets.Display; |
| 51 | +import org.eclipse.ui.console.ConsolePlugin; |
| 52 | +import org.eclipse.ui.console.IConsole; |
| 53 | +import org.eclipse.ui.console.IConsoleManager; |
48 | 54 | import org.eclipse.ui.console.IHyperlink; |
49 | 55 | import org.eclipse.ui.internal.console.ConsoleHyperlinkPosition; |
50 | 56 | import org.eclipse.ui.internal.console.IOConsolePartition; |
@@ -85,6 +91,7 @@ public static Object launchAndWait(ILaunchConfiguration configuration, DebugEven |
85 | 91 | ILaunch launch = configuration.launch(ILaunchManager.RUN_MODE, null); |
86 | 92 | Object suspendee = waiter.waitForEvent(); |
87 | 93 | if (suspendee == null) { |
| 94 | + logProcessConsoleContents(); |
88 | 95 | try { |
89 | 96 | launch.terminate(); |
90 | 97 | } |
@@ -334,4 +341,23 @@ public static IHyperlink getHyperlink(int offset, IDocument doc) { |
334 | 341 | public static void activateLink(final IHyperlink link) { |
335 | 342 | Display.getDefault().asyncExec(() -> link.linkActivated()); |
336 | 343 | } |
| 344 | + |
| 345 | + public static void logProcessConsoleContents() { |
| 346 | + try { |
| 347 | + StringBuilder buf = new StringBuilder(); |
| 348 | + IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager(); |
| 349 | + for (IConsole console : manager.getConsoles()) { |
| 350 | + if (console instanceof ProcessConsole) { |
| 351 | + ProcessConsole processConsole = (ProcessConsole) console; |
| 352 | + String string = processConsole.getDocument().get(); |
| 353 | + buf.append("Console output for \"" + processConsole.getName() + "\" follows:\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 354 | + buf.append(string); |
| 355 | + } |
| 356 | + } |
| 357 | + buf.append("\n"); //$NON-NLS-1$ |
| 358 | + AntUIPlugin.log(new Status(IStatus.INFO, "org.eclipse.jdt.debug.ui.tests", buf.toString())); //$NON-NLS-1$ |
| 359 | + } catch (Throwable t) { |
| 360 | + AntUIPlugin.log(t); |
| 361 | + } |
| 362 | + } |
337 | 363 | } |
0 commit comments