1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

new console api

This commit is contained in:
David Inglis 2004-03-12 16:06:02 +00:00
parent cde152c3d0
commit 2469b15201
4 changed files with 33 additions and 18 deletions

View file

@ -1,3 +1,11 @@
2004-03-12 David Inglis
Improved IConsole API to support multiple streams.
* src/org/eclipse/cdt/core/CCorePlugin.java
* src/org/eclipse/cdt/core/ConsoleOutputStream.java
* src/org/eclipse/cdt/core/resources/IConsole.java
2004-03-09 David Inglis 2004-03-09 David Inglis
Don't error in CDescriptorManager.configure() when project is created twice with the same owner id. Don't error in CDescriptorManager.configure() when project is created twice with the same owner id.

View file

@ -5,6 +5,7 @@ package org.eclipse.cdt.core;
* All Rights Reserved. * All Rights Reserved.
*/ */
import java.io.IOException;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -456,13 +457,27 @@ public class CCorePlugin extends Plugin {
} }
} catch (CoreException e) { } catch (CoreException e) {
} }
return new IConsole() { return new IConsole() { // return a null console
public void clear() { private ConsoleOutputStream nullStream = new ConsoleOutputStream() {
} public void write(byte[] b) throws IOException {
}
public void write(byte[] b, int off, int len) throws IOException {
}
public void write(int c) throws IOException {
}
};
public void start(IProject project) { public void start(IProject project) {
} }
// this can be a null console....
public ConsoleOutputStream getOutputStream() { public ConsoleOutputStream getOutputStream() {
return new ConsoleOutputStream(); return nullStream;
}
public ConsoleOutputStream getInfoStream() {
return nullStream;
}
public ConsoleOutputStream getErrorStream() {
return nullStream;
} }
}; };
} }
@ -475,7 +490,7 @@ public class CCorePlugin extends Plugin {
IBinaryParser parsers[] = null; IBinaryParser parsers[] = null;
if (project != null) { if (project != null) {
try { try {
ICDescriptor cdesc = (ICDescriptor) getCProjectDescription(project); ICDescriptor cdesc = getCProjectDescription(project);
ICExtensionReference[] cextensions = cdesc.get(BINARY_PARSER_UNIQ_ID, true); ICExtensionReference[] cextensions = cdesc.get(BINARY_PARSER_UNIQ_ID, true);
if (cextensions.length > 0) { if (cextensions.length > 0) {
ArrayList list = new ArrayList(cextensions.length); ArrayList list = new ArrayList(cextensions.length);
@ -719,7 +734,7 @@ public class CCorePlugin extends Plugin {
IScannerInfoProvider provider = null; IScannerInfoProvider provider = null;
if (project != null) { if (project != null) {
try { try {
ICDescriptor desc = (ICDescriptor) getCProjectDescription(project); ICDescriptor desc = getCProjectDescription(project);
ICExtensionReference[] extensions = desc.get(BUILD_SCANNER_INFO_UNIQ_ID, true); ICExtensionReference[] extensions = desc.get(BUILD_SCANNER_INFO_UNIQ_ID, true);
if (extensions.length > 0) if (extensions.length > 0)
provider = (IScannerInfoProvider) extensions[0].createExtension(); provider = (IScannerInfoProvider) extensions[0].createExtension();

View file

@ -20,27 +20,18 @@ public class ConsoleOutputStream extends OutputStream {
fBuffer= new StringBuffer(); fBuffer= new StringBuffer();
} }
public synchronized String readBuffer() { public synchronized String readBuffer() {
String buf = fBuffer.toString(); String buf = fBuffer.toString();
fBuffer.setLength(0); fBuffer.setLength(0);
return buf; return buf;
} }
public void clear() {
fBuffer.setLength (0);
}
public synchronized void write(int c) throws IOException { public synchronized void write(int c) throws IOException {
byte ascii[] = new byte[1]; byte ascii[] = new byte[1];
ascii[0] = (byte) c; ascii[0] = (byte) c;
fBuffer.append(new String(ascii)); fBuffer.append(new String(ascii));
} }
public synchronized void write(byte[] b) throws IOException {
fBuffer.append(new String(b));
}
public synchronized void write(byte[] b, int off, int len) throws IOException { public synchronized void write(byte[] b, int off, int len) throws IOException {
fBuffer.append(new String(b, off, len)); fBuffer.append(new String(b, off, len));
} }

View file

@ -10,8 +10,9 @@ import org.eclipse.core.resources.IProject;
public interface IConsole { public interface IConsole {
ConsoleOutputStream getOutputStream();
void start(IProject project); void start(IProject project);
void clear(); ConsoleOutputStream getOutputStream();
ConsoleOutputStream getInfoStream();
ConsoleOutputStream getErrorStream();
} }