use of org.eclipse.ceylon.langtools.tools.javac.main.OptionHelper in project ceylon by eclipse.
the class JavacTool method processOptions.
public static void processOptions(Context context, JavaFileManager fileManager, Iterable<String> options) {
if (options == null)
return;
final Options optionTable = Options.instance(context);
Log log = Log.instance(context);
Option[] recognizedOptions = Option.getJavacToolOptions().toArray(new Option[0]);
OptionHelper optionHelper = new GrumpyHelper(log) {
@Override
public String get(Option option) {
return optionTable.get(option.getText());
}
@Override
public java.util.List<String> getMulti(Option option) {
return optionTable.getMulti(option);
}
@Override
public void put(String name, String value) {
optionTable.put(name, value);
}
@Override
public void addMulti(String name, String value) {
optionTable.addMulti(name, value);
}
@Override
public void remove(String name) {
optionTable.remove(name);
}
};
Iterator<String> flags = options.iterator();
while (flags.hasNext()) {
String flag = flags.next();
int j;
for (j = 0; j < recognizedOptions.length; j++) {
Option ro = recognizedOptions[j];
if (ro.matches(flag))
break;
}
if (j == recognizedOptions.length) {
if (fileManager.handleOption(flag, flags)) {
continue;
} else {
String msg = log.localize(PrefixKind.JAVAC, "err.invalid.flag", flag);
throw new IllegalArgumentException(msg);
}
}
Option option = recognizedOptions[j];
if (option.hasArg()) {
if (!flags.hasNext()) {
String msg = log.localize(PrefixKind.JAVAC, "err.req.arg", flag);
throw new IllegalArgumentException(msg);
}
String operand = flags.next();
if (option.process(optionHelper, flag, operand))
// in case of errors
throw new IllegalArgumentException(flag + " " + operand);
} else {
if (option.process(optionHelper, flag))
// in case of errors
throw new IllegalArgumentException(flag);
}
}
optionTable.notifyListeners();
}
Aggregations