/** * This method adds an exception to the error collector. The Exception most likely has no line number attached to it. * For this reason you should use this method sparingly. Prefer using addError for syntax errors or add an error * to the {@link ErrorCollector} directly by retrieving it with getErrorCollector(). * @param e * the exception that occurred * @throws CompilationFailedException * on error */ public void addException(Exception e) throws CompilationFailedException { getErrorCollector().addException(e, this); }
/** * This method adds a SyntaxException to the error collector. The exception should specify the line and column * number of the error. This method should be reserved for real errors in the syntax of the SourceUnit. If * your error is not in syntax, and is a semantic error, or more general error, then use addException or use * the error collector directly by retrieving it with getErrorCollector(). * @param se * the exception, which should have line and column information * @throws CompilationFailedException * on error */ public void addError(SyntaxException se) throws CompilationFailedException { getErrorCollector().addError(se, this); }
public void error(String msg, Object... args) { sourceUnit.getErrorCollector().addErrorAndContinue( new SimpleMessage(String.format(msg, args), sourceUnit)); }
public void error(InvalidSpecCompileException e) { sourceUnit.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(e, sourceUnit)); } }
public void error(String msg, Throwable cause, Object... args) { sourceUnit.getErrorCollector().addErrorAndContinue( new SimpleMessage(String.format(msg, args) + "\n\n" + TextUtil.printStackTrace(cause), sourceUnit)); }
private void verifyClass(AnnotationNode annotation, Class klass) { if (!ASTTransformation.class.isAssignableFrom(klass)) { source.getErrorCollector().addError(new SimpleMessage("Not an ASTTransformation: " + klass.getName() + " declared by " + annotation.getClassNode().getName(), source)); } }
private String buildErrorMessage(int count) { StringBuilder sb = new StringBuilder(); sb.append("Expected ").append(count); sb.append(" error messages but found "); sb.append(source.getErrorCollector().getErrorCount()).append(":\n"); sb.append(flattenErrorMessage()); return sb.toString(); }
private String flattenErrorMessage() { StringWriter stringWriter = new StringWriter(); PrintWriter writer = new PrintWriter(stringWriter, true); for (int i = source.getErrorCollector().getErrorCount() - 1; i >= 0; i--) { source.getErrorCollector().getError(i).write(writer); } writer.close(); return stringWriter.toString(); } }
public StaticTypeCheckingVisitor(SourceUnit source, ClassNode cn) { this.typeCheckingContext = new TypeCheckingContext(this); this.extension = createDefaultTypeCheckingExtension(); this.typeCheckingContext.source = source; this.typeCheckingContext.pushEnclosingClassNode(cn); this.typeCheckingContext.pushErrorCollector(source.getErrorCollector()); this.typeCheckingContext.pushTemporaryTypeInfo(); }
private Class loadTransformClass(String transformClass, AnnotationNode annotation) { try { return transformLoader.loadClass(transformClass, false, true, false); } catch (ClassNotFoundException e) { source.getErrorCollector().addErrorAndContinue( new SimpleMessage( "Could not find class for Transformation Processor " + transformClass + " declared by " + annotation.getClassNode().getName(), source)); } return null; }
private static void addUnsupportedError(ASTNode node, SourceUnit unit) { unit.getErrorCollector().addErrorAndContinue( new SyntaxErrorMessage( new SyntaxException("The @Category transformation does not support instance "+ (node instanceof FieldNode?"fields":"properties") + " but found ["+getName(node)+"]", node.getLineNumber(), node.getColumnNumber() ), unit )); }
private void checkErrorCount(int count) { assertEquals(buildErrorMessage(count), count, source.getErrorCollector().getErrorCount()); }
private void addError(AnnotatedNode exp, String msg) { sourceUnit.getErrorCollector().addErrorAndContinue( new SyntaxErrorMessage( new SyntaxException(msg + '\n', exp.getLineNumber(), exp.getColumnNumber(), exp.getLastLineNumber(), exp.getLastColumnNumber()), sourceUnit) ); }
private void checkErrorMessage(String expectedErrorMessage) { assertTrue("Expected an error message but none found.", source.getErrorCollector().hasErrors()); assertTrue("Expected message to contain <" + expectedErrorMessage + "> but was <" + flattenErrorMessage() + ">.", flattenErrorMessage().contains(expectedErrorMessage)); }
public void addError(String msg, ASTNode expr) { this.source.getErrorCollector().addErrorAndContinue( new SyntaxErrorMessage( new SyntaxException(msg + '\n', expr.getLineNumber(), expr.getColumnNumber(), expr.getLastLineNumber(), expr.getLastColumnNumber()), this.source) ); }
/** * Adds a new syntax error to the source unit and then continues. * * @param message the message * @param node the node for the error report * @param source the source unit for the error report */ protected void addError(String message, ASTNode node, SourceUnit source) { source.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(new SyntaxException( message, node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber() ), source)); }
/** * Reports an error back to the source unit. * * @param msg the error message * @param expr the expression that caused the error message. */ protected void addError(String msg, ASTNode expr) { sourceUnit.getErrorCollector().addErrorAndContinue( new SyntaxErrorMessage(new SyntaxException(msg + '\n', expr.getLineNumber(), expr.getColumnNumber(), expr.getLastLineNumber(), expr.getLastColumnNumber()), sourceUnit) ); }
public void addError(String msg, ASTNode expr) { sourceUnit.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage( new SyntaxException(msg + '\n', expr.getLineNumber(), expr.getColumnNumber(), expr.getLastLineNumber(), expr.getLastColumnNumber()), sourceUnit) ); }
private void checkVisitErrors(String name, int modifiers, boolean expectedToFail) { ClassNode node = new ClassNode(name, modifiers, ClassHelper.OBJECT_TYPE); verifier.visitClass(node); assertTrue(source.getErrorCollector().hasErrors() == expectedToFail); }
public void addError(String msg, ASTNode expr) { SourceUnit source = getSourceUnit(); source.getErrorCollector().addErrorAndContinue( new SyntaxErrorMessage(new SyntaxException(msg + '\n', expr.getLineNumber(), expr.getColumnNumber(), expr.getLastLineNumber(), expr.getLastColumnNumber()), source) ); }