EvaluationSourceGenerator mapper, CompilationUnit unit) {
IProblem[] problems = unit.getProblems();
if (problems.length != 0) {
boolean snippetError = false;
boolean runMethodError = false;
InstructionSequence errorSequence = new InstructionSequence(snippet);
int codeSnippetStart = mapper.getSnippetStart();
int codeSnippetEnd = codeSnippetStart
+ mapper.getSnippet().length();
int runMethodStart = mapper.getRunMethodStart();
int runMethodEnd = runMethodStart + mapper.getRunMethodLength();
for (IProblem problem : problems) {
int errorOffset = problem.getSourceStart();
int problemId = problem.getID();
if (problemId == IProblem.IsClassPathCorrect) {
errorSequence.addError(problem.getMessage());
snippetError = true;
}
if (problemId == IProblem.VoidMethodReturnsValue
|| problemId == IProblem.NotVisibleMethod
|| problemId == IProblem.NotVisibleConstructor
|| problemId == IProblem.NotVisibleField
|| problemId == IProblem.NotVisibleType) {
continue;
}
if (problem.isError()) {
if (codeSnippetStart <= errorOffset
&& errorOffset <= codeSnippetEnd) {
errorSequence.addError(problem.getMessage());
snippetError = true;
} else if (runMethodStart <= errorOffset
&& errorOffset <= runMethodEnd) {
runMethodError = true;
}
}
}
if (snippetError || runMethodError) {
if (runMethodError) {
errorSequence
.addError(EvaluationEngineMessages.ASTEvaluationEngine_Evaluations_must_contain_either_an_expression_or_a_block_of_well_formed_statements_1);
}
return errorSequence;
}
}