diff options
author | Doug Schaefer | 2017-11-03 20:48:20 +0000 |
---|---|---|
committer | Doug Schaefer | 2017-11-03 20:48:20 +0000 |
commit | 87cd8401f4e36dfc25912e6c768dde2ae9caed4a (patch) | |
tree | 6aa870bd1899bc7e3bc6279c958389dc938f09af /core | |
parent | ceeac1865a9b25e7bb97142abb3ac2d4b8213dc5 (diff) | |
download | org.eclipse.cdt-87cd8401f4e36dfc25912e6c768dde2ae9caed4a.tar.gz org.eclipse.cdt-87cd8401f4e36dfc25912e6c768dde2ae9caed4a.tar.xz org.eclipse.cdt-87cd8401f4e36dfc25912e6c768dde2ae9caed4a.zip |
Hook up the error parser properly in the build configuration.
So we can have the error partitions that work with double clicking
in the build console.
Change-Id: I357f4efb8fd16232b78b18958c9863071feeebcc
Diffstat (limited to 'core')
-rw-r--r-- | core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java | 59 | ||||
-rw-r--r-- | core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java | 5 |
2 files changed, 50 insertions, 14 deletions
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java index fe55abecc93..edd0c89dd84 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java @@ -450,10 +450,37 @@ public abstract class CBuildConfiguration extends PlatformObject return null; } + @Deprecated protected int watchProcess(Process process, IConsoleParser[] consoleParsers, IConsole console) + throws CoreException { + if (consoleParsers == null || consoleParsers.length == 0) { + return watchProcess(process, console); + } else { + return watchProcess(process, consoleParsers); + } + } + + /** + * @since 6.4 + */ + protected int watchProcess(Process process, IConsole console) throws CoreException { + new ReaderThread(process.getInputStream(), console.getOutputStream()).start(); + new ReaderThread(process.getErrorStream(), console.getErrorStream()).start(); + try { + return process.waitFor(); + } catch (InterruptedException e) { + CCorePlugin.log(e); + return -1; + } + } + + /** + * @since 6.4 + */ + protected int watchProcess(Process process, IConsoleParser[] consoleParsers) throws CoreException { - new ReaderThread(process.getInputStream(), consoleParsers, console.getOutputStream()).start(); - new ReaderThread(process.getErrorStream(), consoleParsers, console.getErrorStream()).start(); + new ReaderThread(process.getInputStream(), consoleParsers).start(); + new ReaderThread(process.getErrorStream(), consoleParsers).start(); try { return process.waitFor(); } catch (InterruptedException e) { @@ -463,34 +490,42 @@ public abstract class CBuildConfiguration extends PlatformObject } private static class ReaderThread extends Thread { - private final BufferedReader in; - private final PrintStream out; private final IConsoleParser[] consoleParsers; + private final PrintStream out; - public ReaderThread(InputStream in, IConsoleParser[] consoleParsers, OutputStream out) { + public ReaderThread(InputStream in, IConsoleParser[] consoleParsers) { this.in = new BufferedReader(new InputStreamReader(in)); + this.out = null; this.consoleParsers = consoleParsers; - this.out = new PrintStream(out); } + public ReaderThread(InputStream in, OutputStream out) { + this.in = new BufferedReader(new InputStreamReader(in)); + this.out = new PrintStream(out); + this.consoleParsers = null; + } + @Override public void run() { try { for (String line = in.readLine(); line != null; line = in.readLine()) { - for (IConsoleParser consoleParser : consoleParsers) { - // Synchronize to avoid interleaving of lines - synchronized (consoleParser) { - consoleParser.processLine(line); + if (consoleParsers != null) { + for (IConsoleParser consoleParser : consoleParsers) { + // Synchronize to avoid interleaving of lines + synchronized (consoleParser) { + consoleParser.processLine(line); + } } } - out.println(line); + if (out != null) { + out.println(line); + } } } catch (IOException e) { CCorePlugin.log(e); } } - } private File getScannerInfoCacheFile() { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java index 50f28769f26..fbd3aeeddf0 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java @@ -87,6 +87,7 @@ public class StandardBuildConfiguration extends CBuildConfiguration { try (ErrorParserManager epm = new ErrorParserManager(project, getBuildDirectoryURI(), this, getToolChain().getErrorParserIds())) { + epm.setOutputStream(console.getOutputStream()); // run make console.getOutputStream().write(String.format("%s\n", String.join(" ", command))); //$NON-NLS-1$ //$NON-NLS-2$ ProcessBuilder processBuilder = new ProcessBuilder(command) @@ -94,7 +95,7 @@ public class StandardBuildConfiguration extends CBuildConfiguration { setBuildEnvironment(processBuilder.environment()); Process process = processBuilder.start(); IConsoleParser[] consoleParsers = new IConsoleParser[] { epm, this }; - watchProcess(process, consoleParsers, console); + watchProcess(process, consoleParsers); } project.refreshLocal(IResource.DEPTH_INFINITE, monitor); @@ -125,7 +126,7 @@ public class StandardBuildConfiguration extends CBuildConfiguration { .directory(getBuildDirectory().toFile()); setBuildEnvironment(processBuilder.environment()); Process process = processBuilder.start(); - watchProcess(process, new IConsoleParser[0], console); + watchProcess(process, console); project.refreshLocal(IResource.DEPTH_INFINITE, monitor); } catch (IOException e) { |