if (!DEVELOPMENT_MODE) {
// If we are not developping the code snippet support classes,
// use a regular compiler and feed its lookup environment with
// the code snippet support classes
CompilerOptions compilerOptions = new CompilerOptions(this.options);
compilerOptions.performMethodsFullRecovery = true;
compilerOptions.performStatementsRecovery = true;
compiler =
new CodeSnippetCompiler(
this.environment,
DefaultErrorHandlingPolicies.exitAfterAllProblems(),
compilerOptions,
compilerRequestor,
this.problemFactory,
this.context,
getMapper().startPosOffset,
getMapper().startPosOffset + this.codeSnippet.length - 1);
((CodeSnippetParser) compiler.parser).lineSeparatorLength = this.context.lineSeparator.length();
// Initialize the compiler's lookup environment with the already compiled super classes
IBinaryType binary = this.context.getRootCodeSnippetBinary();
if (binary != null) {
compiler.lookupEnvironment.cacheBinaryType(binary, null /*no access restriction*/);
}
VariablesInfo installedVars = this.context.installedVars;
if (installedVars != null) {
ClassFile[] globalClassFiles = installedVars.classFiles;
for (int i = 0; i < globalClassFiles.length; i++) {
ClassFileReader binaryType = null;
try {
binaryType = new ClassFileReader(globalClassFiles[i].getBytes(), null);
} catch (ClassFormatException e) {
e.printStackTrace(); // Should never happen since we compiled this type
}
compiler.lookupEnvironment.cacheBinaryType(binaryType, null /*no access restriction*/);
}
}
} else {
// If we are developping the code snippet support classes,
// use a wrapped environment so that if the code snippet classes are not found
// then a default implementation is provided.
CompilerOptions compilerOptions = new CompilerOptions(this.options);
compilerOptions.performMethodsFullRecovery = true;
compilerOptions.performStatementsRecovery = true;
compiler = new Compiler(
getWrapperEnvironment(),
DefaultErrorHandlingPolicies.exitAfterAllProblems(),