Exemplo n.º 1
0
 public void work() {
   setupEnvironment();
   final Project project = createDummyProject();
   MpsWorker.ObjectsToProcess go = new MpsWorker.ObjectsToProcess();
   collectModelsToGenerate(go);
   if (go.hasAnythingToGenerate()) {
     reload();
     executeTask(project, go);
   } else {
     error("Could not find anything to generate.");
   }
   disposeProjects(go.getProjects());
   dispose();
   showStatistic();
 }
Exemplo n.º 2
0
  @Override
  protected void executeTask(Project project, MpsWorker.ObjectsToProcess go) {
    Set<SModule> toCompile = SetSequence.fromSet(new LinkedHashSet<SModule>());
    SetSequence.fromSet(toCompile).addSequence(SetSequence.fromSet(go.getModules()));
    for (Project p : go.getProjects()) {
      SetSequence.fromSet(toCompile).addSequence(SetSequence.fromSet(go.getModules()));
    }
    for (final SModel modelDescriptor : go.getModels()) {
      SModule owningModule =
          ModelAccess.instance()
              .runReadAction(
                  new Computable<SModule>() {
                    public SModule compute() {
                      return modelDescriptor.getModule();
                    }
                  });
      SetSequence.fromSet(toCompile).addElement(owningModule);
    }
    final Set<SModule> finalToCompile =
        CollectionUtil.filter(
            toCompile,
            new Condition<SModule>() {
              public boolean met(SModule module) {
                boolean compileInMps =
                    !(module instanceof IModule) || ((IModule) module).isCompileInMPS();
                return compileInMps && !(module.isPackaged());
              }
            });
    if (finalToCompile.isEmpty()) {
      return;
    }
    info("Starting compilation:");
    StringBuffer sb = new StringBuffer();
    for (SModule m : finalToCompile) {
      sb.append("    ");
      sb.append(m.getModuleName());
      sb.append("\n");
    }
    info(sb.toString());
    MPSCompilationResult result =
        ModelAccess.instance()
            .runReadAction(
                new Computable<MPSCompilationResult>() {
                  public MPSCompilationResult compute() {
                    return new ModuleMaker()
                        .make(
                            finalToCompile,
                            new EmptyProgressMonitor() {
                              @Override
                              public void step(String text) {
                                info("    " + text);
                              }

                              @Override
                              public void start(String taskName, int work) {
                                info(taskName);
                              }
                            });
                  }
                });
    info(result.toString());
  }