[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-core-dev] Eclipse Error Parser.
|
Hello!
I think that ErrorParserManager feeds IErrorParser per line, as such your
regexp is only ever applied to one line at a time.
If you're using MinGW gcc you can use -fmessage-length=0 option to force
single-line output.
Otherwise, I guess you can just implement some kind of state machine in,
say, a ErrorPattern decorator to build a single line from multiple lines.
i.e., something like:
class CustomErrorPattern extends ErrorPattern {
public CustomErrorPattern(ErrorPattern orig) {
this.orig = orig;
this.isError = false;
this.sb = null;
}
private static Pattern errorPattern = Pattern.compile("XXX");
private static Pattern continuationPattern = Pattern.compile("YYY");
private ErrorPattern orig; // The decorated error pattern (its
regexp should match "XXX" or "XXX YYY*")
private StringBuffer sb;
private boolean isError;
/** @Override */
public boolean processLine(String line, ErrorParserManager eoParser) {
if (errorPattern.matcher(line).matches()) {
if (isError) {
orig.processLine(sb.toString(), eoParser);
} else {
isError = true;
}
sb = new StringBuffer(line);
} else if (continuationPattern.matcher(line).matches() && isError) {
sb.append(' ').append(line);
} else {
isError = false;
}
return false;
}
}
((note: the code above assumes the last line isn't an error line :P))
Hope this helps!
RB
Asim Zaka wrote:
>
> Thanks.
> At 14:37 23/06/2007, you wrote:
> hello, Asim Zaka
>
> in java pattern "." can represent any character but the
> character of end line.
> if you can make sure the description is two lines try to add this after
> your pattern:
> \\\\n (.+)
> maybe you can get two line description in that way...
>
> On 6/21/07, Asim Zaka
> <
> azaka@xxxxxxxxxxxxxxxxxxxxxx > wrote:
>
>
> Morning all,
>
> I am working on adding my own error parser as a plugin into eclipse.
> I have basically extended my own errorparser class from the cdt class
> AbstractErrorParser. I have defined a
> regular expression to work on the following console output and get
> the file name, line number and description.
>
> ./c/btmg.c(48,55): Variable exported but not used outside btn:
>
>
>
> BTN_long_hold_time
>
> Now the problem I have is that the description goes onto the second
> line and my error parser breaks on the end of first line. Like for
> instance in the above example I only get "Variable exported but not
> used outside btn:" as the description and not
> "BTN_long_hold_time" as it goes onto the second line.
>
> Going into specific details, this is the pattern I have
> made:
>
>
> private
> static final ErrorPattern[]
> patterns =
> {
>
>
> new
> ErrorPattern(
>
> "[.][/][c][/](.*?)[(]([0-9]+).*?:(.+)"
> , 1, 2, 3, 0, IMarkerGenerator.
>
> SEVERITY_WARNING)
>
> };
>
> Can someone please tell me how I can improve this error parser
> plug-in to enable it to get the whole description even if it goes on to
> the second or third line and pass it to the problems window on eclipse as
> one string of description?
>
> Regards,
>
> Asim Pervez Zaka
>
> Firmware Engineer
>
> Actaris,
>
> Langer Road,
>
> Felixstowe, Suffolk,
>
> England
>
> IP11 2ER
>
>
> _______________________________________________
>
> cdt-core-dev mailing list
>
> cdt-core-dev@xxxxxxxxxxx
>
>
>
>
> https://dev.eclipse.org/mailman/listinfo/cdt-core-dev
>
>
> _______________________________________________
> cdt-core-dev mailing list
> cdt-core-dev@xxxxxxxxxxx
>
> https://dev.eclipse.org/mailman/listinfo/cdt-core-dev
>
> Asim Pervez Zaka
> Firmware Engineer
> Actaris,
> Langer Road,
> Felixstowe, Suffolk,
> England
> IP11 2ER
>
>
>
>
> _______________________________________________
> cdt-core-dev mailing list
> cdt-core-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-core-dev
>
>
--
View this message in context: http://www.nabble.com/Eclipse-Error-Parser.-tf3957434.html#a12271794
Sent from the Eclipse CDT - core mailing list archive at Nabble.com.