Exemplo n.º 1
0
 protected void generateProcessedSourceFilesUsingTypes(Filter<CtType<?>> typeFilter) {
   if (factory.getEnvironment().getDefaultFileGenerator() != null) {
     factory.getEnvironment().debugMessage("Generating source using types...");
     ProcessingManager processing = new QueueProcessingManager(factory);
     processing.addProcessor(factory.getEnvironment().getDefaultFileGenerator());
     if (typeFilter != null) {
       processing.process(Query.getElements(factory.Package().getRootPackage(), typeFilter));
     } else {
       processing.process(factory.Package().getRootPackage());
     }
   }
 }
Exemplo n.º 2
0
  @Override
  public void process(Collection<Processor<? extends CtElement>> processors) {
    initInputClassLoader();

    // processing (consume all the processors)
    ProcessingManager processing = new QueueProcessingManager(factory);
    for (Processor<? extends CtElement> processorName : processors) {
      processing.addProcessor(processorName);
      factory.getEnvironment().debugMessage("Loaded processor " + processorName + ".");
    }

    processing.process(factory.Package().getRootPackage());
  }
Exemplo n.º 3
0
  @Override
  public void instantiateAndProcess(List<String> processors) {
    initInputClassLoader();

    // processing (consume all the processors)
    ProcessingManager processing = new QueueProcessingManager(factory);
    for (String processorName : processors) {
      processing.addProcessor(processorName);
      factory.getEnvironment().debugMessage("Loaded processor " + processorName + ".");
    }

    processing.process(factory.Package().getRootPackage());
  }
Exemplo n.º 4
0
 @Test
 public void testBasicAPIUsage() throws Exception {
   // this test shows a basic usage of the Launcher API without command line
   // and asserts there is no exception
   SpoonAPI spoon = new Launcher();
   spoon.addInputResource("src/test/resources/spoon/test/api");
   spoon.setSourceOutputDirectory("target/spooned");
   spoon.run();
   Factory factory = spoon.getFactory();
   for (CtPackage p : factory.Package().getAll()) {
     spoon.getEnvironment().debugMessage("package: " + p.getQualifiedName());
   }
   for (CtType<?> s : factory.Class().getAll()) {
     spoon.getEnvironment().debugMessage("class: " + s.getQualifiedName());
   }
 }