* @throws InvalidSyntaxException if the file has syntax errors.
*/
public static JavaCompilation compile(String source, String fileName) {
CompilerOptions options = getDefaultCompilerOptions();
Parser parser = createCommentRecorderParser(options);
ICompilationUnit cu = createCompilationUnit(source, fileName);
CompilationResult compilationResult = createDefaultCompilationResult(cu, options);
JavaCompilation javaCompilation = new JavaCompilation(parser.parse(cu, compilationResult), parser.scanner);
if (compilationResult.hasSyntaxError) {
throw new InvalidSyntaxException(new String(compilationResult.getFileName()), compilationResult.toString());