mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
bug 295625: Error highlighting in Build Console
more accurate handling in processLine()
This commit is contained in:
parent
ac553dd0a6
commit
89611748f7
2 changed files with 22 additions and 7 deletions
|
@ -303,7 +303,7 @@ public class ErrorParserManager extends OutputStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the input and try to generate error or warning markers
|
* Parses the input and tries to generate error or warning markers
|
||||||
*/
|
*/
|
||||||
private void processLine(String line) {
|
private void processLine(String line) {
|
||||||
if (fErrorParsers.size() == 0)
|
if (fErrorParsers.size() == 0)
|
||||||
|
@ -333,21 +333,30 @@ public class ErrorParserManager extends OutputStream {
|
||||||
// untrimmed lines
|
// untrimmed lines
|
||||||
lineToParse = line;
|
lineToParse = line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean consume = false;
|
||||||
// Protect against rough parsers who may accidentally
|
// Protect against rough parsers who may accidentally
|
||||||
// throw an exception on a line they can't handle.
|
// throw an exception on a line they can't handle.
|
||||||
// It should not stop parsing of the rest of output.
|
// It should not stop parsing of the rest of output.
|
||||||
try {
|
try {
|
||||||
if (curr.processLine(lineToParse, this)) {
|
consume = curr.processLine(lineToParse, this);
|
||||||
ProblemMarkerInfo m = fErrors.size() > 0 ? fErrors.get(0): null;
|
} catch (Exception e){
|
||||||
|
String id = ""; //$NON-NLS-1$
|
||||||
|
if (parser instanceof IErrorParserNamed)
|
||||||
|
id = ((IErrorParserNamed)parser).getId();
|
||||||
|
String message = "Errorparser " + id + " failed parsing line [" + lineToParse + "]"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
CCorePlugin.log(message, e);
|
||||||
|
} finally {
|
||||||
|
if (fErrors.size() > 0) {
|
||||||
|
ProblemMarkerInfo m = fErrors.get(0);
|
||||||
outputLine(line, m);
|
outputLine(line, m);
|
||||||
fErrors.clear();
|
fErrors.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (consume)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (Exception e){
|
|
||||||
String message = "Error parsing line [" + lineToParse + "]"; //$NON-NLS-1$//$NON-NLS-2$
|
|
||||||
CCorePlugin.log(message, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
outputLine(line, null);
|
outputLine(line, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,12 @@ package org.eclipse.cdt.core;
|
||||||
public interface IErrorParser {
|
public interface IErrorParser {
|
||||||
/**
|
/**
|
||||||
* Finds error or warnings on the given line
|
* Finds error or warnings on the given line
|
||||||
|
*
|
||||||
|
* @param line - line to process
|
||||||
|
* @param eoParser - {@link ErrorParserManager}
|
||||||
|
* @return {@code true} if the parser found a problem reported in output.
|
||||||
|
* More accurately, {@code true} will consume the line (prevent other parsers from seeing it)
|
||||||
|
* and {@code false} won't (the line will be handed to the next parser).
|
||||||
*/
|
*/
|
||||||
boolean processLine(String line, ErrorParserManager eoParser);
|
boolean processLine(String line, ErrorParserManager eoParser);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue