langtools/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java
author jjg
Fri, 29 Aug 2008 11:10:12 -0700
changeset 1206 3a05355982a9
parent 735 372aa565a221
child 1996 c855318a4b03
permissions -rw-r--r--
6597471: unused imports in javax.tools.JavaCompiler 6597531: unused imports and unused private const. in com.sun.tools.javac.Server.java Reviewed-by: mcimadamore Contributed-by: davide.angelocola@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
735
372aa565a221 6719955: Update copyright year
xdono
parents: 168
diff changeset
     2
 * Copyright 2006-2008 Sun Microsystems, Inc.  All Rights Reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
 * have any questions.
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.javac.main;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
    28
import com.sun.tools.javac.code.Lint;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import com.sun.tools.javac.code.Source;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import com.sun.tools.javac.code.Type;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import com.sun.tools.javac.jvm.Target;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import com.sun.tools.javac.main.JavacOption.HiddenOption;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import com.sun.tools.javac.main.JavacOption.Option;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
import com.sun.tools.javac.main.JavacOption.XOption;
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
import com.sun.tools.javac.util.ListBuffer;
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
import com.sun.tools.javac.util.Options;
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
import java.io.File;
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
import java.io.FileWriter;
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
import java.io.PrintWriter;
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
    41
import java.util.Collection;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
import java.util.EnumSet;
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
    43
import java.util.LinkedHashSet;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
import java.util.Set;
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
import javax.lang.model.SourceVersion;
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
import static com.sun.tools.javac.main.OptionName.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 * TODO: describe com.sun.tools.javac.main.RecognizedOptions
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 * <p><b>This is NOT part of any API supported by Sun Microsystems.
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 * If you write code that depends on this, you do so at your own
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 * risk.  This code and its internal interfaces are subject to change
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
 * or deletion without notice.</b></p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
