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:
parent
b192a6f48a
commit
ba1e859eba
1 changed files with 32 additions and 18 deletions
|
@ -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;
|
||||||
outputStream.close();
|
if (outputStream != null)
|
||||||
|
outputStream.close();
|
||||||
|
checkLine(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,16 +314,18 @@ 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 {
|
||||||
outputStream.flush();
|
if (outputStream != null)
|
||||||
|
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);
|
||||||
outputStream.write(b);
|
if (outputStream != null)
|
||||||
|
outputStream.write(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 {
|
||||||
|
@ -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);
|
||||||
outputStream.write(b, off, len);
|
if (outputStream != null)
|
||||||
|
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;
|
||||||
currentLine.setLength(0);
|
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.description,
|
||||||
problem.severity,
|
problem.severity,
|
||||||
problem.variableName);
|
problem.variableName);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
fMarkerGenerator.addMarker(
|
fMarkerGenerator.addMarker(
|
||||||
problem.file,
|
problem.file,
|
||||||
problem.lineNumber,
|
problem.lineNumber,
|
||||||
|
|
Loading…
Add table
Reference in a new issue