@Test public void checkExpressions() { int EXPECTED_ERRORS = 1; ExpressionChecker checker = new ExpressionChecker(); ASTBuilder parser = new ASTBuilder(); Form form = parser.getForm(parser.getQlParser("form test { if (parameter1) { \"Test\" testquestion:boolean; } if (testquestion2) { \"anothertest\" anothertest:boolean; } }")); TypeTable typeTable = new TypeTable(); typeTable.addEntry("testquestion2", new BooleanType()); ErrorLogger logger = checker.checkExpressions(form, typeTable); assertEquals(EXPECTED_ERRORS, logger.getErrorNumber()); }
public ErrorLogger checkExpressions(Form form, TypeTable typeTable) { this.typeTable = typeTable; this.logger = new ErrorLogger(); this.expressionMap = new HashMap<>(); for (Statement statement : form.getStatements()) { statement.accept(this, null); } checkForMissingParameters(typeTable); return logger; }
ExpressionChecker implements StatementVisitor<Void, String>, ExpressionVisitor<Void, String> { public ErrorLogger checkExpressions(Form form, TypeTable typeTable) { this.typeTable = typeTable; this.logger = new ErrorLogger(); this.expressionMap = new HashMap<>(); for (Statement statement : form.getStatements()) { statement.accept(this, null); } checkForMissingParameters(typeTable); return logger; } }
ExpressionChecker implements StatementVisitor<Void, String>, ExpressionVisitor<Void, String> { public ErrorLogger checkExpressions(Form form, TypeTable typeTable) { this.typeTable = typeTable; this.logger = new ErrorLogger(); this.expressionMap = new HashMap<>(); for (Statement statement : form.getStatements()) { statement.accept(this, null); } checkForMissingParameters(typeTable); return logger; }  }
ExpressionChecker implements StatementVisitor<Void, String>, ExpressionVisitor<Void, String> { public ErrorLogger checkExpressions(Form form, TypeTable typeTable) { this.typeTable = typeTable; this.logger = new ErrorLogger(); this.expressionMap = new HashMap<>(); for (Statement statement : form.getStatements()) { statement.accept(this, null); } checkForMissingParameters(typeTable); return logger; }  ErrorLogger checkExpressions(Form form, TypeTable typeTable); Map<String, List<Parameter>> getExpressionMap(); @Override Void visit(CalculatedQuestion calculatedQuestion, String context); @Override Void visit(Question question, String context); @Override Void visit(IfStatement ifStatement, String context); @Override Void visit(IfElseStatement ifElseStatement, String context); @Override Void visit(ParameterGroup parameterGroup, String context); @Override Void visit(StringLiteral stringLiteral, String context); @Override Void visit(IntegerLiteral integerLiteral, String context); @Override Void visit(BooleanLiteral booleanLiteral, String context); @Override Void visit(Addition addition, String context); @Override Void visit(Subtraction subtraction, String context); @Override Void visit(Multiplication multiplication, String context); @Override Void visit(Division division, String context); @Override Void visit(NotEqual notEqual, String context); @Override Void visit(Equal equal, String context); @Override Void visit(GreaterThan greaterThan, String context); @Override Void visit(GreaterThanEqualTo greaterThanEqualTo, String context); @Override Void visit(LessThan lessThan, String context); @Override Void visit(LessThanEqualTo lessThanEqualTo, String context); @Override Void visit(LogicalAnd logicalAnd, String context); @Override Void visit(LogicalOr logicalOr, String context); @Override Void visit(Negation negation, String context); @Override Void visit(Parameter parameter, String context); }
ExpressionChecker implements StatementVisitor<Void, String>, ExpressionVisitor<Void, String> { public ErrorLogger checkExpressions(Form form, TypeTable typeTable) { this.typeTable = typeTable; this.logger = new ErrorLogger(); this.expressionMap = new HashMap<>(); for (Statement statement : form.getStatements()) { statement.accept(this, null); } checkForMissingParameters(typeTable); return logger; }  ErrorLogger checkExpressions(Form form, TypeTable typeTable); Map<String, List<Parameter>> getExpressionMap(); @Override Void visit(CalculatedQuestion calculatedQuestion, String context); @Override Void visit(Question question, String context); @Override Void visit(IfStatement ifStatement, String context); @Override Void visit(IfElseStatement ifElseStatement, String context); @Override Void visit(ParameterGroup parameterGroup, String context); @Override Void visit(StringLiteral stringLiteral, String context); @Override Void visit(IntegerLiteral integerLiteral, String context); @Override Void visit(BooleanLiteral booleanLiteral, String context); @Override Void visit(Addition addition, String context); @Override Void visit(Subtraction subtraction, String context); @Override Void visit(Multiplication multiplication, String context); @Override Void visit(Division division, String context); @Override Void visit(NotEqual notEqual, String context); @Override Void visit(Equal equal, String context); @Override Void visit(GreaterThan greaterThan, String context); @Override Void visit(GreaterThanEqualTo greaterThanEqualTo, String context); @Override Void visit(LessThan lessThan, String context); @Override Void visit(LessThanEqualTo lessThanEqualTo, String context); @Override Void visit(LogicalAnd logicalAnd, String context); @Override Void visit(LogicalOr logicalOr, String context); @Override Void visit(Negation negation, String context); @Override Void visit(Parameter parameter, String context);  }