Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3d3bb38

Browse files
committed
Output column info from compiler error when available
1 parent b10063a commit 3d3bb38

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

‎arduino-core/src/cc/arduino/Compiler.java‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,17 @@ public void message(String s) {
515515
String[] pieces = PApplet.match(s, ERROR_FORMAT);
516516

517517
if (pieces != null) {
518-
String error = pieces[pieces.length - 1], msg = "";
518+
String msg = "";
519+
int errorIdx = pieces.length - 1;
520+
String error = pieces[errorIdx];
521+
String filename = pieces[1];
522+
int line = PApplet.parseInt(pieces[2]);
523+
int col;
524+
if (errorIdx > 3) {
525+
col = PApplet.parseInt(pieces[3].substring(1));
526+
} else {
527+
col = -1;
528+
}
519529

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

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

574584
if (ex != null) {
575585
String fileName = ex.getCodeFile().getPrettyName();
576586
int lineNum = ex.getCodeLine() + 1;
577-
s = fileName + ":" + lineNum + ": error: " + error + msg;
587+
int colNum = ex.getCodeColumn();
588+
if (colNum != -1) {
589+
s = fileName + ":" + lineNum + ":" + colNum + ": error: " + error + msg;
590+
} else {
591+
s = fileName + ":" + lineNum + ": error: " + error + msg;
592+
}
578593
}
579594

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

603-
private RunnerException placeException(String message, String fileName, int line) {
618+
private RunnerException placeException(String message, String fileName, int line, intcol) {
604619
for (SketchFile file : sketch.getFiles()) {
605620
if (new File(fileName).getName().equals(file.getFileName())) {
606-
return new RunnerException(message, file, line);
621+
return new RunnerException(message, file, line, col);
607622
}
608623
}
609624
return null;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /