|
37 | 37 |
|
38 | 38 | public abstract class SpoonedFile {
|
39 | 39 |
|
40 |
| - protected final Config config; |
| 40 | + private File[] sourceFiles; |
| 41 | + private URL[] projectClasspath; |
| 42 | + private URL[] compilationClasspath; |
| 43 | + private Factory factory; |
| 44 | + private ProcessingManager manager; |
| 45 | + private DynamicClassCompiler compiler; |
| 46 | + private Map<String, byte[]> compiledClasses; |
| 47 | + private DefaultJavaPrettyPrinter prettyPrinter; |
41 | 48 |
|
42 |
| - protected abstract Collection<? extends CtType<?>> modelledClasses(); |
| 49 | + protected final Config config; |
43 | 50 |
|
44 | 51 | public SpoonedFile(File[] sourceFiles, URL[] projectClasspath, Config config) {
|
45 |
| - //logDebug(logger(), format("[Building Spoon model from %s]", sourceFiles)); |
46 | 52 | this.config = config;
|
47 | 53 | this.sourceFiles = sourceFiles;
|
48 | 54 | this.projectClasspath = projectClasspath;
|
| 55 | + |
49 | 56 | factory = SpoonModelLibrary.newFactory();
|
50 | 57 | factory.getEnvironment().setComplianceLevel(config.getComplianceLevel());
|
51 | 58 | factory.getEnvironment().setCommentEnabled(false);
|
52 | 59 | factory.getEnvironment().setLevel(Level.OFF.toString());
|
| 60 | + |
53 | 61 | factory = SpoonModelLibrary.modelFor(factory, sourceFiles, projectClasspath());
|
| 62 | + |
54 | 63 | compiler = new DynamicClassCompiler(compilationClasspath(), config);
|
55 |
| - manager = new RuntimeProcessingManager(spoonFactory()); |
| 64 | + manager = new RuntimeProcessingManager(factory); |
56 | 65 | compiledClasses = MetaMap.newHashMap();
|
57 | 66 | prettyPrinter = new DefaultJavaPrettyPrinter(spoonEnvironment());
|
58 | 67 | }
|
59 | 68 |
|
| 69 | + protected abstract Collection<? extends CtType<?>> modelledClasses(); |
| 70 | + |
60 | 71 | public void generateOutputFile(File destinationFolder) {
|
61 | 72 | Processor<?> writer = new JavaOutputProcessor(destinationFolder, new DefaultJavaPrettyPrinter(new StandardEnvironment()));
|
62 | 73 | process(writer);
|
@@ -237,13 +248,4 @@ public String toString() {
|
237 | 248 | private Logger logger() {
|
238 | 249 | return loggerFor(this);
|
239 | 250 | }
|
240 |
| - |
241 |
| - private File[] sourceFiles; |
242 |
| - private URL[] projectClasspath; |
243 |
| - private URL[] compilationClasspath; |
244 |
| - private Factory factory; |
245 |
| - private ProcessingManager manager; |
246 |
| - private DynamicClassCompiler compiler; |
247 |
| - private Map<String, byte[]> compiledClasses; |
248 |
| - private DefaultJavaPrettyPrinter prettyPrinter; |
249 | 251 | }
|
0 commit comments