* @param helper an {@code OptionHelper} to help when processing options
* @return an array of options
*/
public static Option[] getAll(final OptionHelper helper) {
return new Option[] {
new Option(G, "opt.g"),
new Option(G_NONE, "opt.g.none") {
@Override
public boolean process(Options options, String option) {
options.put("-g:", "none");
return false;
}
},
new Option(G_CUSTOM, "opt.g.lines.vars.source",
Option.ChoiceKind.ANYOF, "lines", "vars", "source"),
new XOption(XLINT, "opt.Xlint"),
new XOption(XLINT_CUSTOM, "opt.Xlint.suboptlist",
Option.ChoiceKind.ANYOF, getXLintChoices()),
// -nowarn is retained for command-line backward compatibility
new Option(NOWARN, "opt.nowarn") {
@Override
public boolean process(Options options, String option) {
options.put("-Xlint:none", option);
return false;
}
},
new Option(VERBOSE, "opt.verbose"),
new Option(VERBOSE_CUSTOM, "opt.verbose.suboptlist") {
public boolean matches(String s) {
return s.startsWith("-verbose:");
}
public boolean process(Options options, String option) {
String suboptions = option.substring(9);
options.put("-verbose:", suboptions);
// enter all the -verbose suboptions as "-verbose:suboption"
for (StringTokenizer t = new StringTokenizer(suboptions, ","); t.hasMoreTokens(); ) {
String tok = t.nextToken();
String opt = "-verbose:" + tok;
options.put(opt, opt);
}
return false;
}
},
// -deprecation is retained for command-line backward compatibility
new Option(DEPRECATION, "opt.deprecation") {
@Override
public boolean process(Options options, String option) {
options.put("-Xlint:deprecation", option);
return false;
}
},
new Option(CLASSPATH, "opt.arg.path", "opt.classpath"),
new Option(CP, "opt.arg.path", "opt.classpath") {
@Override
public boolean process(Options options, String option, String arg) {
return super.process(options, "-classpath", arg);
}
},
new COption(CEYLONCWD, "opt.arg.path", "opt.ceyloncwd"),
new COption(CEYLONREPO, "opt.arg.url", "opt.ceylonrepo"){
@Override
public boolean process(Options options, String option, String arg) {
if(options != null)
options.addMulti(CEYLONREPO, arg);
return false;
}
},
new COption(CEYLONSYSTEMREPO, "opt.arg.url", "opt.ceylonsystemrepo"),
new COption(CEYLONCACHEREPO, "opt.arg.url", "opt.ceyloncacherepo"),
new COption(CEYLONNODEFREPOS, "opt.ceylonnodefrepos"),
new COption(CEYLONUSER, "opt.arg.value", "opt.ceylonuser"),
new COption(CEYLONPASS, "opt.arg.value", "opt.ceylonpass"),
new COption(CEYLONNOOSGI, "opt.ceylonnoosgi"),
new COption(CEYLONNOPOM, "opt.ceylonnopom"),
new COption(CEYLONPACK200, "opt.ceylonpack200"),
new COption(CEYLONRESOURCEROOT, "opt.arg.path", "opt.ceylonresourceroot"),
new COption(CEYLONDISABLEOPT, "opt.ceylondisableopt"),
new COption(CEYLONDISABLEOPT_CUSTOM, "opt.ceylondisableopt.suboptlist"),
new COption(CEYLONSUPPRESSWARNINGS, "opt.arg.value", "opt.ceylonsuppresswarnings"),
new Option(SOURCEPATH, "opt.arg.path", "opt.sourcepath"){
@Override
public boolean process(Options options, String option, String arg) {
if(options != null)
options.addMulti(SOURCEPATH, arg);
return false;
}
},
new COption(CEYLONSOURCEPATH, "opt.arg.directory", "opt.ceylonsourcepath"){
@Override
public boolean process(Options options, String option, String arg) {
if(options != null)
options.addMulti(SOURCEPATH, arg);
return false;
}
},
new COption(CEYLONRESOURCEPATH, "opt.arg.url", "opt.ceylonresourcepath"){
@Override
public boolean process(Options options, String option, String arg) {
if(options != null)
options.addMulti(CEYLONRESOURCEPATH, arg);
return false;
}
},
new Option(BOOTCLASSPATH, "opt.arg.path", "opt.bootclasspath") {
@Override
public boolean process(Options options, String option, String arg) {
options.remove("-Xbootclasspath/p:");
options.remove("-Xbootclasspath/a:");
return super.process(options, option, arg);
}
},
new XOption(XBOOTCLASSPATH_PREPEND,"opt.arg.path", "opt.Xbootclasspath.p"),
new XOption(XBOOTCLASSPATH_APPEND, "opt.arg.path", "opt.Xbootclasspath.a"),
new XOption(XBOOTCLASSPATH, "opt.arg.path", "opt.bootclasspath") {
@Override
public boolean process(Options options, String option, String arg) {
options.remove("-Xbootclasspath/p:");
options.remove("-Xbootclasspath/a:");
return super.process(options, "-bootclasspath", arg);
}
},
new Option(EXTDIRS, "opt.arg.dirs", "opt.extdirs"),
new XOption(DJAVA_EXT_DIRS, "opt.arg.dirs", "opt.extdirs") {
@Override
public boolean process(Options options, String option, String arg) {
return super.process(options, "-extdirs", arg);
}
},
new Option(ENDORSEDDIRS, "opt.arg.dirs", "opt.endorseddirs"),
new XOption(DJAVA_ENDORSED_DIRS, "opt.arg.dirs", "opt.endorseddirs") {
@Override
public boolean process(Options options, String option, String arg) {
return super.process(options, "-endorseddirs", arg);
}
},
new Option(PROC, "opt.proc.none.only",
Option.ChoiceKind.ONEOF, "none", "only"),
new Option(PROCESSOR, "opt.arg.class.list", "opt.processor"),
new Option(PROCESSORPATH, "opt.arg.path", "opt.processorpath"),
new Option(D, "opt.arg.directory", "opt.d"),
new COption(CEYLONOUT, "opt.arg.url", "opt.ceylonout"){
@Override
public boolean process(Options options, String option, String arg) {
return super.process(options, "-d", arg);
}
},
new COption(CEYLONOFFLINE, "opt.ceylonoffline"),
new COption(CEYLONCONTINUE, "opt.ceyloncontinue"),
new COption(CEYLONMAVENOVERRIDES, "opt.arg.url", "opt.ceylonmavenoverrides"),
new Option(S, "opt.arg.directory", "opt.sourceDest"),
new Option(IMPLICIT, "opt.implicit",
Option.ChoiceKind.ONEOF, "none", "class"),
new Option(ENCODING, "opt.arg.encoding", "opt.encoding") {
@Override
public boolean process(Options options, String option, String operand) {
try {
Charset.forName(operand);
options.put(option, operand);
return false;
} catch (UnsupportedCharsetException e) {
helper.error("err.unsupported.encoding", operand);
return true;
} catch (IllegalCharsetNameException e) {
helper.error("err.unsupported.encoding", operand);
return true;
}
}
},
new Option(SOURCE, "opt.arg.release", "opt.source") {
@Override
public boolean process(Options options, String option, String operand) {
Source source = Source.lookup(operand);
if (source == null) {
helper.error("err.invalid.source", operand);
return true;
}
return super.process(options, option, operand);
}
},
new Option(TARGET, "opt.arg.release", "opt.target") {
@Override
public boolean process(Options options, String option, String operand) {
Target target = Target.lookup(operand);
if (target == null) {
helper.error("err.invalid.target", operand);
return true;
}
return super.process(options, option, operand);
}
},
new COption(VERSION, "opt.version") {
@Override
public boolean process(Options options, String option) {
helper.printVersion();
return super.process(options, option);
}
},
new HiddenOption(FULLVERSION) {
@Override
public boolean process(Options options, String option) {
helper.printFullVersion();
return super.process(options, option);
}
},
new HiddenOption(DIAGS) {
@Override
public boolean process(Options options, String option) {
Option xd = getOptions(helper, EnumSet.of(XD))[0];
option = option.substring(option.indexOf('=') + 1);
String diagsOption = option.contains("%") ?
"-XDdiagsFormat=" :
"-XDdiags=";
diagsOption += option;
if (xd.matches(diagsOption))
return xd.process(options, diagsOption);
else
return false;
}
},
new COption(HELP, "opt.help") {
@Override
public boolean process(Options options, String option) {
helper.printHelp();
return super.process(options, option);
}
},
new Option(A, "opt.arg.key.equals.value","opt.A") {
@Override
String helpSynopsis() {
hasSuffix = true;
return super.helpSynopsis();
}
@Override
public boolean matches(String arg) {
return arg.startsWith("-A");
}
@Override
public boolean hasArg() {
return false;
}
// Mapping for processor options created in
// JavacProcessingEnvironment
@Override
public boolean process(Options options, String option) {
int argLength = option.length();
if (argLength == 2) {
helper.error("err.empty.A.argument");
return true;
}
int sepIndex = option.indexOf('=');
String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
if (!JavacProcessingEnvironment.isValidOptionName(key)) {
helper.error("err.invalid.A.key", option);
return true;
}
return process(options, option, option);
}
},
new Option(X, "opt.X") {
@Override
public boolean process(Options options, String option) {
helper.printXhelp();
return super.process(options, option);
}
},
// This option exists only for the purpose of documenting itself.
// It's actually implemented by the launcher.
new Option(J, "opt.arg.flag", "opt.J") {
@Override
String helpSynopsis() {
hasSuffix = true;
return super.helpSynopsis();
}
@Override
public boolean process(Options options, String option) {
throw new AssertionError
("the -J flag should be caught by the launcher.");
}
},
// stop after parsing and attributing.
// new HiddenOption("-attrparseonly"),
// new Option("-moreinfo", "opt.moreinfo") {
new HiddenOption(MOREINFO) {
@Override
public boolean process(Options options, String option) {
Type.moreInfo = true;
return super.process(options, option);
}
},
// treat warnings as errors
new Option(WERROR, "opt.Werror"),
new Option(SRC, "opt.arg.src", "opt.src") {
public boolean process(Options options, String option, String arg) {
return super.process(options, "-src", arg);
}
},
// use complex inference from context in the position of a method call argument
new HiddenOption(COMPLEXINFERENCE),
// generare source stubs
// new HiddenOption("-stubs"),
// relax some constraints to allow compiling from stubs
// new HiddenOption("-relax"),
// output source after translating away inner classes
// new Option("-printflat", "opt.printflat"),
// new HiddenOption("-printflat"),
// display scope search details
// new Option("-printsearch", "opt.printsearch"),
// new HiddenOption("-printsearch"),
// prompt after each error
// new Option("-prompt", "opt.prompt"),
new HiddenOption(PROMPT),
// dump stack on error
new HiddenOption(DOE),
// output source after type erasure
// new Option("-s", "opt.s"),
new HiddenOption(PRINTSOURCE),
// allow us to compile ceylon.language
new HiddenOption(BOOTSTRAPCEYLON),
// output shrouded class files
// new Option("-scramble", "opt.scramble"),
// new Option("-scrambleall", "opt.scrambleall"),
// display warnings for generic unchecked operations
new HiddenOption(WARNUNCHECKED) {
@Override
public boolean process(Options options, String option) {
options.put("-Xlint:unchecked", option);
return false;
}
},
new XOption(XMAXERRS, "opt.arg.number", "opt.maxerrs"),
new XOption(XMAXWARNS, "opt.arg.number", "opt.maxwarns"),
new XOption(XSTDOUT, "opt.arg.file", "opt.Xstdout") {
@Override
public boolean process(Options options, String option, String arg) {
try {
helper.setOut(new PrintWriter(new FileWriter(arg), true));
} catch (java.io.IOException e) {
helper.error("err.error.writing.file", arg, e);
return true;
}
return super.process(options, option, arg);
}
},
new XOption(XPRINT, "opt.print"),
new XOption(XPRINTROUNDS, "opt.printRounds"),
new XOption(XPRINTPROCESSORINFO, "opt.printProcessorInfo"),
new XOption(XPREFER, "opt.prefer",
Option.ChoiceKind.ONEOF, "source", "newer"),
new XOption(XPKGINFO, "opt.pkginfo",
Option.ChoiceKind.ONEOF, "always", "legacy", "nonempty"),
/* -O is a no-op, accepted for backward compatibility. */
new HiddenOption(O),
/* -Xjcov produces tables to support the code coverage tool jcov. */
new HiddenOption(XJCOV),
/* This is a back door to the compiler's option table.
* -XDx=y sets the option x to the value y.
* -XDx sets the option x to the value x.
*/
new HiddenOption(XD) {
String s;
@Override
public boolean matches(String s) {
this.s = s;
return s.startsWith(name.optionName);
}
@Override
public boolean process(Options options, String option) {
s = s.substring(name.optionName.length());
int eq = s.indexOf('=');
String key = (eq < 0) ? s : s.substring(0, eq);
String value = (eq < 0) ? s : s.substring(eq+1);
options.put(key, value);
return false;
}
},
// This option exists only for the purpose of documenting itself.
// It's actually implemented by the CommandLine class.
new Option(AT, "opt.arg.file", "opt.AT") {
@Override
String helpSynopsis() {
hasSuffix = true;
return super.helpSynopsis();
}