1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Keep on trying to find a motif

This commit is contained in:
Alain Magloire 2003-10-16 19:09:52 +00:00
parent 6738deaf1a
commit 1349365cd7

View file

@ -54,38 +54,41 @@ public class GCCErrorParser implements IErrorParser {
if (firstColon != -1) { if (firstColon != -1) {
try { try {
int secondColon= line.indexOf(':', firstColon + 1); int secondColon = -1;
if (secondColon != -1) { int num = -1;
String fileName = line.substring(0, firstColon);
String lineNumber = line.substring(firstColon + 1, secondColon);
String varName = null;
String desc = line.substring(secondColon + 1).trim();
int severity = IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
int num = -1;
int col = -1;
while ((secondColon = line.indexOf(':', firstColon + 1)) != -1) {
String lineNumber = line.substring(firstColon + 1, secondColon);
try { try {
num = Integer.parseInt(lineNumber); num = Integer.parseInt(lineNumber);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
// Failed.
} }
if (num != -1) {
break; // Find possible match.
}
firstColon = secondColon;
}
if (num == -1) { if (secondColon != -1) {
// Bail out not recognizable format. i.e. no line numbers int col = -1;
return false;
} else { String fileName = line.substring(0, firstColon);
/* Then check for the column */ String varName = null;
int thirdColon= line.indexOf(':', secondColon + 1); String desc = line.substring(secondColon + 1).trim();
if (thirdColon != -1) { int severity = IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
String columnNumber = line.substring(secondColon + 1, thirdColon); /* Then check for the column */
try { int thirdColon= line.indexOf(':', secondColon + 1);
col = Integer.parseInt(columnNumber); if (thirdColon != -1) {
} catch (NumberFormatException e) { String columnNumber = line.substring(secondColon + 1, thirdColon);
} try {
} col = Integer.parseInt(columnNumber);
if (col != -1) { } catch (NumberFormatException e) {
desc = line.substring(thirdColon + 1).trim();
} }
} }
if (col != -1) {
desc = line.substring(thirdColon + 1).trim();
}
// gnu c: filename:no: (Each undeclared identifier is reported // gnu c: filename:no: (Each undeclared identifier is reported
// only once. filename:no: for each function it appears in.) // only once. filename:no: for each function it appears in.)
@ -103,9 +106,11 @@ public class GCCErrorParser implements IErrorParser {
/* See if we can get a var name /* See if we can get a var name
* Look for: * Look for:
* 'foo' undeclared * `foo' undeclared
* 'foo' defined but not used * `foo' defined but not used
* conflicting types for 'foo' * conflicting types for `foo'
* previous declaration of `foo'
* parse error before `foo'
* *
*/ */
int s; int s;
@ -141,26 +146,43 @@ public class GCCErrorParser implements IErrorParser {
} }
} }
/*
* In file included from b.h:2,
* from a.h:3,
* from hello.c:3:
* c.h:2:15: missing ')' in macro parameter list
*
* We reconstruct the multiline gcc errors to multiple errors:
* c.h:3:15: missing ')' in macro parameter list
* b.h:2: in inclusion c.h:3:15
* a.h:3: in inclusion b.h:2
* hello.c:3: in inclusion a.h:3
*
*/
if (eoParser.getScratchBuffer().startsWith("In file included from ")) { if (eoParser.getScratchBuffer().startsWith("In file included from ")) {
if (line.startsWith("from ")) { if (line.startsWith("from ")) {
// We want the last error in the chain, so continue.
eoParser.appendToScratchBuffer(line); eoParser.appendToScratchBuffer(line);
return false; return false;
} }
String buffer = eoParser.getScratchBuffer(); String buffer = eoParser.getScratchBuffer();
eoParser.clearScratchBuffer(); eoParser.clearScratchBuffer();
int from = -1; int from = -1;
while ((from = buffer.lastIndexOf("from ")) != -1) { String inclusionError = fileName + ":" + num;
String buf = buffer.substring(from + 5); while ((from = buffer.indexOf("from ")) != -1) {
buffer = buffer.substring(0, from); int coma = buffer.indexOf(',', from);
if (buf.endsWith(",")) { String buf;
int coma = buf.lastIndexOf(','); if (coma != -1) {
StringBuffer b = new StringBuffer(buf); buf = buffer.substring(from + 5, coma) + ':';
b.setCharAt(coma, ':'); buffer = buffer.substring(coma);
b.append(' ').append(buffer).append(" from ").append(line);
buf = b.toString();
} else { } else {
buf = buf + ' ' + buffer + " from " + line; buf = buffer.substring(from + 5);
buffer = "";
} }
String t = buf;
buf += " in inclusion " + inclusionError;
inclusionError = t;
// Call the parsing process again.
processLine(buf, eoParser); processLine(buf, eoParser);
} }
} }
@ -196,6 +218,7 @@ public class GCCErrorParser implements IErrorParser {
if (file == null) { if (file == null) {
desc = desc +"[" + fileName + "]"; desc = desc +"[" + fileName + "]";
} }
eoParser.generateMarker(file, num, desc, severity, varName); eoParser.generateMarker(file, num, desc, severity, varName);
} else { } else {
if (line.startsWith("In file included from ")) { if (line.startsWith("In file included from ")) {