public CategorizedProblem[] validate(final String str, IJavaProject prj) {
Map prjOptions = prj.getOptions(true);
CompilerOptions options = new CompilerOptions(prjOptions);
INameEnvironment environment = new NameEnvironment(prj);
IErrorHandlingPolicy policy = new IErrorHandlingPolicy() {
public boolean stopOnFirstError() {
return false;
}
public boolean proceedOnErrors() {
return true;
}
};
ICompilerRequestor requestor = new ICompilerRequestor() {
public void acceptResult(CompilationResult result) {
ClassFile[] classFiles = result.getClassFiles();
for (ClassFile f : classFiles) {
resultBytes = f.getBytes();
break;
}
problems=result.getAllProblems();
}
};
IProblemFactory problemFactory = new DefaultProblemFactory();
Compiler c = new Compiler(environment, policy, options, requestor,
problemFactory);
c.compile(new ICompilationUnit[] { new Unit(str) });
environment.cleanup();
return problems;
}