Search in sources :

Example 1 with GrumpyHelper

use of com.sun.tools.javac.main.RecognizedOptions.GrumpyHelper in project ceylon-compiler by ceylon.

the class JavacTool method processOptions.

public static void processOptions(Context context, JavaFileManager fileManager, Iterable<String> options) {
    if (options == null)
        return;
    Options optionTable = Options.instance(context);
    JavacOption[] recognizedOptions = RecognizedOptions.getJavacToolOptions(new GrumpyHelper());
    Iterator<String> flags = options.iterator();
    while (flags.hasNext()) {
        String flag = flags.next();
        int j;
        for (j = 0; j < recognizedOptions.length; j++) if (recognizedOptions[j].matches(flag))
            break;
        if (j == recognizedOptions.length) {
            if (fileManager.handleOption(flag, flags)) {
                continue;
            } else {
                String msg = Main.getLocalizedString("err.invalid.flag", flag);
                throw new IllegalArgumentException(msg);
            }
        }
        JavacOption option = recognizedOptions[j];
        if (option.hasArg()) {
            if (!flags.hasNext()) {
                String msg = Main.getLocalizedString("err.req.arg", flag);
                throw new IllegalArgumentException(msg);
            }
            String operand = flags.next();
            if (option.process(optionTable, flag, operand))
                // in case of errors
                throw new IllegalArgumentException(flag + " " + operand);
        } else {
            if (option.process(optionTable, flag))
                // in case of errors
                throw new IllegalArgumentException(flag);
        }
    }
}
Also used : RecognizedOptions(com.sun.tools.javac.main.RecognizedOptions) Options(com.sun.tools.javac.util.Options) JavacOption(com.sun.tools.javac.main.JavacOption) GrumpyHelper(com.sun.tools.javac.main.RecognizedOptions.GrumpyHelper)

Aggregations

JavacOption (com.sun.tools.javac.main.JavacOption)1 RecognizedOptions (com.sun.tools.javac.main.RecognizedOptions)1 GrumpyHelper (com.sun.tools.javac.main.RecognizedOptions.GrumpyHelper)1 Options (com.sun.tools.javac.util.Options)1