8201817: Taglet.init should be called with the "primary" doclet

Reviewed-by: ksrini
This commit is contained in:
Jonathan Gibbons 2018-05-02 11:11:06 -07:00
parent cfa9de4249
commit f7ac53e5e9
4 changed files with 19 additions and 7 deletions

View File

@ -44,7 +44,7 @@ public class StandardDoclet implements Doclet {
private final HtmlDoclet htmlDoclet; private final HtmlDoclet htmlDoclet;
public StandardDoclet() { public StandardDoclet() {
htmlDoclet = new HtmlDoclet(); htmlDoclet = new HtmlDoclet(this);
} }
@Override @Override

View File

@ -31,6 +31,7 @@ import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.PackageElement; import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import jdk.javadoc.doclet.Doclet;
import jdk.javadoc.doclet.DocletEnvironment; import jdk.javadoc.doclet.DocletEnvironment;
import jdk.javadoc.doclet.Reporter; import jdk.javadoc.doclet.Reporter;
import jdk.javadoc.internal.doclets.toolkit.AbstractDoclet; import jdk.javadoc.internal.doclets.toolkit.AbstractDoclet;
@ -59,8 +60,8 @@ import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder;
*/ */
public class HtmlDoclet extends AbstractDoclet { public class HtmlDoclet extends AbstractDoclet {
public HtmlDoclet() { public HtmlDoclet(Doclet parent) {
configuration = new HtmlConfiguration(this); configuration = new HtmlConfiguration(parent);
} }
@Override // defined by Doclet @Override // defined by Doclet

View File

@ -42,6 +42,9 @@ import com.sun.tools.javac.util.DefinedBy.Api;
import jdk.javadoc.doclet.Doclet; import jdk.javadoc.doclet.Doclet;
import jdk.javadoc.doclet.DocletEnvironment; import jdk.javadoc.doclet.DocletEnvironment;
import jdk.javadoc.doclet.Reporter; import jdk.javadoc.doclet.Reporter;
import jdk.javadoc.doclet.StandardDoclet;
import jdk.javadoc.doclet.Taglet;
import jdk.javadoc.internal.doclets.formats.html.HtmlDoclet;
import jdk.javadoc.internal.doclets.toolkit.builders.BuilderFactory; import jdk.javadoc.internal.doclets.toolkit.builders.BuilderFactory;
import jdk.javadoc.internal.doclets.toolkit.taglets.TagletManager; import jdk.javadoc.internal.doclets.toolkit.taglets.TagletManager;
import jdk.javadoc.internal.doclets.toolkit.util.DocFile; import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
@ -356,7 +359,15 @@ public abstract class BaseConfiguration {
/** /**
* Constructs the configurations needed by the doclet. * Constructs the configurations needed by the doclet.
* *
* @param doclet the doclet that created this configuration * @apiNote
* The {@code doclet} parameter is used when {@link Taglet#init(DocletEnvironment, Doclet)
* initializing tags}.
* Some doclets (such as the {@link StandardDoclet), may delegate to another
* (such as the {@link HtmlDoclet}). In such cases, the primary doclet (i.e
* {@code StandardDoclet}) should be provided here, and not any internal
* class like {@code HtmlDoclet}.
*
* @param doclet the doclet for this run of javadoc
*/ */
public BaseConfiguration(Doclet doclet) { public BaseConfiguration(Doclet doclet) {
this.doclet = doclet; this.doclet = doclet;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 8176836 * @bug 8176836 8201817
* @summary Provide Taglet with context * @summary Provide Taglet with context
* @library ../lib * @library ../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool * @modules jdk.javadoc/jdk.javadoc.internal.tool
@ -52,7 +52,7 @@ public class TestUserTaglet extends JavadocTester {
checkOutput("pkg/C.html", true, checkOutput("pkg/C.html", true,
"<li>Element: CLASS C", "<li>Element: CLASS C",
"<li>Element supertypes: [java.lang.Object]", "<li>Element supertypes: [java.lang.Object]",
"<li>Doclet: class jdk.javadoc.internal.doclets.formats.html.HtmlDoclet" "<li>Doclet: class jdk.javadoc.doclet.StandardDoclet"
); );
} }
} }