Beispiel #1
0
 private static void checkErrors() {
   int errors = ErrorUtil.errorCount();
   if (Options.treatWarningsAsErrors()) {
     errors += ErrorUtil.warningCount();
   }
   if (errors > 0) {
     System.exit(errors);
   }
 }
Beispiel #2
0
  /**
   * Runs the entire J2Swift pipeline.
   *
   * @param fileArgs the files to process, same format as command-line args to {@link #main}.
   */
  public static void run(List<String> fileArgs) {
    File preProcessorTempDir = null;
    File strippedSourcesDir = null;
    try {
      JdtParser parser = createParser();

      List<ProcessingContext> inputs = Lists.newArrayList();
      GenerationBatch batch = new GenerationBatch();
      batch.processFileArgs(fileArgs);
      inputs.addAll(batch.getInputs());
      if (ErrorUtil.errorCount() > 0) {
        return;
      }
      InputFilePreprocessor inputFilePreprocessor = new InputFilePreprocessor(parser);
      inputFilePreprocessor.processInputs(inputs);
      if (ErrorUtil.errorCount() > 0) {
        return;
      }
      strippedSourcesDir = inputFilePreprocessor.getStrippedSourcesDir();
      if (strippedSourcesDir != null) {
        parser.prependSourcepathEntry(strippedSourcesDir.getPath());
      }

      Options.getHeaderMap().loadMappings();
      TranslationProcessor translationProcessor =
          new TranslationProcessor(parser, loadDeadCodeMap());
      translationProcessor.processInputs(inputs);
      translationProcessor.processBuildClosureDependencies();
      if (ErrorUtil.errorCount() > 0) {
        return;
      }
      translationProcessor.postProcess();

      Options.getHeaderMap().printMappings();
    } finally {
      FileUtil.deleteTempDir(preProcessorTempDir);
      FileUtil.deleteTempDir(strippedSourcesDir);
    }
  }