MCPcopy Index your code
hub / github.com/benfry/processing4 / placeException

Method placeException

java/src/processing/mode/java/JavaBuild.java:500–552  ·  view source on GitHub ↗

Map an error from a set of processed .java files back to its location in the actual sketch. @param message The error message. @param dotJavaFilename The .java file where the exception was found. @param dotJavaLine Line number of the .java file for the exception (0-indexed!) @return A RunnerException

(String message,
                                        String dotJavaFilename,
                                        int dotJavaLine)

Source from the content-addressed store, hash-verified

498 * possible to place the exception to the sketch code.
499 */
500 public SketchException placeException(String message,
501 String dotJavaFilename,
502 int dotJavaLine) {
503 int codeIndex = 0; //-1;
504 int codeLine = -1;
505
506 //System.out.println(message + " placing " + dotJavaFilename + " " + dotJavaLine);
507 //System.out.println("code count is " + getCodeCount());
508
509 // first check to see if it's a .java file
510 for (int i = 0; i < sketch.getCodeCount(); i++) {
511 SketchCode code = sketch.getCode(i);
512 if (code.isExtension("java")) {
513 if (dotJavaFilename.equals(code.getFileName())) {
514 codeIndex = i;
515 codeLine = dotJavaLine;
516 return new SketchException(message, codeIndex, codeLine);
517 }
518 }
519 }
520
521 // If not the preprocessed file at this point, then need to get out
522 if (!dotJavaFilename.equals(sketch.getMainName() + ".java")) {
523 return null;
524 }
525
526 // if it's not a .java file, codeIndex will still be 0
527 // this section searches through the list of .pde files
528 codeIndex = 0;
529 for (int i = 0; i < sketch.getCodeCount(); i++) {
530 SketchCode code = sketch.getCode(i);
531
532 if (code.isExtension("pde")) {
533 //System.out.println("preproc offset is " + code.getPreprocOffset());
534 //System.out.println("looking for line " + dotJavaLine);
535 if (code.getPreprocOffset() <= dotJavaLine) {
536 codeIndex = i;
537// System.out.println("i'm thinkin file " + i);
538 codeLine = dotJavaLine - code.getPreprocOffset();
539 }
540 }
541 }
542 // could not find a proper line number, so deal with this differently.
543 // but if it was in fact the .java file we're looking for, though,
544 // send the error message through.
545 // this is necessary because 'import' statements will be at a line
546 // that has a lower number than the preproc offset, for instance.
547// if (codeLine == -1 && !dotJavaFilename.equals(name + ".java")) {
548// return null;
549// }
550// return new SketchException(message, codeIndex, codeLine);
551 return new SketchException(message, codeIndex, codeLine, -1, false); // changed for 0194 for compile errors, but...
552 }
553
554
555 /**

Callers 2

compileMethod · 0.80
findExceptionMethod · 0.80

Calls 7

isExtensionMethod · 0.95
getFileNameMethod · 0.95
getPreprocOffsetMethod · 0.95
getCodeCountMethod · 0.80
getCodeMethod · 0.80
getMainNameMethod · 0.80
equalsMethod · 0.45

Tested by

no test coverage detected