1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +02:00

checkLine() breaks the string in to lines and passes it to

processLine().
This commit is contained in:
Alain Magloire 2002-11-24 16:02:01 +00:00
parent b192a6f48a
commit ba1e859eba

View file

@ -288,7 +288,8 @@ public class ErrorParserManager extends OutputStream {
}
/**
* Method getInputStream.
* Method getOutputStream. It has a reference count
* the stream must be close the same number of time this method was call.
* @return OutputStream
*/
public OutputStream getOutputStream() {
@ -303,7 +304,9 @@ public class ErrorParserManager extends OutputStream {
if (nOpens > 0 && --nOpens == 0) {
fDirectoryStack.removeAllElements();
fBaseDirectory = null;
if (outputStream != null)
outputStream.close();
checkLine(true);
}
}
@ -311,15 +314,17 @@ public class ErrorParserManager extends OutputStream {
* @see java.io.OutputStream#flush()
*/
public void flush() throws IOException {
if (outputStream != null)
outputStream.flush();
}
/**
* @see java.io.OutputStream#write(int)
*/
public void write(int b) throws IOException {
public synchronized void write(int b) throws IOException {
currentLine.append((char) b);
checkLine();
checkLine(false);
if (outputStream != null)
outputStream.write(b);
}
@ -334,18 +339,28 @@ public class ErrorParserManager extends OutputStream {
return;
}
currentLine.append(new String(b, 0, len));
checkLine();
checkLine(false);
if (outputStream != null)
outputStream.write(b, off, len);
}
private void checkLine() {
String line = currentLine.toString();
if (line.endsWith("\n")) {
// Remove the training new lines.
line = line.trim();
private void checkLine(boolean flush) {
String buffer = currentLine.toString();
int i = 0;
while ((i = buffer.indexOf('\n')) != -1) {
String line = buffer.substring(0, i).trim(); // get rid of any trailing \r
processLine(line);
previousLine = line;
buffer = buffer.substring(i + 1); // skip the \n and advance
}
currentLine.setLength(0);
if (flush) {
if (buffer.length() > 0) {
processLine(buffer);
previousLine = buffer;
}
} else {
currentLine.append(buffer);
}
}
@ -365,8 +380,7 @@ public class ErrorParserManager extends OutputStream {
problem.description,
problem.severity,
problem.variableName);
}
else {
} else {
fMarkerGenerator.addMarker(
problem.file,
problem.lineNumber,