@Override public int getCursor() { return wrappedCompileException.getCursor(); }
public static CompileException rewriteIfNeeded(CompileException caught, char[] outer, int outerCursor) { if (outer != caught.getExpr()) { if (caught.getExpr().length <= caught.getCursor()) { caught.setCursor(caught.getExpr().length - 1); } try { String innerExpr = new String(caught.getExpr()).substring(caught.getCursor()); caught.setExpr(outer); String outerStr = new String(outer); int newCursor = outerStr.substring(outerStr.indexOf(new String(caught.getExpr()))) .indexOf(innerExpr); caught.setCursor(newCursor); } catch (Throwable t) { t.printStackTrace(); } } return caught; }
public static CompileException rewriteIfNeeded(CompileException caught, char[] outer, int outerCursor) { if (outer != caught.getExpr()) { if (caught.getExpr().length <= caught.getCursor()) { caught.setCursor(caught.getExpr().length - 1); } try { String innerExpr = new String(caught.getExpr()).substring(caught.getCursor()); caught.setExpr(outer); String outerStr = new String(outer); int newCursor = outerStr.substring(outerStr.indexOf(new String(caught.getExpr()))) .indexOf(innerExpr); caught.setCursor(newCursor); } catch (Throwable t) { t.printStackTrace(); } } return caught; }
/** * Constructor. * * @param name * the name of template. * @param compileException * the {@link CompileException}. * @param columnNumber * the column where the expression starts. * @param lineNumber * the line where the expression starts. */ public NamedCompileException(final String name, final CompileException compileException, final int columnNumber, final int lineNumber) { super("", compileException.getExpr(), compileException.getCursor()); compileException.setColumn(columnNumber); compileException.setLineNumber(lineNumber); compileException.setErrors(compileException.getErrors()); // setEvaluationContext(); compileException.setLastLineStart(compileException.getLastLineStart()); compileException.setStackTrace(compileException.getStackTrace()); wrappedCompileException = compileException; this.name = name; }