Wed, 27 Apr 2016 01:34:52 +0800
Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/langtools/
changeset: 2573:53ca196be1ae
tag: jdk8u25-b17
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. Oracle designates this |
aoqi@0 | 8 | * particular file as subject to the "Classpath" exception as provided |
aoqi@0 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
aoqi@0 | 10 | * |
aoqi@0 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 15 | * accompanied this code). |
aoqi@0 | 16 | * |
aoqi@0 | 17 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 20 | * |
aoqi@0 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 22 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 23 | * questions. |
aoqi@0 | 24 | */ |
aoqi@0 | 25 | |
aoqi@0 | 26 | package com.sun.tools.doclets.formats.html; |
aoqi@0 | 27 | |
aoqi@0 | 28 | import java.net.*; |
aoqi@0 | 29 | import java.util.*; |
aoqi@0 | 30 | |
aoqi@0 | 31 | import javax.tools.JavaFileManager; |
aoqi@0 | 32 | |
aoqi@0 | 33 | import com.sun.javadoc.*; |
aoqi@0 | 34 | import com.sun.tools.doclets.formats.html.markup.ContentBuilder; |
aoqi@0 | 35 | import com.sun.tools.doclets.internal.toolkit.*; |
aoqi@0 | 36 | import com.sun.tools.doclets.internal.toolkit.util.*; |
aoqi@0 | 37 | import com.sun.tools.doclint.DocLint; |
aoqi@0 | 38 | import com.sun.tools.javac.file.JavacFileManager; |
aoqi@0 | 39 | import com.sun.tools.javac.util.Context; |
aoqi@0 | 40 | import com.sun.tools.javac.util.StringUtils; |
aoqi@0 | 41 | import com.sun.tools.javadoc.RootDocImpl; |
aoqi@0 | 42 | |
aoqi@0 | 43 | /** |
aoqi@0 | 44 | * Configure the output based on the command line options. |
aoqi@0 | 45 | * <p> |
aoqi@0 | 46 | * Also determine the length of the command line option. For example, |
aoqi@0 | 47 | * for a option "-header" there will be a string argument associated, then the |
aoqi@0 | 48 | * the length of option "-header" is two. But for option "-nohelp" no argument |
aoqi@0 | 49 | * is needed so it's length is 1. |
aoqi@0 | 50 | * </p> |
aoqi@0 | 51 | * <p> |
aoqi@0 | 52 | * Also do the error checking on the options used. For example it is illegal to |
aoqi@0 | 53 | * use "-helpfile" option when already "-nohelp" option is used. |
aoqi@0 | 54 | * </p> |
aoqi@0 | 55 | * |
aoqi@0 | 56 | * <p><b>This is NOT part of any supported API. |
aoqi@0 | 57 | * If you write code that depends on this, you do so at your own risk. |
aoqi@0 | 58 | * This code and its internal interfaces are subject to change or |
aoqi@0 | 59 | * deletion without notice.</b> |
aoqi@0 | 60 | * |
aoqi@0 | 61 | * @author Robert Field. |
aoqi@0 | 62 | * @author Atul Dambalkar. |
aoqi@0 | 63 | * @author Jamie Ho |
aoqi@0 | 64 | * @author Bhavesh Patel (Modified) |
aoqi@0 | 65 | */ |
aoqi@0 | 66 | public class ConfigurationImpl extends Configuration { |
aoqi@0 | 67 | |
aoqi@0 | 68 | /** |
aoqi@0 | 69 | * The build date. Note: For now, we will use |
aoqi@0 | 70 | * a version number instead of a date. |
aoqi@0 | 71 | */ |
aoqi@0 | 72 | public static final String BUILD_DATE = System.getProperty("java.version"); |
aoqi@0 | 73 | |
aoqi@0 | 74 | /** |
aoqi@0 | 75 | * Argument for command line option "-header". |
aoqi@0 | 76 | */ |
aoqi@0 | 77 | public String header = ""; |
aoqi@0 | 78 | |
aoqi@0 | 79 | /** |
aoqi@0 | 80 | * Argument for command line option "-packagesheader". |
aoqi@0 | 81 | */ |
aoqi@0 | 82 | public String packagesheader = ""; |
aoqi@0 | 83 | |
aoqi@0 | 84 | /** |
aoqi@0 | 85 | * Argument for command line option "-footer". |
aoqi@0 | 86 | */ |
aoqi@0 | 87 | public String footer = ""; |
aoqi@0 | 88 | |
aoqi@0 | 89 | /** |
aoqi@0 | 90 | * Argument for command line option "-doctitle". |
aoqi@0 | 91 | */ |
aoqi@0 | 92 | public String doctitle = ""; |
aoqi@0 | 93 | |
aoqi@0 | 94 | /** |
aoqi@0 | 95 | * Argument for command line option "-windowtitle". |
aoqi@0 | 96 | */ |
aoqi@0 | 97 | public String windowtitle = ""; |
aoqi@0 | 98 | |
aoqi@0 | 99 | /** |
aoqi@0 | 100 | * Argument for command line option "-top". |
aoqi@0 | 101 | */ |
aoqi@0 | 102 | public String top = ""; |
aoqi@0 | 103 | |
aoqi@0 | 104 | /** |
aoqi@0 | 105 | * Argument for command line option "-bottom". |
aoqi@0 | 106 | */ |
aoqi@0 | 107 | public String bottom = ""; |
aoqi@0 | 108 | |
aoqi@0 | 109 | /** |
aoqi@0 | 110 | * Argument for command line option "-helpfile". |
aoqi@0 | 111 | */ |
aoqi@0 | 112 | public String helpfile = ""; |
aoqi@0 | 113 | |
aoqi@0 | 114 | /** |
aoqi@0 | 115 | * Argument for command line option "-stylesheetfile". |
aoqi@0 | 116 | */ |
aoqi@0 | 117 | public String stylesheetfile = ""; |
aoqi@0 | 118 | |
aoqi@0 | 119 | /** |
aoqi@0 | 120 | * Argument for command line option "-Xdocrootparent". |
aoqi@0 | 121 | */ |
aoqi@0 | 122 | public String docrootparent = ""; |
aoqi@0 | 123 | |
aoqi@0 | 124 | /** |
aoqi@0 | 125 | * True if command line option "-nohelp" is used. Default value is false. |
aoqi@0 | 126 | */ |
aoqi@0 | 127 | public boolean nohelp = false; |
aoqi@0 | 128 | |
aoqi@0 | 129 | /** |
aoqi@0 | 130 | * True if command line option "-splitindex" is used. Default value is |
aoqi@0 | 131 | * false. |
aoqi@0 | 132 | */ |
aoqi@0 | 133 | public boolean splitindex = false; |
aoqi@0 | 134 | |
aoqi@0 | 135 | /** |
aoqi@0 | 136 | * False if command line option "-noindex" is used. Default value is true. |
aoqi@0 | 137 | */ |
aoqi@0 | 138 | public boolean createindex = true; |
aoqi@0 | 139 | |
aoqi@0 | 140 | /** |
aoqi@0 | 141 | * True if command line option "-use" is used. Default value is false. |
aoqi@0 | 142 | */ |
aoqi@0 | 143 | public boolean classuse = false; |
aoqi@0 | 144 | |
aoqi@0 | 145 | /** |
aoqi@0 | 146 | * False if command line option "-notree" is used. Default value is true. |
aoqi@0 | 147 | */ |
aoqi@0 | 148 | public boolean createtree = true; |
aoqi@0 | 149 | |
aoqi@0 | 150 | /** |
aoqi@0 | 151 | * True if command line option "-nodeprecated" is used. Default value is |
aoqi@0 | 152 | * false. |
aoqi@0 | 153 | */ |
aoqi@0 | 154 | public boolean nodeprecatedlist = false; |
aoqi@0 | 155 | |
aoqi@0 | 156 | /** |
aoqi@0 | 157 | * True if command line option "-nonavbar" is used. Default value is false. |
aoqi@0 | 158 | */ |
aoqi@0 | 159 | public boolean nonavbar = false; |
aoqi@0 | 160 | |
aoqi@0 | 161 | /** |
aoqi@0 | 162 | * True if command line option "-nooverview" is used. Default value is |
aoqi@0 | 163 | * false |
aoqi@0 | 164 | */ |
aoqi@0 | 165 | private boolean nooverview = false; |
aoqi@0 | 166 | |
aoqi@0 | 167 | /** |
aoqi@0 | 168 | * True if command line option "-overview" is used. Default value is false. |
aoqi@0 | 169 | */ |
aoqi@0 | 170 | public boolean overview = false; |
aoqi@0 | 171 | |
aoqi@0 | 172 | /** |
aoqi@0 | 173 | * This is true if option "-overview" is used or option "-overview" is not |
aoqi@0 | 174 | * used and number of packages is more than one. |
aoqi@0 | 175 | */ |
aoqi@0 | 176 | public boolean createoverview = false; |
aoqi@0 | 177 | |
aoqi@0 | 178 | /** |
aoqi@0 | 179 | * Collected set of doclint options |
aoqi@0 | 180 | */ |
aoqi@0 | 181 | public Set<String> doclintOpts = new LinkedHashSet<String>(); |
aoqi@0 | 182 | |
aoqi@0 | 183 | /** |
aoqi@0 | 184 | * Unique Resource Handler for this package. |
aoqi@0 | 185 | */ |
aoqi@0 | 186 | public final MessageRetriever standardmessage; |
aoqi@0 | 187 | |
aoqi@0 | 188 | /** |
aoqi@0 | 189 | * First file to appear in the right-hand frame in the generated |
aoqi@0 | 190 | * documentation. |
aoqi@0 | 191 | */ |
aoqi@0 | 192 | public DocPath topFile = DocPath.empty; |
aoqi@0 | 193 | |
aoqi@0 | 194 | /** |
aoqi@0 | 195 | * The classdoc for the class file getting generated. |
aoqi@0 | 196 | */ |
aoqi@0 | 197 | public ClassDoc currentcd = null; // Set this classdoc in the ClassWriter. |
aoqi@0 | 198 | |
aoqi@0 | 199 | /** |
aoqi@0 | 200 | * Constructor. Initializes resource for the |
aoqi@0 | 201 | * {@link com.sun.tools.doclets.internal.toolkit.util.MessageRetriever MessageRetriever}. |
aoqi@0 | 202 | */ |
aoqi@0 | 203 | public ConfigurationImpl() { |
aoqi@0 | 204 | standardmessage = new MessageRetriever(this, |
aoqi@0 | 205 | "com.sun.tools.doclets.formats.html.resources.standard"); |
aoqi@0 | 206 | } |
aoqi@0 | 207 | |
aoqi@0 | 208 | private final String versionRBName = "com.sun.tools.javadoc.resources.version"; |
aoqi@0 | 209 | private ResourceBundle versionRB; |
aoqi@0 | 210 | |
aoqi@0 | 211 | /** |
aoqi@0 | 212 | * Return the build date for the doclet. |
aoqi@0 | 213 | */ |
aoqi@0 | 214 | @Override |
aoqi@0 | 215 | public String getDocletSpecificBuildDate() { |
aoqi@0 | 216 | if (versionRB == null) { |
aoqi@0 | 217 | try { |
aoqi@0 | 218 | versionRB = ResourceBundle.getBundle(versionRBName); |
aoqi@0 | 219 | } catch (MissingResourceException e) { |
aoqi@0 | 220 | return BUILD_DATE; |
aoqi@0 | 221 | } |
aoqi@0 | 222 | } |
aoqi@0 | 223 | |
aoqi@0 | 224 | try { |
aoqi@0 | 225 | return versionRB.getString("release"); |
aoqi@0 | 226 | } catch (MissingResourceException e) { |
aoqi@0 | 227 | return BUILD_DATE; |
aoqi@0 | 228 | } |
aoqi@0 | 229 | } |
aoqi@0 | 230 | |
aoqi@0 | 231 | /** |
aoqi@0 | 232 | * Depending upon the command line options provided by the user, set |
aoqi@0 | 233 | * configure the output generation environment. |
aoqi@0 | 234 | * |
aoqi@0 | 235 | * @param options The array of option names and values. |
aoqi@0 | 236 | */ |
aoqi@0 | 237 | @Override |
aoqi@0 | 238 | public void setSpecificDocletOptions(String[][] options) { |
aoqi@0 | 239 | for (int oi = 0; oi < options.length; ++oi) { |
aoqi@0 | 240 | String[] os = options[oi]; |
aoqi@0 | 241 | String opt = StringUtils.toLowerCase(os[0]); |
aoqi@0 | 242 | if (opt.equals("-footer")) { |
aoqi@0 | 243 | footer = os[1]; |
aoqi@0 | 244 | } else if (opt.equals("-header")) { |
aoqi@0 | 245 | header = os[1]; |
aoqi@0 | 246 | } else if (opt.equals("-packagesheader")) { |
aoqi@0 | 247 | packagesheader = os[1]; |
aoqi@0 | 248 | } else if (opt.equals("-doctitle")) { |
aoqi@0 | 249 | doctitle = os[1]; |
aoqi@0 | 250 | } else if (opt.equals("-windowtitle")) { |
aoqi@0 | 251 | windowtitle = os[1].replaceAll("\\<.*?>", ""); |
aoqi@0 | 252 | } else if (opt.equals("-top")) { |
aoqi@0 | 253 | top = os[1]; |
aoqi@0 | 254 | } else if (opt.equals("-bottom")) { |
aoqi@0 | 255 | bottom = os[1]; |
aoqi@0 | 256 | } else if (opt.equals("-helpfile")) { |
aoqi@0 | 257 | helpfile = os[1]; |
aoqi@0 | 258 | } else if (opt.equals("-stylesheetfile")) { |
aoqi@0 | 259 | stylesheetfile = os[1]; |
aoqi@0 | 260 | } else if (opt.equals("-charset")) { |
aoqi@0 | 261 | charset = os[1]; |
aoqi@0 | 262 | } else if (opt.equals("-xdocrootparent")) { |
aoqi@0 | 263 | docrootparent = os[1]; |
aoqi@0 | 264 | } else if (opt.equals("-nohelp")) { |
aoqi@0 | 265 | nohelp = true; |
aoqi@0 | 266 | } else if (opt.equals("-splitindex")) { |
aoqi@0 | 267 | splitindex = true; |
aoqi@0 | 268 | } else if (opt.equals("-noindex")) { |
aoqi@0 | 269 | createindex = false; |
aoqi@0 | 270 | } else if (opt.equals("-use")) { |
aoqi@0 | 271 | classuse = true; |
aoqi@0 | 272 | } else if (opt.equals("-notree")) { |
aoqi@0 | 273 | createtree = false; |
aoqi@0 | 274 | } else if (opt.equals("-nodeprecatedlist")) { |
aoqi@0 | 275 | nodeprecatedlist = true; |
aoqi@0 | 276 | } else if (opt.equals("-nonavbar")) { |
aoqi@0 | 277 | nonavbar = true; |
aoqi@0 | 278 | } else if (opt.equals("-nooverview")) { |
aoqi@0 | 279 | nooverview = true; |
aoqi@0 | 280 | } else if (opt.equals("-overview")) { |
aoqi@0 | 281 | overview = true; |
aoqi@0 | 282 | } else if (opt.equals("-xdoclint")) { |
aoqi@0 | 283 | doclintOpts.add(null); |
aoqi@0 | 284 | } else if (opt.startsWith("-xdoclint:")) { |
aoqi@0 | 285 | doclintOpts.add(opt.substring(opt.indexOf(":") + 1)); |
aoqi@0 | 286 | } |
aoqi@0 | 287 | } |
aoqi@0 | 288 | if (root.specifiedClasses().length > 0) { |
aoqi@0 | 289 | Map<String,PackageDoc> map = new HashMap<String,PackageDoc>(); |
aoqi@0 | 290 | PackageDoc pd; |
aoqi@0 | 291 | ClassDoc[] classes = root.classes(); |
aoqi@0 | 292 | for (int i = 0; i < classes.length; i++) { |
aoqi@0 | 293 | pd = classes[i].containingPackage(); |
aoqi@0 | 294 | if(! map.containsKey(pd.name())) { |
aoqi@0 | 295 | map.put(pd.name(), pd); |
aoqi@0 | 296 | } |
aoqi@0 | 297 | } |
aoqi@0 | 298 | } |
aoqi@0 | 299 | setCreateOverview(); |
aoqi@0 | 300 | setTopFile(root); |
aoqi@0 | 301 | |
aoqi@0 | 302 | if (root instanceof RootDocImpl) { |
aoqi@0 | 303 | ((RootDocImpl) root).initDocLint(doclintOpts, tagletManager.getCustomTagNames()); |
aoqi@0 | 304 | } |
aoqi@0 | 305 | } |
aoqi@0 | 306 | |
aoqi@0 | 307 | /** |
aoqi@0 | 308 | * Returns the "length" of a given option. If an option takes no |
aoqi@0 | 309 | * arguments, its length is one. If it takes one argument, it's |
aoqi@0 | 310 | * length is two, and so on. This method is called by JavaDoc to |
aoqi@0 | 311 | * parse the options it does not recognize. It then calls |
aoqi@0 | 312 | * {@link #validOptions(String[][], DocErrorReporter)} to |
aoqi@0 | 313 | * validate them. |
aoqi@0 | 314 | * <b>Note:</b><br> |
aoqi@0 | 315 | * The options arrive as case-sensitive strings. For options that |
aoqi@0 | 316 | * are not case-sensitive, use toLowerCase() on the option string |
aoqi@0 | 317 | * before comparing it. |
aoqi@0 | 318 | * </blockquote> |
aoqi@0 | 319 | * |
aoqi@0 | 320 | * @return number of arguments + 1 for a option. Zero return means |
aoqi@0 | 321 | * option not known. Negative value means error occurred. |
aoqi@0 | 322 | */ |
aoqi@0 | 323 | public int optionLength(String option) { |
aoqi@0 | 324 | int result = -1; |
aoqi@0 | 325 | if ((result = super.optionLength(option)) > 0) { |
aoqi@0 | 326 | return result; |
aoqi@0 | 327 | } |
aoqi@0 | 328 | // otherwise look for the options we have added |
aoqi@0 | 329 | option = StringUtils.toLowerCase(option); |
aoqi@0 | 330 | if (option.equals("-nodeprecatedlist") || |
aoqi@0 | 331 | option.equals("-noindex") || |
aoqi@0 | 332 | option.equals("-notree") || |
aoqi@0 | 333 | option.equals("-nohelp") || |
aoqi@0 | 334 | option.equals("-splitindex") || |
aoqi@0 | 335 | option.equals("-serialwarn") || |
aoqi@0 | 336 | option.equals("-use") || |
aoqi@0 | 337 | option.equals("-nonavbar") || |
aoqi@0 | 338 | option.equals("-nooverview") || |
aoqi@0 | 339 | option.equals("-xdoclint") || |
aoqi@0 | 340 | option.startsWith("-xdoclint:")) { |
aoqi@0 | 341 | return 1; |
aoqi@0 | 342 | } else if (option.equals("-help")) { |
aoqi@0 | 343 | // Uugh: first, this should not be hidden inside optionLength, |
aoqi@0 | 344 | // and second, we should not be writing directly to stdout. |
aoqi@0 | 345 | // But we have no access to a DocErrorReporter, which would |
aoqi@0 | 346 | // allow use of reporter.printNotice |
aoqi@0 | 347 | System.out.println(getText("doclet.usage")); |
aoqi@0 | 348 | return 1; |
aoqi@0 | 349 | } else if (option.equals("-x")) { |
aoqi@0 | 350 | // Uugh: first, this should not be hidden inside optionLength, |
aoqi@0 | 351 | // and second, we should not be writing directly to stdout. |
aoqi@0 | 352 | // But we have no access to a DocErrorReporter, which would |
aoqi@0 | 353 | // allow use of reporter.printNotice |
aoqi@0 | 354 | System.out.println(getText("doclet.X.usage")); |
aoqi@0 | 355 | return 1; |
aoqi@0 | 356 | } else if (option.equals("-footer") || |
aoqi@0 | 357 | option.equals("-header") || |
aoqi@0 | 358 | option.equals("-packagesheader") || |
aoqi@0 | 359 | option.equals("-doctitle") || |
aoqi@0 | 360 | option.equals("-windowtitle") || |
aoqi@0 | 361 | option.equals("-top") || |
aoqi@0 | 362 | option.equals("-bottom") || |
aoqi@0 | 363 | option.equals("-helpfile") || |
aoqi@0 | 364 | option.equals("-stylesheetfile") || |
aoqi@0 | 365 | option.equals("-charset") || |
aoqi@0 | 366 | option.equals("-overview") || |
aoqi@0 | 367 | option.equals("-xdocrootparent")) { |
aoqi@0 | 368 | return 2; |
aoqi@0 | 369 | } else { |
aoqi@0 | 370 | return 0; |
aoqi@0 | 371 | } |
aoqi@0 | 372 | } |
aoqi@0 | 373 | |
aoqi@0 | 374 | /** |
aoqi@0 | 375 | * {@inheritDoc} |
aoqi@0 | 376 | */ |
aoqi@0 | 377 | @Override |
aoqi@0 | 378 | public boolean validOptions(String options[][], |
aoqi@0 | 379 | DocErrorReporter reporter) { |
aoqi@0 | 380 | boolean helpfile = false; |
aoqi@0 | 381 | boolean nohelp = false; |
aoqi@0 | 382 | boolean overview = false; |
aoqi@0 | 383 | boolean nooverview = false; |
aoqi@0 | 384 | boolean splitindex = false; |
aoqi@0 | 385 | boolean noindex = false; |
aoqi@0 | 386 | // check shared options |
aoqi@0 | 387 | if (!generalValidOptions(options, reporter)) { |
aoqi@0 | 388 | return false; |
aoqi@0 | 389 | } |
aoqi@0 | 390 | // otherwise look at our options |
aoqi@0 | 391 | for (int oi = 0; oi < options.length; ++oi) { |
aoqi@0 | 392 | String[] os = options[oi]; |
aoqi@0 | 393 | String opt = StringUtils.toLowerCase(os[0]); |
aoqi@0 | 394 | if (opt.equals("-helpfile")) { |
aoqi@0 | 395 | if (nohelp == true) { |
aoqi@0 | 396 | reporter.printError(getText("doclet.Option_conflict", |
aoqi@0 | 397 | "-helpfile", "-nohelp")); |
aoqi@0 | 398 | return false; |
aoqi@0 | 399 | } |
aoqi@0 | 400 | if (helpfile == true) { |
aoqi@0 | 401 | reporter.printError(getText("doclet.Option_reuse", |
aoqi@0 | 402 | "-helpfile")); |
aoqi@0 | 403 | return false; |
aoqi@0 | 404 | } |
aoqi@0 | 405 | DocFile help = DocFile.createFileForInput(this, os[1]); |
aoqi@0 | 406 | if (!help.exists()) { |
aoqi@0 | 407 | reporter.printError(getText("doclet.File_not_found", os[1])); |
aoqi@0 | 408 | return false; |
aoqi@0 | 409 | } |
aoqi@0 | 410 | helpfile = true; |
aoqi@0 | 411 | } else if (opt.equals("-nohelp")) { |
aoqi@0 | 412 | if (helpfile == true) { |
aoqi@0 | 413 | reporter.printError(getText("doclet.Option_conflict", |
aoqi@0 | 414 | "-nohelp", "-helpfile")); |
aoqi@0 | 415 | return false; |
aoqi@0 | 416 | } |
aoqi@0 | 417 | nohelp = true; |
aoqi@0 | 418 | } else if (opt.equals("-xdocrootparent")) { |
aoqi@0 | 419 | try { |
aoqi@0 | 420 | new URL(os[1]); |
aoqi@0 | 421 | } catch (MalformedURLException e) { |
aoqi@0 | 422 | reporter.printError(getText("doclet.MalformedURL", os[1])); |
aoqi@0 | 423 | return false; |
aoqi@0 | 424 | } |
aoqi@0 | 425 | } else if (opt.equals("-overview")) { |
aoqi@0 | 426 | if (nooverview == true) { |
aoqi@0 | 427 | reporter.printError(getText("doclet.Option_conflict", |
aoqi@0 | 428 | "-overview", "-nooverview")); |
aoqi@0 | 429 | return false; |
aoqi@0 | 430 | } |
aoqi@0 | 431 | if (overview == true) { |
aoqi@0 | 432 | reporter.printError(getText("doclet.Option_reuse", |
aoqi@0 | 433 | "-overview")); |
aoqi@0 | 434 | return false; |
aoqi@0 | 435 | } |
aoqi@0 | 436 | overview = true; |
aoqi@0 | 437 | } else if (opt.equals("-nooverview")) { |
aoqi@0 | 438 | if (overview == true) { |
aoqi@0 | 439 | reporter.printError(getText("doclet.Option_conflict", |
aoqi@0 | 440 | "-nooverview", "-overview")); |
aoqi@0 | 441 | return false; |
aoqi@0 | 442 | } |
aoqi@0 | 443 | nooverview = true; |
aoqi@0 | 444 | } else if (opt.equals("-splitindex")) { |
aoqi@0 | 445 | if (noindex == true) { |
aoqi@0 | 446 | reporter.printError(getText("doclet.Option_conflict", |
aoqi@0 | 447 | "-splitindex", "-noindex")); |
aoqi@0 | 448 | return false; |
aoqi@0 | 449 | } |
aoqi@0 | 450 | splitindex = true; |
aoqi@0 | 451 | } else if (opt.equals("-noindex")) { |
aoqi@0 | 452 | if (splitindex == true) { |
aoqi@0 | 453 | reporter.printError(getText("doclet.Option_conflict", |
aoqi@0 | 454 | "-noindex", "-splitindex")); |
aoqi@0 | 455 | return false; |
aoqi@0 | 456 | } |
aoqi@0 | 457 | noindex = true; |
aoqi@0 | 458 | } else if (opt.startsWith("-xdoclint:")) { |
aoqi@0 | 459 | if (opt.contains("/")) { |
aoqi@0 | 460 | reporter.printError(getText("doclet.Option_doclint_no_qualifiers")); |
aoqi@0 | 461 | return false; |
aoqi@0 | 462 | } |
aoqi@0 | 463 | if (!DocLint.isValidOption( |
aoqi@0 | 464 | opt.replace("-xdoclint:", DocLint.XMSGS_CUSTOM_PREFIX))) { |
aoqi@0 | 465 | reporter.printError(getText("doclet.Option_doclint_invalid_arg")); |
aoqi@0 | 466 | return false; |
aoqi@0 | 467 | } |
aoqi@0 | 468 | } |
aoqi@0 | 469 | } |
aoqi@0 | 470 | return true; |
aoqi@0 | 471 | } |
aoqi@0 | 472 | |
aoqi@0 | 473 | /** |
aoqi@0 | 474 | * {@inheritDoc} |
aoqi@0 | 475 | */ |
aoqi@0 | 476 | @Override |
aoqi@0 | 477 | public MessageRetriever getDocletSpecificMsg() { |
aoqi@0 | 478 | return standardmessage; |
aoqi@0 | 479 | } |
aoqi@0 | 480 | |
aoqi@0 | 481 | /** |
aoqi@0 | 482 | * Decide the page which will appear first in the right-hand frame. It will |
aoqi@0 | 483 | * be "overview-summary.html" if "-overview" option is used or no |
aoqi@0 | 484 | * "-overview" but the number of packages is more than one. It will be |
aoqi@0 | 485 | * "package-summary.html" of the respective package if there is only one |
aoqi@0 | 486 | * package to document. It will be a class page(first in the sorted order), |
aoqi@0 | 487 | * if only classes are provided on the command line. |
aoqi@0 | 488 | * |
aoqi@0 | 489 | * @param root Root of the program structure. |
aoqi@0 | 490 | */ |
aoqi@0 | 491 | protected void setTopFile(RootDoc root) { |
aoqi@0 | 492 | if (!checkForDeprecation(root)) { |
aoqi@0 | 493 | return; |
aoqi@0 | 494 | } |
aoqi@0 | 495 | if (createoverview) { |
aoqi@0 | 496 | topFile = DocPaths.OVERVIEW_SUMMARY; |
aoqi@0 | 497 | } else { |
aoqi@0 | 498 | if (packages.length == 1 && packages[0].name().equals("")) { |
aoqi@0 | 499 | if (root.classes().length > 0) { |
aoqi@0 | 500 | ClassDoc[] classarr = root.classes(); |
aoqi@0 | 501 | Arrays.sort(classarr); |
aoqi@0 | 502 | ClassDoc cd = getValidClass(classarr); |
aoqi@0 | 503 | topFile = DocPath.forClass(cd); |
aoqi@0 | 504 | } |
aoqi@0 | 505 | } else { |
aoqi@0 | 506 | topFile = DocPath.forPackage(packages[0]).resolve(DocPaths.PACKAGE_SUMMARY); |
aoqi@0 | 507 | } |
aoqi@0 | 508 | } |
aoqi@0 | 509 | } |
aoqi@0 | 510 | |
aoqi@0 | 511 | protected ClassDoc getValidClass(ClassDoc[] classarr) { |
aoqi@0 | 512 | if (!nodeprecated) { |
aoqi@0 | 513 | return classarr[0]; |
aoqi@0 | 514 | } |
aoqi@0 | 515 | for (int i = 0; i < classarr.length; i++) { |
aoqi@0 | 516 | if (classarr[i].tags("deprecated").length == 0) { |
aoqi@0 | 517 | return classarr[i]; |
aoqi@0 | 518 | } |
aoqi@0 | 519 | } |
aoqi@0 | 520 | return null; |
aoqi@0 | 521 | } |
aoqi@0 | 522 | |
aoqi@0 | 523 | protected boolean checkForDeprecation(RootDoc root) { |
aoqi@0 | 524 | ClassDoc[] classarr = root.classes(); |
aoqi@0 | 525 | for (int i = 0; i < classarr.length; i++) { |
aoqi@0 | 526 | if (isGeneratedDoc(classarr[i])) { |
aoqi@0 | 527 | return true; |
aoqi@0 | 528 | } |
aoqi@0 | 529 | } |
aoqi@0 | 530 | return false; |
aoqi@0 | 531 | } |
aoqi@0 | 532 | |
aoqi@0 | 533 | /** |
aoqi@0 | 534 | * Generate "overview.html" page if option "-overview" is used or number of |
aoqi@0 | 535 | * packages is more than one. Sets {@link #createoverview} field to true. |
aoqi@0 | 536 | */ |
aoqi@0 | 537 | protected void setCreateOverview() { |
aoqi@0 | 538 | if ((overview || packages.length > 1) && !nooverview) { |
aoqi@0 | 539 | createoverview = true; |
aoqi@0 | 540 | } |
aoqi@0 | 541 | } |
aoqi@0 | 542 | |
aoqi@0 | 543 | /** |
aoqi@0 | 544 | * {@inheritDoc} |
aoqi@0 | 545 | */ |
aoqi@0 | 546 | @Override |
aoqi@0 | 547 | public WriterFactory getWriterFactory() { |
aoqi@0 | 548 | return new WriterFactoryImpl(this); |
aoqi@0 | 549 | } |
aoqi@0 | 550 | |
aoqi@0 | 551 | /** |
aoqi@0 | 552 | * {@inheritDoc} |
aoqi@0 | 553 | */ |
aoqi@0 | 554 | @Override |
aoqi@0 | 555 | public Comparator<ProgramElementDoc> getMemberComparator() { |
aoqi@0 | 556 | return null; |
aoqi@0 | 557 | } |
aoqi@0 | 558 | |
aoqi@0 | 559 | /** |
aoqi@0 | 560 | * {@inheritDoc} |
aoqi@0 | 561 | */ |
aoqi@0 | 562 | @Override |
aoqi@0 | 563 | public Locale getLocale() { |
aoqi@0 | 564 | if (root instanceof RootDocImpl) |
aoqi@0 | 565 | return ((RootDocImpl)root).getLocale(); |
aoqi@0 | 566 | else |
aoqi@0 | 567 | return Locale.getDefault(); |
aoqi@0 | 568 | } |
aoqi@0 | 569 | |
aoqi@0 | 570 | /** |
aoqi@0 | 571 | * {@inheritDoc} |
aoqi@0 | 572 | */ |
aoqi@0 | 573 | @Override |
aoqi@0 | 574 | public JavaFileManager getFileManager() { |
aoqi@0 | 575 | if (fileManager == null) { |
aoqi@0 | 576 | if (root instanceof RootDocImpl) |
aoqi@0 | 577 | fileManager = ((RootDocImpl) root).getFileManager(); |
aoqi@0 | 578 | else |
aoqi@0 | 579 | fileManager = new JavacFileManager(new Context(), false, null); |
aoqi@0 | 580 | } |
aoqi@0 | 581 | return fileManager; |
aoqi@0 | 582 | } |
aoqi@0 | 583 | |
aoqi@0 | 584 | private JavaFileManager fileManager; |
aoqi@0 | 585 | |
aoqi@0 | 586 | @Override |
aoqi@0 | 587 | public boolean showMessage(SourcePosition pos, String key) { |
aoqi@0 | 588 | if (root instanceof RootDocImpl) { |
aoqi@0 | 589 | return pos == null || ((RootDocImpl) root).showTagMessages(); |
aoqi@0 | 590 | } |
aoqi@0 | 591 | return true; |
aoqi@0 | 592 | } |
aoqi@0 | 593 | |
aoqi@0 | 594 | @Override |
aoqi@0 | 595 | public Content newContent() { |
aoqi@0 | 596 | return new ContentBuilder(); |
aoqi@0 | 597 | } |
aoqi@0 | 598 | } |