src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java
author jlahoda
Fri, 09 Mar 2018 09:42:10 +0100
changeset 49197 cc2673fa8c20
parent 48543 7067fe4e054e
child 50055 0b63526d1550
permissions -rw-r--r--
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure. Summary: Catching CompletionFailures that would be thrown to API clients, and re-completing the symbols again when javac itself needs it. Reviewed-by: cushon, jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
     1
/*
48515
0da9fb7d7d04 8181878: javadoc should support/ignore --add-opens
jjg
parents: 47867
diff changeset
     2
 * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
     4
 *
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    10
 *
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    15
 * accompanied this code).
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    16
 *
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    20
 *
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    23
 * questions.
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    24
 */
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    25
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 31936
diff changeset
    26
package jdk.javadoc.internal.tool;
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    27
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 31936
diff changeset
    28
import java.util.ArrayList;
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
    29
import java.util.Arrays;
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
    30
import java.util.EnumMap;
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents: 22163
diff changeset
    31
import java.util.LinkedHashMap;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 31936
diff changeset
    32
import java.util.List;
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents: 22163
diff changeset
    33
import java.util.Map;
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
    34
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
    35
import javax.lang.model.element.ElementKind;
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents: 22163
diff changeset
    36
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents: 22163
diff changeset
    37
import com.sun.tools.javac.main.Option;
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
    38
import com.sun.tools.javac.main.Option.InvalidValueException;
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
    39
import com.sun.tools.javac.main.Option.OptionKind;
37393
a9ba8bd6697b 8152818: Javadoc must support module options supported by javac.
ksrini
parents: 36526
diff changeset
    40
import com.sun.tools.javac.main.OptionHelper;
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    41
import com.sun.tools.javac.util.Options;
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    42
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
    43
import static com.sun.tools.javac.main.Option.OptionKind.*;
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
    44
