01: package spoon.support.builder;
02:
03: import org.eclipse.jdt.core.compiler.CategorizedProblem;
04:
05: import spoon.reflect.Factory;
06:
07: public class SnippetBuilder extends SpoonBuildingManager {
08:
09: public SnippetBuilder(Factory factory) {
10: super (factory);
11: }
12:
13: @Override
14: public boolean build() throws Exception {
15: if (factory == null) {
16: throw new Exception("Factory not initialized");
17: }
18: JDTCompiler.JAVA_COMPLIANCE = factory.getEnvironment()
19: .getComplianceLevel();
20: boolean srcSuccess;
21: factory.getEnvironment().debugMessage(
22: "compiling sources: " + sources.getAllJavaFiles());
23: long t = System.currentTimeMillis();
24: compiler = new JDTCompiler();
25: initCompiler();
26: srcSuccess = compiler.compileSrc(factory, sources
27: .getAllJavaFiles());
28: if (!srcSuccess) {
29: for (CategorizedProblem[] cps : compiler.probs) {
30: for (int i = 0; i < cps.length; i++) {
31: CategorizedProblem problem = cps[i];
32: if (problem != null)
33: getProblems().add(problem.getMessage());
34: }
35: }
36: }
37: factory.getEnvironment().debugMessage(
38: "compiled in " + (System.currentTimeMillis() - t)
39: + " ms");
40: factory.getEnvironment().debugMessage(
41: "compiling templates: " + templates.getAllJavaFiles());
42: t = System.currentTimeMillis();
43: return srcSuccess;
44: }
45:
46: }
|