Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions arduino-core/src/cc/arduino/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,17 @@ public void message(String s) {
String[] pieces = PApplet.match(s, ERROR_FORMAT);

if (pieces != null) {
String error = pieces[pieces.length - 1], msg = "";
String msg = "";
int errorIdx = pieces.length - 1;
String error = pieces[errorIdx];
String filename = pieces[1];
int line = PApplet.parseInt(pieces[2]);
int col;
if (errorIdx > 3) {
col = PApplet.parseInt(pieces[3].substring(1));
} else {
col = -1;
}

if (error.trim().equals("SPI.h: No such file or directory")) {
error = tr("Please import the SPI library from the Sketch > Import Library menu.");
Expand Down Expand Up @@ -569,12 +579,17 @@ public void message(String s) {
//msg = _("\nThe 'Keyboard' class is only supported on the Arduino Leonardo.\n\n");
}

RunnerException ex = placeException(error, pieces[1], PApplet.parseInt(pieces[2]) - 1);
RunnerException ex = placeException(error, filename, line - 1, col);

if (ex != null) {
String fileName = ex.getCodeFile().getPrettyName();
int lineNum = ex.getCodeLine() + 1;
s = fileName + ":" + lineNum + ": error: " + error + msg;
int colNum = ex.getCodeColumn();
if (colNum != -1) {
s = fileName + ":" + lineNum + ":" + colNum + ": error: " + error + msg;
} else {
s = fileName + ":" + lineNum + ": error: " + error + msg;
}
}

if (ex != null) {
Expand All @@ -600,10 +615,10 @@ public void message(String s) {
System.err.println(s);
}

private RunnerException placeException(String message, String fileName, int line) {
private RunnerException placeException(String message, String fileName, int line, int col) {
for (SketchFile file : sketch.getFiles()) {
if (new File(fileName).getName().equals(file.getFileName())) {
return new RunnerException(message, file, line);
return new RunnerException(message, file, line, col);
}
}
return null;
Expand Down