List of usage examples for org.eclipse.jdt.internal.compiler Compiler resolve
public CompilationUnitDeclaration resolve(ICompilationUnit sourceUnit, boolean verifyMethods, boolean analyzeCode, boolean generateCode)
From source file:org.codehaus.groovy.eclipse.core.compiler.GroovySnippetCompiler.java
License:Open Source License
@SuppressWarnings({ "unchecked" })
private GroovyCompilationUnitDeclaration internalCompile(String source, String sourcePath) {
if (sourcePath == null) {
sourcePath = "Nothing.groovy";
} else if (!ContentTypeUtils.isGroovyLikeFileName(sourcePath)) {
sourcePath = sourcePath.concat(".groovy");
}/* w w w . jav a 2 s . co m*/
Map options = JavaCore.getOptions();
options.put(CompilerOptions.OPTIONG_BuildGroovyFiles, CompilerOptions.ENABLED);
Compiler compiler = new CompilationUnitResolver(nameEnvironment,
DefaultErrorHandlingPolicies.proceedWithAllProblems(), new CompilerOptions(options),
new Requestor(), new DefaultProblemFactory(), null, true);
GroovyCompilationUnitDeclaration decl = (GroovyCompilationUnitDeclaration) compiler.resolve(
new MockCompilationUnit(source.toCharArray(), sourcePath.toCharArray()), true, false, false);
return decl;
}