import static jdk.javadoc.internal.tool.Main.Result.*;
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
    45
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    46
/**
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    47
 * javadoc tool options.
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    48
 *
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    49
 *  <p><b>This is NOT part of any supported API.
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    50
 *  If you write code that depends on this, you do so at your own risk.
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    51
 *  This code and its internal interfaces are subject to change or
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    52
 *  deletion without notice.</b>
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    53
 */
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    54
public enum ToolOption {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
    55
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    56
    // ----- options for underlying compiler -----
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    57
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
    58
    BOOTCLASSPATH("-bootclasspath", STANDARD, true) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    59
        @Override
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
    60
        public void process(Helper helper, String arg) throws InvalidValueException {
41990
ffaf4e59538a 8166379: IAE while invoking javadoc with --patch-module
ksrini
parents: 41451
diff changeset
    61
            Option.BOOT_CLASS_PATH.process(helper.getOptionHelper(), primaryName, arg);
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    62
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    63
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    64
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
    65
    CLASS_PATH("--class-path -classpath -cp", STANDARD, true) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    66
        @Override
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
    67
        public void process(Helper helper, String arg) throws InvalidValueException {
41990
ffaf4e59538a 8166379: IAE while invoking javadoc with --patch-module
ksrini
parents: 41451
diff changeset
    68
            Option.CLASS_PATH.process(helper.getOptionHelper(), primaryName, arg);
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    69
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    70
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    71
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
    72
    EXTDIRS("-extdirs", STANDARD, true) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    73
        @Override
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
    74
        public void process(Helper helper, String arg) throws InvalidValueException {
41990
ffaf4e59538a 8166379: IAE while invoking javadoc with --patch-module
ksrini
parents: 41451
diff changeset
    75
            Option.EXTDIRS.process(helper.getOptionHelper(), primaryName, arg);
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    76
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    77
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    78
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
    79
    SOURCE_PATH("--source-path -sourcepath", STANDARD, true) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    80
        @Override
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
    81
        public void process(Helper helper, String arg) throws InvalidValueException {
41990
ffaf4e59538a 8166379: IAE while invoking javadoc with --patch-module
ksrini
parents: 41451
diff changeset
    82
            Option.SOURCE_PATH.process(helper.getOptionHelper(), primaryName, arg);
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    83
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    84
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
    85
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
    86
    MODULE_SOURCE_PATH("--module-source-path", STANDARD, true) {
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37393
diff changeset
    87
        @Override
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
    88
        public void process(Helper helper, String arg) throws InvalidValueException {
41990
ffaf4e59538a 8166379: IAE while invoking javadoc with --patch-module
ksrini
parents: 41451
diff changeset
    89
            Option.MODULE_SOURCE_PATH.process(helper.getOptionHelper(), primaryName, arg);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
    90
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
    91
    },
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
    92
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
    93
    UPGRADE_MODULE_PATH("--upgrade-module-path", STANDARD, true) {
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37393
diff changeset
    94
        @Override
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
    95
        public void process(Helper helper, String arg) throws InvalidValueException {
41990
ffaf4e59538a 8166379: IAE while invoking javadoc with --patch-module
ksrini
parents: 41451
diff changeset
    96
            Option.UPGRADE_MODULE_PATH.process(helper.getOptionHelper(), primaryName, arg);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
    97
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
    98
    },
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
    99
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   100
    SYSTEM("--system", STANDARD, true) {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   101
        @Override
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
   102
        public void process(Helper helper, String arg) throws InvalidValueException {
41990
ffaf4e59538a 8166379: IAE while invoking javadoc with --patch-module
ksrini
parents: 41451
diff changeset
   103
            Option.SYSTEM.process(helper.getOptionHelper(), primaryName, arg);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   104
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   105
    },
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   106
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   107
    MODULE_PATH("--module-path -p", STANDARD, true) {
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37393
diff changeset
   108
        @Override
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
   109
        public void process(Helper helper, String arg) throws InvalidValueException {
41990
ffaf4e59538a 8166379: IAE while invoking javadoc with --patch-module
ksrini
parents: 41451
diff changeset
   110
            Option.MODULE_PATH.process(helper.getOptionHelper(), primaryName, arg);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   111
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   112
    },
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   113
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   114
    ADD_MODULES("--add-modules", STANDARD, true) {
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37393
diff changeset
   115
        @Override
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
   116
        public void process(Helper helper, String arg) throws InvalidValueException {
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   117
            Option.ADD_MODULES.process(helper.getOptionHelper(), primaryName, arg);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   118
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   119
    },
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   120
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   121
    LIMIT_MODULES("--limit-modules", STANDARD, true) {
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37393
diff changeset
   122
        @Override
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
   123
        public void process(Helper helper, String arg) throws InvalidValueException {
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   124
            Option.LIMIT_MODULES.process(helper.getOptionHelper(), primaryName, arg);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   125
        }
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   126
    },
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   127
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   128
    MODULE("--module", STANDARD, true) {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   129
        @Override
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   130
        public void process(Helper helper, String arg) {
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   131
            helper.addToList(this, ",", arg);
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   132
        }
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   133
    },
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   134
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   135
    ENCODING("-encoding", STANDARD, true) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   136
        @Override
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
   137
        public void process(Helper helper, String arg) throws InvalidValueException {
41990
ffaf4e59538a 8166379: IAE while invoking javadoc with --patch-module
ksrini
parents: 41451
diff changeset
   138
            Option.ENCODING.process(helper.getOptionHelper(), primaryName, arg);
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   139
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   140
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   141
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   142
    RELEASE("--release", STANDARD, true) {
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37393
diff changeset
   143
        @Override
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
   144
        public void process(Helper helper, String arg) throws InvalidValueException {
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   145
            Option.RELEASE.process(helper.getOptionHelper(), primaryName, arg);
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37393
diff changeset
   146
        }
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37393
diff changeset
   147
    },
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37393
diff changeset
   148
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   149
    SOURCE("-source", STANDARD, true) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   150
        @Override
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
   151
        public void process(Helper helper, String arg) throws InvalidValueException {
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   152
            Option.SOURCE.process(helper.getOptionHelper(), primaryName, arg);
47867
2053c5489a9e 8187588: Error generating using JDK 9 javadoc against a JDK 8 source repository
ksrini
parents: 47216
diff changeset
   153
            Option.TARGET.process(helper.getOptionHelper(), Option.TARGET.primaryName, arg);
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   154
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   155
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   156
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   157
    XMAXERRS("-Xmaxerrs", EXTENDED, true) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   158
        @Override
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
   159
        public void process(Helper helper, String arg) throws InvalidValueException {
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   160
            Option.XMAXERRS.process(helper.getOptionHelper(), primaryName, arg);
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   161
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   162
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   163
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   164
    XMAXWARNS("-Xmaxwarns", EXTENDED, true) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   165
        @Override
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
   166
        public void process(Helper helper, String arg) throws InvalidValueException {
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   167
            Option.XMAXWARNS.process(helper.getOptionHelper(), primaryName, arg);
37393
a9ba8bd6697b 8152818: Javadoc must support module options supported by javac.
ksrini
parents: 36526
diff changeset
   168
        }
a9ba8bd6697b 8152818: Javadoc must support module options supported by javac.
ksrini
parents: 36526
diff changeset
   169
    },
a9ba8bd6697b 8152818: Javadoc must support module options supported by javac.
ksrini
parents: 36526
diff changeset
   170
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   171
    ADD_READS("--add-reads", EXTENDED, true) {
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37393
diff changeset
   172
        @Override
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
   173
        public void process(Helper helper, String arg) throws InvalidValueException {
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   174
            Option.ADD_READS.process(helper.getOptionHelper(), primaryName, arg);
37393
a9ba8bd6697b 8152818: Javadoc must support module options supported by javac.
ksrini
parents: 36526
diff changeset
   175
        }
a9ba8bd6697b 8152818: Javadoc must support module options supported by javac.
ksrini
parents: 36526
diff changeset
   176
    },
a9ba8bd6697b 8152818: Javadoc must support module options supported by javac.
ksrini
parents: 36526
diff changeset
   177
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   178
    ADD_EXPORTS("--add-exports", EXTENDED, true) {
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37393
diff changeset
   179
        @Override
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
   180
        public void process(Helper helper, String arg) throws InvalidValueException {
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   181
            Option.ADD_EXPORTS.process(helper.getOptionHelper(), primaryName, arg);
37393
a9ba8bd6697b 8152818: Javadoc must support module options supported by javac.
ksrini
parents: 36526
diff changeset
   182
        }
a9ba8bd6697b 8152818: Javadoc must support module options supported by javac.
ksrini
parents: 36526
diff changeset
   183
    },
a9ba8bd6697b 8152818: Javadoc must support module options supported by javac.
ksrini
parents: 36526
diff changeset
   184
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   185
    PATCH_MODULE("--patch-module", EXTENDED, true) {
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37393
diff changeset
   186
        @Override
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
   187
        public void process(Helper helper, String arg) throws InvalidValueException {
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   188
            Option.PATCH_MODULE.process(helper.getOptionHelper(), primaryName, arg);
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37393
diff changeset
   189
        }
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37393
diff changeset
   190
    },
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37393
diff changeset
   191
48515
0da9fb7d7d04 8181878: javadoc should support/ignore --add-opens
jjg
parents: 47867
diff changeset
   192
    ADD_OPENS("--add-opens", HIDDEN, true) {
0da9fb7d7d04 8181878: javadoc should support/ignore --add-opens
jjg
parents: 47867
diff changeset
   193
        @Override
0da9fb7d7d04 8181878: javadoc should support/ignore --add-opens
jjg
parents: 47867
diff changeset
   194
        public void process(Helper helper, String arg) throws InvalidValueException {
0da9fb7d7d04 8181878: javadoc should support/ignore --add-opens
jjg
parents: 47867
diff changeset
   195
            Option.ADD_OPENS.process(helper.getOptionHelper(), primaryName, arg);
0da9fb7d7d04 8181878: javadoc should support/ignore --add-opens
jjg
parents: 47867
diff changeset
   196
        }
0da9fb7d7d04 8181878: javadoc should support/ignore --add-opens
jjg
parents: 47867
diff changeset
   197
    },
0da9fb7d7d04 8181878: javadoc should support/ignore --add-opens
jjg
parents: 47867
diff changeset
   198
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   199
    // ----- doclet options -----
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   200
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   201
    DOCLET("-doclet", STANDARD, true), // handled in setDocletInvoker
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   202
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   203
    DOCLETPATH("-docletpath", STANDARD, true), // handled in setDocletInvoker
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   204
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   205
    // ----- selection options -----
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   206
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   207
    SUBPACKAGES("-subpackages", STANDARD, true) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   208
        @Override
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   209
        public void process(Helper helper, String arg) {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   210
            helper.addToList(this, ":", arg);
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   211
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   212
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   213
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   214
    EXCLUDE("-exclude", STANDARD, true) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   215
        @Override
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   216
        public void process(Helper helper, String arg) {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   217
            helper.addToList(this, ":", arg);
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   218
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   219
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   220
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   221
    // ----- filtering options -----
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   222
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   223
    PACKAGE("-package", STANDARD) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   224
        @Override
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   225
        public void process(Helper helper) throws OptionException {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   226
            helper.setSimpleFilter("package");
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   227
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   228
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   229
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   230
    PRIVATE("-private", STANDARD) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   231
        @Override
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   232
        public void process(Helper helper) throws OptionException {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   233
            helper.setSimpleFilter("private");
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   234
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   235
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   236
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   237
    PROTECTED("-protected", STANDARD) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   238
        @Override
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   239
        public void process(Helper helper) throws OptionException {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   240
            helper.setSimpleFilter("protected");
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   241
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   242
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   243
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   244
    PUBLIC("-public", STANDARD) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   245
        @Override
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   246
        public void process(Helper helper) throws OptionException {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   247
            helper.setSimpleFilter("public");
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   248
        }
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   249
    },
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   250
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   251
    SHOW_MEMBERS("--show-members", STANDARD, true) {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   252
        @Override
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   253
        public void process(Helper helper, String arg) throws OptionException {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   254
            helper.setFilter(this, arg);
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   255
        }
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   256
    },
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   257
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   258
    SHOW_TYPES("--show-types", STANDARD, true) {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   259
        @Override
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   260
        public void process(Helper helper, String arg) throws OptionException {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   261
            helper.setFilter(this, arg);
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   262
        }
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   263
    },
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   264
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   265
    SHOW_PACKAGES("--show-packages", STANDARD, true) {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   266
        @Override
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   267
        public void process(Helper helper, String arg) throws OptionException {
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   268
            helper.setShowPackageAccess(SHOW_PACKAGES, arg);
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   269
        }
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   270
    },
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   271
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   272
    SHOW_MODULE_CONTENTS("--show-module-contents", STANDARD, true) {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   273
        @Override
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   274
        public void process(Helper helper, String arg) throws OptionException {
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   275
            helper.setShowModuleContents(SHOW_MODULE_CONTENTS, arg);
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   276
        }
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   277
    },
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   278
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   279
    EXPAND_REQUIRES("--expand-requires", STANDARD, true) {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   280
        @Override
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   281
        public void process(Helper helper, String arg) throws OptionException {
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   282
            helper.setExpandRequires(EXPAND_REQUIRES, arg);
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   283
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   284
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   285
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   286
    // ----- output control options -----
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   287
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   288
    QUIET("-quiet", STANDARD) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   289
        @Override
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   290
        public void process(Helper helper) {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   291
            helper.jdtoolOpts.put(QUIET, true);
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   292
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   293
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   294
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   295
    VERBOSE("-verbose", STANDARD) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   296
        @Override
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   297
        public void process(Helper helper) {
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   298
            helper.compOpts.put("-verbose", "");
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   299
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   300
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   301
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   302
    XWERROR("-Xwerror", HIDDEN) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   303
        @Override
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   304
        public void process(Helper helper) {
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   305
            helper.rejectWarnings = true;
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   306
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   307
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   308
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   309
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   310
    // ----- other options -----
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   311
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   312
    BREAKITERATOR("-breakiterator", STANDARD) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   313
        @Override
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   314
        public void process(Helper helper) {
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   315
            helper.breakiterator = true;
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   316
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   317
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   318
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   319
    LOCALE("-locale", STANDARD, true) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   320
        @Override
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   321
        public void process(Helper helper, String arg) {
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   322
            helper.docLocale = arg;
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   323
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   324
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   325
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   326
    XCLASSES("-Xclasses", HIDDEN) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   327
        @Override
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   328
        public void process(Helper helper) {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   329
            helper.jdtoolOpts.put(XCLASSES, true);
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   330
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   331
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   332
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   333
    DUMPONERROR("--dump-on-error", HIDDEN) {
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   334
        @Override
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   335
        public void process(Helper helper) {
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   336
            helper.dumpOnError = true;
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   337
        }
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   338
    },
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   339
44287
829205b133d4 8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents: 43878
diff changeset
   340
    IGNORE_SOURCE_ERRORS("--ignore-source-errors", HIDDEN) {
829205b133d4 8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents: 43878
diff changeset
   341
        @Override
829205b133d4 8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents: 43878
diff changeset
   342
        public void process(Helper helper) {
829205b133d4 8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents: 43878
diff changeset
   343
            helper.jdtoolOpts.put(IGNORE_SOURCE_ERRORS, true);
829205b133d4 8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents: 43878
diff changeset
   344
        }
829205b133d4 8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents: 43878
diff changeset
   345
    },
829205b133d4 8175219: javadoc should exit when it encounters compilation errors.
ksrini
parents: 43878
diff changeset
   346
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   347
    // ----- help options -----
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   348
48543
7067fe4e054e 8189102: All tools should support -?, -h and --help
goetz
parents: 48515
diff changeset
   349
    HELP("--help -help -? -h", STANDARD) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   350
        @Override
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   351
        public void process(Helper helper) throws OptionException {
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   352
            throw new OptionException(OK, helper::usage);
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   353
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   354
    },
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   355
43875
d0e60aa1f18b 8175047: javadoc should support --help-extra as a synonym for -X
jjg
parents: 43772
diff changeset
   356
    HELP_EXTRA("--help-extra -X", STANDARD) {
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   357
        @Override
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   358
        public void process(Helper helper) throws OptionException {
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   359
           throw new OptionException(OK, helper::Xusage);
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   360
        }
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   361
    },
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   362
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   363
    // This option exists only for the purpose of documenting itself.
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   364
    // It's actually implemented by the launcher.
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   365
    J("-J", STANDARD, true) {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   366
        @Override
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   367
        public void process(Helper helper) {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   368
            throw new AssertionError("the -J flag should be caught by the launcher.");
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   369
        }
45912
865870b7fe9b 8177048: javadoc should support -version and/or --version
pmuthuswamy
parents: 45742
diff changeset
   370
    },
865870b7fe9b 8177048: javadoc should support -version and/or --version
pmuthuswamy
parents: 45742
diff changeset
   371
865870b7fe9b 8177048: javadoc should support -version and/or --version
pmuthuswamy
parents: 45742
diff changeset
   372
    VERSION("--version", STANDARD) {
865870b7fe9b 8177048: javadoc should support -version and/or --version
pmuthuswamy
parents: 45742
diff changeset
   373
        @Override
865870b7fe9b 8177048: javadoc should support -version and/or --version
pmuthuswamy
parents: 45742
diff changeset
   374
        public void process(Helper helper) throws OptionException {
865870b7fe9b 8177048: javadoc should support -version and/or --version
pmuthuswamy
parents: 45742
diff changeset
   375
            throw new OptionException(OK, helper::version);
865870b7fe9b 8177048: javadoc should support -version and/or --version
pmuthuswamy
parents: 45742
diff changeset
   376
        }
865870b7fe9b 8177048: javadoc should support -version and/or --version
pmuthuswamy
parents: 45742
diff changeset
   377
    },
865870b7fe9b 8177048: javadoc should support -version and/or --version
pmuthuswamy
parents: 45742
diff changeset
   378
865870b7fe9b 8177048: javadoc should support -version and/or --version
pmuthuswamy
parents: 45742
diff changeset
   379
    FULLVERSION("--full-version", HIDDEN) {
865870b7fe9b 8177048: javadoc should support -version and/or --version
pmuthuswamy
parents: 45742
diff changeset
   380
        @Override
865870b7fe9b 8177048: javadoc should support -version and/or --version
pmuthuswamy
parents: 45742
diff changeset
   381
        public void process(Helper helper) throws OptionException {
865870b7fe9b 8177048: javadoc should support -version and/or --version
pmuthuswamy
parents: 45742
diff changeset
   382
            throw new OptionException(OK, helper::fullVersion);
865870b7fe9b 8177048: javadoc should support -version and/or --version
pmuthuswamy
parents: 45742
diff changeset
   383
        }
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   384
    };
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   385
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   386
    public final String primaryName;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   387
    public final List<String> names;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   388
    public final OptionKind kind;
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   389
    public final boolean hasArg;
37393
a9ba8bd6697b 8152818: Javadoc must support module options supported by javac.
ksrini
parents: 36526
diff changeset
   390
    public final boolean hasSuffix; // ex: foo:bar or -foo=bar
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   391
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   392
    ToolOption(String opt, OptionKind kind) {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   393
        this(opt, kind, false);
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   394
    }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   395
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   396
    ToolOption(String names, OptionKind kind, boolean hasArg) {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   397
        this.names = Arrays.asList(names.split("\\s+"));
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   398
        this.primaryName = this.names.get(0);
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   399
        this.kind = kind;
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   400
        this.hasArg = hasArg;
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   401
        char lastChar = names.charAt(names.length() - 1);
37393
a9ba8bd6697b 8152818: Javadoc must support module options supported by javac.
ksrini
parents: 36526
diff changeset
   402
        this.hasSuffix = lastChar == ':' || lastChar == '=';
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   403
    }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   404
42260
2b4da2bf6660 8169676: boolean result of Option.process is often ignored
jjg
parents: 41990
diff changeset
   405
    void process(Helper helper, String arg) throws OptionException, Option.InvalidValueException { }
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   406
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   407
    void process(Helper helper) throws OptionException { }
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   408
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   409
    List<String> getNames() {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   410
        return names;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   411
    }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   412
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   413
    String getParameters(Messager messager) {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   414
        return (hasArg || primaryName.endsWith(":"))
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   415
                ? messager.getText(getKey(primaryName, ".arg"))
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   416
                : null;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   417
    }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   418
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   419
    String getDescription(Messager messager) {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   420
        return messager.getText(getKey(primaryName, ".desc"));
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   421
    }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   422
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   423
    private String getKey(String optionName, String suffix) {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   424
        return "main.opt."
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   425
                + optionName
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   426
                .replaceAll("^-*", "")              // remove leading '-'
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   427
                .replaceAll("[^A-Za-z0-9]+$", "")   // remove trailing non-alphanumeric
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   428
                .replaceAll("[^A-Za-z0-9]", ".")    // replace internal non-alphanumeric
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   429
                + suffix;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   430
    }
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   431
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   432
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   433
    static ToolOption get(String name) {
37393
a9ba8bd6697b 8152818: Javadoc must support module options supported by javac.
ksrini
parents: 36526
diff changeset
   434
        String oname = name;
43878
4b0a3bda61d3 8175048: javadoc does not decode options containing '=' and ':' correctly
jjg
parents: 43875
diff changeset
   435
        if (name.startsWith("--") && name.contains("=")) {
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   436
            oname = name.substring(0, name.indexOf('='));
37393
a9ba8bd6697b 8152818: Javadoc must support module options supported by javac.
ksrini
parents: 36526
diff changeset
   437
        }
a9ba8bd6697b 8152818: Javadoc must support module options supported by javac.
ksrini
parents: 36526
diff changeset
   438
        for (ToolOption o : values()) {
41252
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   439
            for (String n : o.names) {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   440
                if (oname.equals(n)) {
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   441
                    return o;
058d83c9b1c7 8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents: 40762
diff changeset
   442
                }
37393
a9ba8bd6697b 8152818: Javadoc must support module options supported by javac.
ksrini
parents: 36526
diff changeset
   443
            }
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   444
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   445
        return null;
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   446
    }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   447
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   448
    static abstract class Helper {
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   449
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents: 22163
diff changeset
   450
        // File manager options
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents: 22163
diff changeset
   451
        final Map<Option, String> fileManagerOpts = new LinkedHashMap<>();
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents: 22163
diff changeset
   452
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   453
        /** javac options, set by various options. */
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   454
        Options compOpts; // = Options.instance(context)
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   455
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   456
        /** Javadoc tool options */
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   457
        final Map<ToolOption, Object> jdtoolOpts = new EnumMap<>(ToolOption.class);
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   458
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   459
        /** dump stack traces for debugging etc.*/
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   460
        boolean dumpOnError = false;
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   461
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   462
        /** Set by -breakiterator. */
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   463
        boolean breakiterator = false;
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   464
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   465
        /** Set by -Xwerror. */
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   466
        boolean rejectWarnings = false;
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   467
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   468
        /** Set by -prompt. */
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   469
        boolean promptOnError;
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   470
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   471
        /** Set by -locale. */
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   472
        String docLocale = "";
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   473
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   474
        Helper() {
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   475
            populateDefaultAccessMap();
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   476
        }
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   477
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   478
        abstract void usage();
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   479
        abstract void Xusage();
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   480
45912
865870b7fe9b 8177048: javadoc should support -version and/or --version
pmuthuswamy
parents: 45742
diff changeset
   481
        abstract void version();
865870b7fe9b 8177048: javadoc should support -version and/or --version
pmuthuswamy
parents: 45742
diff changeset
   482
        abstract void fullVersion();
865870b7fe9b 8177048: javadoc should support -version and/or --version
pmuthuswamy
parents: 45742
diff changeset
   483
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   484
        abstract String getLocalizedMessage(String msg, Object... args);
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   485
37393
a9ba8bd6697b 8152818: Javadoc must support module options supported by javac.
ksrini
parents: 36526
diff changeset
   486
        abstract OptionHelper getOptionHelper();
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   487
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   488
        @SuppressWarnings("unchecked")
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   489
        void addToList(ToolOption opt, String delimiter, String str) {
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   490
            List<String> list = (List<String>) jdtoolOpts.computeIfAbsent(opt, v -> new ArrayList<>());
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   491
            list.addAll(Arrays.asList(str.split(delimiter)));
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   492
            jdtoolOpts.put(opt, list);
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   493
        }
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   494
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   495
        void setExpandRequires(ToolOption opt, String arg) throws OptionException {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   496
            switch (arg) {
42407
f3702cff2933 8169069: Module system implementation refresh (11/2016)
alanb
parents: 41990
diff changeset
   497
                case "transitive":
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   498
                    jdtoolOpts.put(opt, AccessKind.PUBLIC);
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   499
                    break;
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   500
                case "all":
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   501
                    jdtoolOpts.put(opt, AccessKind.PRIVATE);
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   502
                    break;
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   503
                default:
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   504
                    String text = getLocalizedMessage("main.illegal_option_value", arg);
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   505
                    throw new IllegalOptionValue(this::usage, text);
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   506
            }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   507
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   508
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   509
        void setShowModuleContents(ToolOption opt, String arg) throws OptionException {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   510
            switch (arg) {
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   511
                case "api":
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   512
                    jdtoolOpts.put(opt, AccessKind.PUBLIC);
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   513
                    break;
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   514
                case "all":
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   515
                    jdtoolOpts.put(opt, AccessKind.PRIVATE);
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   516
                    break;
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   517
                default:
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   518
                    String text = getLocalizedMessage("main.illegal_option_value", arg);
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   519
                    throw new IllegalOptionValue(this::usage, text);
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   520
            }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   521
        }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   522
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   523
        void setShowPackageAccess(ToolOption opt, String arg) throws OptionException {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   524
            switch (arg) {
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   525
                case "exported":
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   526
                    jdtoolOpts.put(opt, AccessKind.PUBLIC);
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   527
                    break;
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   528
                case "all":
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   529
                    jdtoolOpts.put(opt, AccessKind.PRIVATE);
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   530
                    break;
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   531
                default:
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   532
                    String text = getLocalizedMessage("main.illegal_option_value", arg);
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   533
                    throw new IllegalOptionValue(this::usage, text);
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   534
            }
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   535
        }
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   536
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   537
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   538
        void setFilter(ToolOption opt, String arg) throws OptionException {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   539
            jdtoolOpts.put(opt, getAccessValue(arg));
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   540
        }
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   541
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   542
        void setSimpleFilter(String arg) throws OptionException {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   543
            handleSimpleOption(arg);
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   544
        }
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   545
24897
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents: 22163
diff changeset
   546
        void setFileManagerOpt(Option opt, String arg) {
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents: 22163
diff changeset
   547
            fileManagerOpts.put(opt, arg);
655b72d7b96e 7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents: 22163
diff changeset
   548
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 31936
diff changeset
   549
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   550
        void handleSimpleOption(String arg) throws OptionException {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   551
            populateSimpleAccessMap(getAccessValue(arg));
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   552
        }
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   553
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   554
        /*
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   555
         * This method handles both the simple options -package,
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   556
         * -private, so on, in addition to the new ones such as
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   557
         * --show-types:public and so on.
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   558
         */
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   559
        private AccessKind getAccessValue(String arg) throws OptionException {
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   560
            int colon = arg.indexOf(':');
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   561
            String value = (colon > 0)
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   562
                    ? arg.substring(colon + 1)
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   563
                    : arg;
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   564
            switch (value) {
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   565
                case "public":
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   566
                    return AccessKind.PUBLIC;
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   567
                case "protected":
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   568
                    return AccessKind.PROTECTED;
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   569
                case "package":
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   570
                    return AccessKind.PACKAGE;
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   571
                case "private":
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   572
                    return AccessKind.PRIVATE;
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   573
                default:
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   574
                    String text = getLocalizedMessage("main.illegal_option_value", value);
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents: 41252
diff changeset
   575
                    throw new IllegalOptionValue(this::usage, text);
40508
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   576
            }
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   577
        }
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   578
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   579
        /*
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   580
         * Sets the entire kind map to PROTECTED this is the default.
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   581
         */
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   582
        private void populateDefaultAccessMap() {
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   583
            populateSimpleAccessMap(AccessKind.PROTECTED);
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   584
        }
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   585
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   586
        /*
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   587
         * This sets access to all the allowed kinds in the
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   588
         * access map.
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   589
         */
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   590
        void populateSimpleAccessMap(AccessKind accessValue) {
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   591
            for (ElementKind kind : ElementsTable.ModifierFilter.ALLOWED_KINDS) {
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   592
                switch (kind) {
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   593
                    case METHOD:
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   594
                        jdtoolOpts.put(SHOW_MEMBERS, accessValue);
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   595
                        break;
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   596
                    case CLASS:
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   597
                        jdtoolOpts.put(SHOW_TYPES, accessValue);
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   598
                        break;
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   599
                    case PACKAGE:
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   600
                        jdtoolOpts.put(SHOW_PACKAGES, accessValue);
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   601
                        break;
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   602
                    case MODULE:
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   603
                        jdtoolOpts.put(SHOW_MODULE_CONTENTS, accessValue);
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   604
                        break;
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   605
                    default:
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   606
                        throw new AssertionError("unknown element kind:" + kind);
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   607
                }
74ef30d16fb9 8159305: Enhance the javadoc tool to support module related options
ksrini
parents: 40308
diff changeset
   608
            }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 31936
diff changeset
   609
        }
14543
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   610
    }
43edeaf6d0a9 8003257: refactor javadoc tool option handling
jjg
parents:
diff changeset
   611
}