1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-17 06:52:18 +01:00

Allow highlighting line with error even if gcc reports full path to file

This commit is contained in:
Federico Fissore 2015-09-24 16:05:41 +02:00
parent 563a7306b9
commit 71c81e30a7

View File

@ -536,9 +536,7 @@ public class Compiler implements MessageConsumer {
RunnerException exception = placeException(error, pieces[1], PApplet.parseInt(pieces[2]) - 1);
// replace full file path with the name of the sketch tab (unless we're
// in verbose mode, in which case don't modify the compiler output)
if (exception != null && !verbose) {
if (exception != null) {
SketchCode code = sketch.getCode(exception.getCodeIndex());
String fileName = (code.isExtension("ino") || code.isExtension("pde")) ? code.getPrettyName() : code.getFileName();
int lineNum = exception.getCodeLine() + 1;
@ -568,15 +566,10 @@ public class Compiler implements MessageConsumer {
System.err.println(s);
}
private RunnerException placeException(String message,
String dotJavaFilename,
int dotJavaLine) {
// Placing errors is simple, because we inserted #line directives
// into the preprocessed source. The compiler gives us correct
// the file name and line number. :-)
private RunnerException placeException(String message, String fileName, int line) {
for (SketchCode code : sketch.getCodes()) {
if (dotJavaFilename.equals(code.getFileName())) {
return new RunnerException(message, sketch.indexOfCode(code), dotJavaLine);
if (new File(fileName).getName().equals(code.getFileName())) {
return new RunnerException(message, sketch.indexOfCode(code), line);
}
}
return null;