changeset 40315:9e994c77db6a

8160137: HTMLDoclet and AbstractDoclet should implement Doclet Reviewed-by: ksrini
author jjg
date Fri, 12 Aug 2016 16:03:36 -0700
parents 52f8470ce3e4
children 20b50a99fe8d
files langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclets/StandardDoclet.java langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java
diffstat 3 files changed, 24 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclets/StandardDoclet.java	Fri Aug 12 15:41:47 2016 -0700
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclets/StandardDoclet.java	Fri Aug 12 16:03:36 2016 -0700
@@ -46,22 +46,27 @@
         htmlDoclet = new HtmlDoclet();
     }
 
+    @Override
     public void init(Locale locale, Reporter reporter) {
         htmlDoclet.init(locale, reporter);
     }
 
+    @Override
     public String getName() {
         return "Standard";
     }
 
+    @Override
     public Set<Doclet.Option> getSupportedOptions() {
         return htmlDoclet.getSupportedOptions();
     }
 
+    @Override
     public SourceVersion getSupportedSourceVersion() {
-        return htmlDoclet.sourceVersion();
+        return htmlDoclet.getSupportedSourceVersion();
     }
 
+    @Override
     public boolean run(DocletEnvironment docEnv) {
         return htmlDoclet.run(docEnv);
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java	Fri Aug 12 15:41:47 2016 -0700
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java	Fri Aug 12 16:03:36 2016 -0700
@@ -32,7 +32,6 @@
 import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
 
-import com.sun.javadoc.PackageDoc;
 import jdk.javadoc.doclet.Doclet.Option;
 import jdk.javadoc.doclet.DocletEnvironment;
 import jdk.javadoc.doclet.Reporter;
@@ -66,6 +65,11 @@
         configuration = new ConfigurationImpl();
     }
 
+    @Override // defined by Doclet
+    public String getName() {
+        return "Html";
+    }
+
     /**
      * The global configuration information for this run.
      */
@@ -77,6 +81,7 @@
     private static final DocPath DOCLET_RESOURCES = DocPath
             .create("/jdk/javadoc/internal/doclets/formats/html/resources");
 
+    @Override // defined by Doclet
     public void init(Locale locale, Reporter reporter) {
         configuration.reporter = reporter;
         configuration.locale = locale;
@@ -84,21 +89,11 @@
     }
 
     /**
-     * The "start" method as required by Javadoc.
-     *
-     * @param docEnv the root of the documentation tree.
-     * @see jdk.doclet.DocletEnvironment
-     * @return true if the doclet ran without encountering any errors.
-     */
-    public boolean run(DocletEnvironment docEnv) {
-        return startDoclet(docEnv);
-    }
-
-    /**
      * Create the configuration instance.
      * Override this method to use a different
      * configuration.
      */
+    @Override // defined by AbstractDoclet
     public Configuration configuration() {
         return configuration;
     }
@@ -113,6 +108,7 @@
      *
      * @see jdk.doclet.RootDoc
      */
+    @Override // defined by AbstractDoclet
     protected void generateOtherFiles(DocletEnvironment docEnv, ClassTree classtree)
             throws Exception {
         super.generateOtherFiles(docEnv, classtree);
@@ -228,6 +224,7 @@
     /**
      * {@inheritDoc}
      */
+    @Override // defined by AbstractDoclet
     protected void generateClassFiles(SortedSet<TypeElement> arr, ClassTree classtree) {
         List<TypeElement> list = new ArrayList<>(arr);
         ListIterator<TypeElement> iterator = list.listIterator();
@@ -270,6 +267,7 @@
     /**
      * {@inheritDoc}
      */
+    @Override // defined by AbstractDoclet
     protected void generateModuleFiles() throws Exception {
         if (configuration.showModules) {
             ModuleIndexFrameWriter.generate(configuration);
@@ -303,6 +301,7 @@
     /**
      * {@inheritDoc}
      */
+    @Override // defined by AbstractDoclet
     protected void generatePackageFiles(ClassTree classtree) throws Exception {
         Set<PackageElement> packages = configuration.packages;
         if (packages.size() > 1) {
@@ -339,6 +338,7 @@
         }
     }
 
+    @Override // defined by Doclet
     public Set<Option> getSupportedOptions() {
         return configuration.getSupportedOptions();
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java	Fri Aug 12 15:41:47 2016 -0700
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java	Fri Aug 12 16:03:36 2016 -0700
@@ -32,6 +32,7 @@
 import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
 
+import jdk.javadoc.doclet.Doclet;
 import jdk.javadoc.doclet.DocletEnvironment;
 import jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder;
 import jdk.javadoc.internal.doclets.toolkit.builders.BuilderFactory;
@@ -53,7 +54,7 @@
  *
  * @author Jamie Ho
  */
-public abstract class AbstractDoclet {
+public abstract class AbstractDoclet implements Doclet {
 
     /**
      * The global configuration information for this run.
@@ -92,7 +93,8 @@
      * @param root   the {@link DocletEnvironment} that points to the source to document.
      * @return true if the doclet executed without error.  False otherwise.
      */
-    public boolean startDoclet(DocletEnvironment root) {
+    @Override
+    public boolean run(DocletEnvironment root) {
         configuration = configuration();
         configuration.docEnv = root;
         configuration.cmtUtils = new CommentUtils(configuration);
@@ -131,7 +133,8 @@
      * Returns the SourceVersion indicating the features supported by this doclet.
      * @return SourceVersion
      */
-    public SourceVersion sourceVersion() {
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
         return SourceVersion.RELEASE_9;
     }