< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/doclint/DocLint.java

Print this page




  63 /**
  64  * Multi-function entry point for the doc check utility.
  65  *
  66  * This class can be invoked in the following ways:
  67  * <ul>
  68  * <li>From the command line
  69  * <li>From javac, as a plugin
  70  * <li>Directly, via a simple API
  71  * </ul>
  72  *
  73  * <p><b>This is NOT part of any supported API.
  74  * If you write code that depends on this, you do so at your own
  75  * risk.  This code and its internal interfaces are subject to change
  76  * or deletion without notice.</b></p>
  77  */
  78 public class DocLint implements Plugin {
  79 
  80     public static final String XMSGS_OPTION = "-Xmsgs";
  81     public static final String XMSGS_CUSTOM_PREFIX = "-Xmsgs:";
  82     private static final String STATS = "-stats";
  83     public static final String XIMPLICIT_HEADERS = "-XimplicitHeaders:";
  84     public static final String XCUSTOM_TAGS_PREFIX = "-XcustomTags:";
  85     public static final String XHTML_VERSION_PREFIX = "-XhtmlVersion:";
  86     public static final String XCHECK_PACKAGE = "-XcheckPackage:";
  87     public static final String SEPARATOR = ",";
  88 
  89     // <editor-fold defaultstate="collapsed" desc="Command-line entry point">
  90     public static void main(String... args) {
  91         DocLint dl = new DocLint();
  92         try {
  93             dl.run(args);
  94         } catch (BadArgs e) {
  95             System.err.println(e.getMessage());
  96             System.exit(1);
  97         } catch (IOException e) {
  98             System.err.println(dl.localize("dc.main.ioerror", e.getLocalizedMessage()));
  99             System.exit(2);
 100         }
 101     }
 102 
 103     // </editor-fold>


 272     public String getName() {
 273         return "doclint";
 274     }
 275 
 276     @Override @DefinedBy(Api.COMPILER_TREE)
 277     public void init(JavacTask task, String... args) {
 278         init(task, args, true);
 279     }
 280 
 281     // </editor-fold>
 282 
 283     // <editor-fold defaultstate="collapsed" desc="Embedding API">
 284 
 285     public void init(JavacTask task, String[] args, boolean addTaskListener) {
 286         env = new Env();
 287         for (String arg : args) {
 288             if (arg.equals(XMSGS_OPTION)) {
 289                 env.messages.setOptions(null);
 290             } else if (arg.startsWith(XMSGS_CUSTOM_PREFIX)) {
 291                 env.messages.setOptions(arg.substring(arg.indexOf(":") + 1));
 292             } else if (arg.matches(XIMPLICIT_HEADERS + "[1-6]")) {
 293                 char ch = arg.charAt(arg.length() - 1);
 294                 env.setImplicitHeaders(Character.digit(ch, 10));
 295             } else if (arg.startsWith(XCUSTOM_TAGS_PREFIX)) {
 296                 env.setCustomTags(arg.substring(arg.indexOf(":") + 1));
 297             } else if (arg.startsWith(XHTML_VERSION_PREFIX)) {
 298                 String argsVersion = arg.substring(arg.indexOf(":") + 1);
 299                 HtmlVersion htmlVersion = HtmlVersion.getHtmlVersion(argsVersion);
 300                 if (htmlVersion != null) {
 301                     env.setHtmlVersion(htmlVersion);
 302                 } else {
 303                     throw new IllegalArgumentException(argsVersion);
 304                 }
 305             } else if (arg.startsWith(XCHECK_PACKAGE)) {
 306                 env.setCheckPackages(arg.substring(arg.indexOf(":") + 1));
 307             } else
 308                 throw new IllegalArgumentException(arg);
 309         }
 310         env.init(task);
 311 
 312         checker = new Checker(env);
 313 
 314         if (addTaskListener) {




  63 /**
  64  * Multi-function entry point for the doc check utility.
  65  *
  66  * This class can be invoked in the following ways:
  67  * <ul>
  68  * <li>From the command line
  69  * <li>From javac, as a plugin
  70  * <li>Directly, via a simple API
  71  * </ul>
  72  *
  73  * <p><b>This is NOT part of any supported API.
  74  * If you write code that depends on this, you do so at your own
  75  * risk.  This code and its internal interfaces are subject to change
  76  * or deletion without notice.</b></p>
  77  */
  78 public class DocLint implements Plugin {
  79 
  80     public static final String XMSGS_OPTION = "-Xmsgs";
  81     public static final String XMSGS_CUSTOM_PREFIX = "-Xmsgs:";
  82     private static final String STATS = "-stats";

  83     public static final String XCUSTOM_TAGS_PREFIX = "-XcustomTags:";
  84     public static final String XHTML_VERSION_PREFIX = "-XhtmlVersion:";
  85     public static final String XCHECK_PACKAGE = "-XcheckPackage:";
  86     public static final String SEPARATOR = ",";
  87 
  88     // <editor-fold defaultstate="collapsed" desc="Command-line entry point">
  89     public static void main(String... args) {
  90         DocLint dl = new DocLint();
  91         try {
  92             dl.run(args);
  93         } catch (BadArgs e) {
  94             System.err.println(e.getMessage());
  95             System.exit(1);
  96         } catch (IOException e) {
  97             System.err.println(dl.localize("dc.main.ioerror", e.getLocalizedMessage()));
  98             System.exit(2);
  99         }
 100     }
 101 
 102     // </editor-fold>


 271     public String getName() {
 272         return "doclint";
 273     }
 274 
 275     @Override @DefinedBy(Api.COMPILER_TREE)
 276     public void init(JavacTask task, String... args) {
 277         init(task, args, true);
 278     }
 279 
 280     // </editor-fold>
 281 
 282     // <editor-fold defaultstate="collapsed" desc="Embedding API">
 283 
 284     public void init(JavacTask task, String[] args, boolean addTaskListener) {
 285         env = new Env();
 286         for (String arg : args) {
 287             if (arg.equals(XMSGS_OPTION)) {
 288                 env.messages.setOptions(null);
 289             } else if (arg.startsWith(XMSGS_CUSTOM_PREFIX)) {
 290                 env.messages.setOptions(arg.substring(arg.indexOf(":") + 1));



 291             } else if (arg.startsWith(XCUSTOM_TAGS_PREFIX)) {
 292                 env.setCustomTags(arg.substring(arg.indexOf(":") + 1));
 293             } else if (arg.startsWith(XHTML_VERSION_PREFIX)) {
 294                 String argsVersion = arg.substring(arg.indexOf(":") + 1);
 295                 HtmlVersion htmlVersion = HtmlVersion.getHtmlVersion(argsVersion);
 296                 if (htmlVersion != null) {
 297                     env.setHtmlVersion(htmlVersion);
 298                 } else {
 299                     throw new IllegalArgumentException(argsVersion);
 300                 }
 301             } else if (arg.startsWith(XCHECK_PACKAGE)) {
 302                 env.setCheckPackages(arg.substring(arg.indexOf(":") + 1));
 303             } else
 304                 throw new IllegalArgumentException(arg);
 305         }
 306         env.init(task);
 307 
 308         checker = new Checker(env);
 309 
 310         if (addTaskListener) {


< prev index next >