public class RecognizedOptions {
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    private RecognizedOptions() {}
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    public interface OptionHelper {
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
        void setOut(PrintWriter out);
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
        void error(String key, Object... args);
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
        void printVersion();
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
        void printFullVersion();
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
        void printHelp();
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
        void printXhelp();
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
        void addFile(File f);
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        void addClassName(String s);
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    public static class GrumpyHelper implements OptionHelper {
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
        public void setOut(PrintWriter out) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
            throw new IllegalArgumentException();
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
        public void error(String key, Object... args) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
            throw new IllegalArgumentException(Main.getLocalizedString(key, args));
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
        public void printVersion() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
            throw new IllegalArgumentException();
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
        public void printFullVersion() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
            throw new IllegalArgumentException();
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
        public void printHelp() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
            throw new IllegalArgumentException();
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
        public void printXhelp() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
            throw new IllegalArgumentException();
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
        public void addFile(File f) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
            throw new IllegalArgumentException(f.getPath());
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
        public void addClassName(String s) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
            throw new IllegalArgumentException(s);
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    static Set<OptionName> javacOptions = EnumSet.of(
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
        G,
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
        G_NONE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
        G_CUSTOM,
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
        XLINT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        XLINT_CUSTOM,
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
        NOWARN,
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        VERBOSE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        DEPRECATION,
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
        CLASSPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
        CP,
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
        SOURCEPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
        BOOTCLASSPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
        XBOOTCLASSPATH_PREPEND,
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        XBOOTCLASSPATH_APPEND,
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        XBOOTCLASSPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
        EXTDIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
        DJAVA_EXT_DIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
        ENDORSEDDIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
        DJAVA_ENDORSED_DIRS,
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   137
        PROC,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
        PROCESSOR,
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
        PROCESSORPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
        D,
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
        S,
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
        IMPLICIT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        ENCODING,
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
        SOURCE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
        TARGET,
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
        VERSION,
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
        FULLVERSION,
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
        HELP,
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
        A,
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        X,
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
        J,
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        MOREINFO,
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
        WERROR,
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
        // COMPLEXINFERENCE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
        PROMPT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
        DOE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
        PRINTSOURCE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
        WARNUNCHECKED,
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
        XMAXERRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
        XMAXWARNS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
        XSTDOUT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
        XPRINT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
        XPRINTROUNDS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
        XPRINTPROCESSORINFO,
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
        XPREFER,
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
        O,
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
        XJCOV,
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
        XD,
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
        SOURCEFILE);
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
    static Set<OptionName> javacFileManagerOptions = EnumSet.of(
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
        CLASSPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
        CP,
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
        SOURCEPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
        BOOTCLASSPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
        XBOOTCLASSPATH_PREPEND,
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
        XBOOTCLASSPATH_APPEND,
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
        XBOOTCLASSPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
        EXTDIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        DJAVA_EXT_DIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
        ENDORSEDDIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
        DJAVA_ENDORSED_DIRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
        PROCESSORPATH,
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
        D,
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
        S,
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
        ENCODING,
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
        SOURCE);
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
    static Set<OptionName> javacToolOptions = EnumSet.of(
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
        G,
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
        G_NONE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
        G_CUSTOM,
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
        XLINT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
        XLINT_CUSTOM,
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
        NOWARN,
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
        VERBOSE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
        DEPRECATION,
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   198
        PROC,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
        PROCESSOR,
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
        IMPLICIT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
        SOURCE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
        TARGET,
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
        // VERSION,
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
        // FULLVERSION,
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
        // HELP,
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
        A,
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
        // X,
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
        // J,
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
        MOREINFO,
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
        WERROR,
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
        // COMPLEXINFERENCE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
        PROMPT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
        DOE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
        PRINTSOURCE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
        WARNUNCHECKED,
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
        XMAXERRS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
        XMAXWARNS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
        // XSTDOUT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        XPRINT,
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
        XPRINTROUNDS,
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
        XPRINTPROCESSORINFO,
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
        XPREFER,
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
        O,
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
        XJCOV,
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
        XD);
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
    static Option[] getJavaCompilerOptions(OptionHelper helper) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
        return getOptions(helper, javacOptions);
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
    public static Option[] getJavacFileManagerOptions(OptionHelper helper) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
        return getOptions(helper, javacFileManagerOptions);
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
    public static Option[] getJavacToolOptions(OptionHelper helper) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
        return getOptions(helper, javacToolOptions);
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
    static Option[] getOptions(OptionHelper helper, Set<OptionName> desired) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
        ListBuffer<Option> options = new ListBuffer<Option>();
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
        for (Option option : getAll(helper))
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
            if (desired.contains(option.getName()))
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
                options.append(option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
        return options.toArray(new Option[options.length()]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
    /**
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   248
     * Get all the recognized options.
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   249
     * @param helper an {@code OptionHelper} to help when processing options
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   250
     * @return an array of options
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
    public static Option[] getAll(final OptionHelper helper) {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   253
        return new Option[] {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
        new Option(G,                                           "opt.g"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
        new Option(G_NONE,                                      "opt.g.none") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   256
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
                options.put("-g:", "none");
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   263
        new Option(G_CUSTOM,                                    "opt.g.lines.vars.source",
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   264
                Option.ChoiceKind.ANYOF, "lines", "vars", "source"),
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   265
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   266
        new XOption(XLINT,                                      "opt.Xlint"),
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   267
        new XOption(XLINT_CUSTOM,                               "opt.Xlint.suboptlist",
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   268
                Option.ChoiceKind.ANYOF, getXLintChoices()),
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   269
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   270
        // -nowarn is retained for command-line backward compatibility
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   271
        new Option(NOWARN,                                      "opt.nowarn") {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   272
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
            public boolean process(Options options, String option) {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   274
                options.put("-Xlint:none", option);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
        new Option(VERBOSE,                                     "opt.verbose"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
        // -deprecation is retained for command-line backward compatibility
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
        new Option(DEPRECATION,                                 "opt.deprecation") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   283
            @Override
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   284
            public boolean process(Options options, String option) {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   285
                options.put("-Xlint:deprecation", option);
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   286
                return false;
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   287
            }
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   288
        },
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
        new Option(CLASSPATH,              "opt.arg.path",      "opt.classpath"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
        new Option(CP,                     "opt.arg.path",      "opt.classpath") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   292
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
            public boolean process(Options options, String option, String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
                return super.process(options, "-classpath", arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
        new Option(SOURCEPATH,             "opt.arg.path",      "opt.sourcepath"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
        new Option(BOOTCLASSPATH,          "opt.arg.path",      "opt.bootclasspath") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   299
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
            public boolean process(Options options, String option, String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
                options.remove("-Xbootclasspath/p:");
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
                options.remove("-Xbootclasspath/a:");
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
                return super.process(options, option, arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
        new XOption(XBOOTCLASSPATH_PREPEND,"opt.arg.path", "opt.Xbootclasspath.p"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
        new XOption(XBOOTCLASSPATH_APPEND, "opt.arg.path", "opt.Xbootclasspath.a"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
        new XOption(XBOOTCLASSPATH,        "opt.arg.path", "opt.bootclasspath") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   309
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
            public boolean process(Options options, String option, String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
                options.remove("-Xbootclasspath/p:");
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
                options.remove("-Xbootclasspath/a:");
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
                return super.process(options, "-bootclasspath", arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
        new Option(EXTDIRS,                "opt.arg.dirs",      "opt.extdirs"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
        new XOption(DJAVA_EXT_DIRS,        "opt.arg.dirs",      "opt.extdirs") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   318
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
            public boolean process(Options options, String option, String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
                return super.process(options, "-extdirs", arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
        new Option(ENDORSEDDIRS,            "opt.arg.dirs",     "opt.endorseddirs"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
        new XOption(DJAVA_ENDORSED_DIRS,    "opt.arg.dirs",     "opt.endorseddirs") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   325
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
            public boolean process(Options options, String option, String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
                return super.process(options, "-endorseddirs", arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
        },
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   330
        new Option(PROC,                                 "opt.proc.none.only",
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   331
                Option.ChoiceKind.ONEOF, "none", "only"),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
        new Option(PROCESSOR,           "opt.arg.class.list",   "opt.processor"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
        new Option(PROCESSORPATH,       "opt.arg.path",         "opt.processorpath"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
        new Option(D,                   "opt.arg.directory",    "opt.d"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
        new Option(S,                   "opt.arg.directory",    "opt.sourceDest"),
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   336
        new Option(IMPLICIT,                                    "opt.implicit",
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   337
                Option.ChoiceKind.ONEOF, "none", "class"),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
        new Option(ENCODING,            "opt.arg.encoding",     "opt.encoding"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
        new Option(SOURCE,              "opt.arg.release",      "opt.source") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   340
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
            public boolean process(Options options, String option, String operand) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
                Source source = Source.lookup(operand);
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
                if (source == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
                    helper.error("err.invalid.source", operand);
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
                    return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
                return super.process(options, option, operand);
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
        new Option(TARGET,              "opt.arg.release",      "opt.target") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   351
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
            public boolean process(Options options, String option, String operand) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
                Target target = Target.lookup(operand);
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
                if (target == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
                    helper.error("err.invalid.target", operand);
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
                    return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
                return super.process(options, option, operand);
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
        new Option(VERSION,                                     "opt.version") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   362
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
                helper.printVersion();
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
                return super.process(options, option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
        new HiddenOption(FULLVERSION) {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   369
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
                helper.printFullVersion();
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
                return super.process(options, option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
        new Option(HELP,                                        "opt.help") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   376
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
                helper.printHelp();
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
                return super.process(options, option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
        new Option(A,                "opt.arg.key.equals.value","opt.A") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   383
            @Override
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   384
            String helpSynopsis() {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   385
                hasSuffix = true;
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   386
                return super.helpSynopsis();
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   387
            }
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   388
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   389
            @Override
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   390
            public boolean matches(String arg) {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   391
                return arg.startsWith("-A");
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   392
            }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   394
            @Override
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   395
            public boolean hasArg() {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   396
                return false;
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   397
            }
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   398
            // Mapping for processor options created in
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   399
            // JavacProcessingEnvironment
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   400
            @Override
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   401
            public boolean process(Options options, String option) {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   402
                int argLength = option.length();
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   403
                if (argLength == 2) {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   404
                    helper.error("err.empty.A.argument");
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   405
                    return true;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
                }
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   407
                int sepIndex = option.indexOf('=');
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   408
                String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   409
                if (!JavacProcessingEnvironment.isValidOptionName(key)) {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   410
                    helper.error("err.invalid.A.key", option);
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   411
                    return true;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
                }
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   413
                return process(options, option, option);
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   414
            }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   415
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   416
        new Option(X,                                           "opt.X") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   417
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   418
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   419
                helper.printXhelp();
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
                return super.process(options, option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   422
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   423
06bc494ca11e Initial load
duke
parents:
diff changeset
   424
        // This option exists only for the purpose of documenting itself.
06bc494ca11e Initial load
duke
parents:
diff changeset
   425
        // It's actually implemented by the launcher.
06bc494ca11e Initial load
duke
parents:
diff changeset
   426
        new Option(J,                   "opt.arg.flag",         "opt.J") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   427
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   428
            String helpSynopsis() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   429
                hasSuffix = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   430
                return super.helpSynopsis();
06bc494ca11e Initial load
duke
parents:
diff changeset
   431
            }
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   432
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   433
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   434
                throw new AssertionError
06bc494ca11e Initial load
duke
parents:
diff changeset
   435
                    ("the -J flag should be caught by the launcher.");
06bc494ca11e Initial load
duke
parents:
diff changeset
   436
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   437
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   438
06bc494ca11e Initial load
duke
parents:
diff changeset
   439
        // stop after parsing and attributing.
06bc494ca11e Initial load
duke
parents:
diff changeset
   440
        // new HiddenOption("-attrparseonly"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   441
06bc494ca11e Initial load
duke
parents:
diff changeset
   442
        // new Option("-moreinfo",                                      "opt.moreinfo") {
06bc494ca11e Initial load
duke
parents:
diff changeset
   443
        new HiddenOption(MOREINFO) {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   444
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   445
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   446
                Type.moreInfo = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   447
                return super.process(options, option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   448
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   449
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   450
06bc494ca11e Initial load
duke
parents:
diff changeset
   451
        // treat warnings as errors
06bc494ca11e Initial load
duke
parents:
diff changeset
   452
        new HiddenOption(WERROR),
06bc494ca11e Initial load
duke
parents:
diff changeset
   453
06bc494ca11e Initial load
duke
parents:
diff changeset
   454
        // use complex inference from context in the position of a method call argument
06bc494ca11e Initial load
duke
parents:
diff changeset
   455
        new HiddenOption(COMPLEXINFERENCE),
06bc494ca11e Initial load
duke
parents:
diff changeset
   456
06bc494ca11e Initial load
duke
parents:
diff changeset
   457
        // generare source stubs
06bc494ca11e Initial load
duke
parents:
diff changeset
   458
        // new HiddenOption("-stubs"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   459
06bc494ca11e Initial load
duke
parents:
diff changeset
   460
        // relax some constraints to allow compiling from stubs
06bc494ca11e Initial load
duke
parents:
diff changeset
   461
        // new HiddenOption("-relax"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   462
06bc494ca11e Initial load
duke
parents:
diff changeset
   463
        // output source after translating away inner classes
06bc494ca11e Initial load
duke
parents:
diff changeset
   464
        // new Option("-printflat",                             "opt.printflat"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   465
        // new HiddenOption("-printflat"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   466
06bc494ca11e Initial load
duke
parents:
diff changeset
   467
        // display scope search details
06bc494ca11e Initial load
duke
parents:
diff changeset
   468
        // new Option("-printsearch",                           "opt.printsearch"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   469
        // new HiddenOption("-printsearch"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   470
06bc494ca11e Initial load
duke
parents:
diff changeset
   471
        // prompt after each error
06bc494ca11e Initial load
duke
parents:
diff changeset
   472
        // new Option("-prompt",                                        "opt.prompt"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   473
        new HiddenOption(PROMPT),
06bc494ca11e Initial load
duke
parents:
diff changeset
   474
06bc494ca11e Initial load
duke
parents:
diff changeset
   475
        // dump stack on error
06bc494ca11e Initial load
duke
parents:
diff changeset
   476
        new HiddenOption(DOE),
06bc494ca11e Initial load
duke
parents:
diff changeset
   477
06bc494ca11e Initial load
duke
parents:
diff changeset
   478
        // output source after type erasure
06bc494ca11e Initial load
duke
parents:
diff changeset
   479
        // new Option("-s",                                     "opt.s"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   480
        new HiddenOption(PRINTSOURCE),
06bc494ca11e Initial load
duke
parents:
diff changeset
   481
06bc494ca11e Initial load
duke
parents:
diff changeset
   482
        // output shrouded class files
06bc494ca11e Initial load
duke
parents:
diff changeset
   483
        // new Option("-scramble",                              "opt.scramble"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   484
        // new Option("-scrambleall",                           "opt.scrambleall"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   485
06bc494ca11e Initial load
duke
parents:
diff changeset
   486
        // display warnings for generic unchecked operations
06bc494ca11e Initial load
duke
parents:
diff changeset
   487
        new HiddenOption(WARNUNCHECKED) {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   488
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   489
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   490
                options.put("-Xlint:unchecked", option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   491
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   492
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   493
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   494
06bc494ca11e Initial load
duke
parents:
diff changeset
   495
        new XOption(XMAXERRS,           "opt.arg.number",       "opt.maxerrs"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   496
        new XOption(XMAXWARNS,          "opt.arg.number",       "opt.maxwarns"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   497
        new XOption(XSTDOUT,            "opt.arg.file",         "opt.Xstdout") {
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   498
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   499
            public boolean process(Options options, String option, String arg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   500
                try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   501
                    helper.setOut(new PrintWriter(new FileWriter(arg), true));
06bc494ca11e Initial load
duke
parents:
diff changeset
   502
                } catch (java.io.IOException e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   503
                    helper.error("err.error.writing.file", arg, e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   504
                    return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   505
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   506
                return super.process(options, option, arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   507
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   508
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   509
06bc494ca11e Initial load
duke
parents:
diff changeset
   510
        new XOption(XPRINT,                                     "opt.print"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   511
06bc494ca11e Initial load
duke
parents:
diff changeset
   512
        new XOption(XPRINTROUNDS,                               "opt.printRounds"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   513
06bc494ca11e Initial load
duke
parents:
diff changeset
   514
        new XOption(XPRINTPROCESSORINFO,                        "opt.printProcessorInfo"),
06bc494ca11e Initial load
duke
parents:
diff changeset
   515
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   516
        new XOption(XPREFER,                                    "opt.prefer",
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   517
                Option.ChoiceKind.ONEOF, "source", "newer"),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   518
06bc494ca11e Initial load
duke
parents:
diff changeset
   519
        /* -O is a no-op, accepted for backward compatibility. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   520
        new HiddenOption(O),
06bc494ca11e Initial load
duke
parents:
diff changeset
   521
06bc494ca11e Initial load
duke
parents:
diff changeset
   522
        /* -Xjcov produces tables to support the code coverage tool jcov. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   523
        new HiddenOption(XJCOV),
06bc494ca11e Initial load
duke
parents:
diff changeset
   524
06bc494ca11e Initial load
duke
parents:
diff changeset
   525
        /* This is a back door to the compiler's option table.
06bc494ca11e Initial load
duke
parents:
diff changeset
   526
         * -XDx=y sets the option x to the value y.
06bc494ca11e Initial load
duke
parents:
diff changeset
   527
         * -XDx sets the option x to the value x.
06bc494ca11e Initial load
duke
parents:
diff changeset
   528
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   529
        new HiddenOption(XD) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   530
            String s;
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   531
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   532
            public boolean matches(String s) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   533
                this.s = s;
06bc494ca11e Initial load
duke
parents:
diff changeset
   534
                return s.startsWith(name.optionName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   535
            }
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   536
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   537
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   538
                s = s.substring(name.optionName.length());
06bc494ca11e Initial load
duke
parents:
diff changeset
   539
                int eq = s.indexOf('=');
06bc494ca11e Initial load
duke
parents:
diff changeset
   540
                String key = (eq < 0) ? s : s.substring(0, eq);
06bc494ca11e Initial load
duke
parents:
diff changeset
   541
                String value = (eq < 0) ? s : s.substring(eq+1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   542
                options.put(key, value);
06bc494ca11e Initial load
duke
parents:
diff changeset
   543
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   544
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   545
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   546
06bc494ca11e Initial load
duke
parents:
diff changeset
   547
        /*
06bc494ca11e Initial load
duke
parents:
diff changeset
   548
         * TODO: With apt, the matches method accepts anything if
06bc494ca11e Initial load
duke
parents:
diff changeset
   549
         * -XclassAsDecls is used; code elsewhere does the lookup to
06bc494ca11e Initial load
duke
parents:
diff changeset
   550
         * see if the class name is both legal and found.
06bc494ca11e Initial load
duke
parents:
diff changeset
   551
         *
06bc494ca11e Initial load
duke
parents:
diff changeset
   552
         * In apt, the process method adds the candiate class file
06bc494ca11e Initial load
duke
parents:
diff changeset
   553
         * name to a separate list.
06bc494ca11e Initial load
duke
parents:
diff changeset
   554
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   555
        new HiddenOption(SOURCEFILE) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   556
            String s;
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   557
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   558
            public boolean matches(String s) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   559
                this.s = s;
06bc494ca11e Initial load
duke
parents:
diff changeset
   560
                return s.endsWith(".java")  // Java source file
06bc494ca11e Initial load
duke
parents:
diff changeset
   561
                    || SourceVersion.isName(s);   // Legal type name
06bc494ca11e Initial load
duke
parents:
diff changeset
   562
            }
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   563
            @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   564
            public boolean process(Options options, String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   565
                if (s.endsWith(".java") ) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   566
                    File f = new File(s);
06bc494ca11e Initial load
duke
parents:
diff changeset
   567
                    if (!f.exists()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   568
                        helper.error("err.file.not.found", f);
06bc494ca11e Initial load
duke
parents:
diff changeset
   569
                        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   570
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   571
                    if (!f.isFile()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   572
                        helper.error("err.file.not.file", f);
06bc494ca11e Initial load
duke
parents:
diff changeset
   573
                        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   574
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   575
                    helper.addFile(f);
06bc494ca11e Initial load
duke
parents:
diff changeset
   576
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   577
                else
06bc494ca11e Initial load
duke
parents:
diff changeset
   578
                    helper.addClassName(s);
06bc494ca11e Initial load
duke
parents:
diff changeset
   579
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   580
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   581
        },
06bc494ca11e Initial load
duke
parents:
diff changeset
   582
    };
06bc494ca11e Initial load
duke
parents:
diff changeset
   583
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   584
168
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   585
    private static Collection<String> getXLintChoices() {
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   586
        Collection<String> choices = new LinkedHashSet<String>();
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   587
        choices.add("all");
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   588
        for (Lint.LintCategory c : Lint.LintCategory.values())
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   589
            choices.add(c.option);
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   590
        for (Lint.LintCategory c : Lint.LintCategory.values())
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   591
            choices.add("-" + c.option);
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   592
        choices.add("none");
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   593
        return choices;
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   594
    }
25697c18650b 6307187: clean up code for -Xlint:options
jjg
parents: 10
diff changeset
   595
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   596
}