Пример #1
0
 public List<OptFlag.Arg<?>> filterArgs(Set<OptFlag<?>> flags) {
   List<Arg<?>> matches = new ArrayList<>();
   for (Arg<?> arg : arguments) {
     if (arg.flag != null && flags.contains(arg.flag())) matches.add(arg);
   }
   return matches;
 }
Пример #2
0
  /**
   * Iterates over arguments parsed from the command line and applies them to this object. Any
   * source arguments are added to {@code source}.
   *
   * @param source The set of source filenames provided on the command line.
   */
  protected final void applyArgs(Set<String> source) throws UsageError {
    // Set up defaults first.
    for (OptFlag<?> flag : flags) {
      Arg<?> arg = flag.defaultArg(arguments);
      if (arg != null) handleArg(arg);
    }

    // Let user-specified arguments override the defaults.
    for (Arg<?> arg : arguments) {
      if (arg.flag == null) {
        handleSourceArg(arg, source);
      } else {
        try {
          handleArg(arg);
        } catch (UsageError e) {
          throw e;
        } catch (Throwable e) {
          throw new InternalCompilerError(
              "Error while handling arg " + arg + " created by " + arg.flag().getClass(), e);
        }
      }
    }
  }
Пример #3
0
  /** Process the option specified by {@code arg} */
  protected void handleArg(Arg<?> arg) throws UsageError {
    assert arg.flag != null;
    Set<String> ids = arg.flag().ids();

    if (ids.contains("-d")) {
      setClassOutput((File) arg.value());
    } else if (ids.contains("-D")) {
      setSourceOutput((File) arg.value());
    } else if (ids.contains("-classpath")) {
      setClasspath(this.<List<File>, File>sccast(arg.value(), File.class));
    } else if (ids.contains("-bootclasspath")) {
      setBootclasspath(this.<List<File>, File>sccast(arg.value(), File.class));
    } else if (ids.contains("-addbootcp")) {
      addBootCP(this.<List<File>, File>sccast(arg.value(), File.class));
    } else if (ids.contains("-sourcepath")) {
      setSourcepath(this.<List<File>, File>sccast(arg.value(), File.class));
    } else if (ids.contains("-commandlineonly")) {
      setCommandLineOnly((Boolean) arg.value());
    } else if (ids.contains("-preferclassfiles")) {
      setIgnoreModTimes((Boolean) arg.value());
    } else if (ids.contains("-assert")) {
      setAssertions((Boolean) arg.value());
    } else if (ids.contains("-fqcn")) {
      setFullyQualifiedNames((Boolean) arg.value());
    } else if (ids.contains("-g")) {
      setGenerateDebugInfo((Boolean) arg.value());
    } else if (ids.contains("-c")) {
      setOutputOnly((Boolean) arg.value());
    } else if (ids.contains("-errors")) {
      setErrorCount((Integer) arg.value());
    } else if (ids.contains("-w")) {
      setOutputWidth((Integer) arg.value());
    } else if (ids.contains("-postcompiler")) {
      setPostCompiler((String) arg.value());
    } else if (ids.contains("-postopts")) {
      setPostCompilerOpts((String) arg.value());
    } else if (ids.contains("-stdout")) {
      setOutputStdOut((Boolean) arg.value());
    } else if (ids.contains("-sx")) {
      addSourceExtension((String) arg.value());
    } else if (ids.contains("-ox")) {
      setOutputExtension((String) arg.value());
    } else if (ids.contains("-noserial")) {
      setNoSerializedTypes((Boolean) arg.value());
    } else if (ids.contains("-dump")) {
      addDumpAST((String) arg.value());
    } else if (ids.contains("-print")) {
      addPrintAST((String) arg.value());
    } else if (ids.contains("-disable")) {
      addDisablePass((String) arg.value());
    } else if (ids.contains("-nooutput")) {
      setNoOutput((Boolean) arg.value());
    } else if (ids.contains("-verbose")) {
      setVerbose((Boolean) arg.value());
    } else if (ids.contains("-report")) {
      @SuppressWarnings("unchecked")
      Pair<String, Integer> pair = (Pair<String, Integer>) arg.value();
      addReportTopic(pair.part1(), pair.part2());
    } else if (ids.contains("-debugpositions")) {
      setDebugPositions((Boolean) arg.value());
    } else if (ids.contains("-simpleoutput")) {
      setSimpleOutput((Boolean) arg.value());
    } else if (ids.contains("-mergestrings")) {
      setMergeStrings((Boolean) arg.value());
    } else if (ids.contains("-print-arguments")) {
      print_args = (Boolean) arg.value();
    } else if (ids.contains("-no-output-to-fs")) {
      noOutputToFS = (Boolean) arg.value();
    } else throw new UnhandledArgument(arg);
  }