1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +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 * @return OutputStream
*/ */
public OutputStream getOutputStream() { public OutputStream getOutputStream() {
@ -303,7 +304,9 @@ public class ErrorParserManager extends OutputStream {
if (nOpens > 0 && --nOpens == 0) { if (nOpens > 0 && --nOpens == 0) {
fDirectoryStack.removeAllElements(); fDirectoryStack.removeAllElements();
fBaseDirectory = null; fBaseDirectory = null;
if (outputStream != null)
outputStream.close(); outputStream.close();
checkLine(true);
} }
} }
@ -311,15 +314,17 @@ public class ErrorParserManager extends OutputStream {
* @see java.io.OutputStream#flush() * @see java.io.OutputStream#flush()
*/ */
public void flush() throws IOException { public void flush() throws IOException {
if (outputStream != null)
outputStream.flush(); outputStream.flush();
} }
/** /**
* @see java.io.OutputStream#write(int) * @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); currentLine.append((char) b);
checkLine(); checkLine(false);
if (outputStream != null)
outputStream.write(b); outputStream.write(b);
} }
@ -334,18 +339,28 @@ public class ErrorParserManager extends OutputStream {
return; return;
} }
currentLine.append(new String(b, 0, len)); currentLine.append(new String(b, 0, len));
checkLine(); checkLine(false);
if (outputStream != null)
outputStream.write(b, off, len); outputStream.write(b, off, len);
} }
private void checkLine() { private void checkLine(boolean flush) {
String line = currentLine.toString(); String buffer = currentLine.toString();
if (line.endsWith("\n")) { int i = 0;
// Remove the training new lines. while ((i = buffer.indexOf('\n')) != -1) {
line = line.trim(); String line = buffer.substring(0, i).trim(); // get rid of any trailing \r
processLine(line); processLine(line);
previousLine = line; previousLine = line;
buffer = buffer.substring(i + 1); // skip the \n and advance
}
currentLine.setLength(0); 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.description,
problem.severity, problem.severity,
problem.variableName); problem.variableName);
} } else {
else {
fMarkerGenerator.addMarker( fMarkerGenerator.addMarker(
problem.file, problem.file,
problem.lineNumber, problem.lineNumber,