mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
8029143: javadoc standard doclet should add Functional Interface blurb when @FunctionalInterface annotation is present
Reviewed-by: ksrini
This commit is contained in:
parent
fb9c998b1d
commit
e08ccd0e48
8 changed files with 61 additions and 19 deletions
|
@ -74,15 +74,6 @@ public interface ClassDoc extends ProgramElementDoc, Type {
|
||||||
*/
|
*/
|
||||||
boolean isExternalizable();
|
boolean isExternalizable();
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true if this class can be used as a target type of a lambda expression
|
|
||||||
* or method reference.
|
|
||||||
*
|
|
||||||
* @return true if this class can be used as a target type of a lambda expression
|
|
||||||
* or method reference.
|
|
||||||
*/
|
|
||||||
boolean isFunctionalInterface();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the serialization methods for this class or
|
* Return the serialization methods for this class or
|
||||||
* interface.
|
* interface.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2014, 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
|
||||||
|
@ -29,6 +29,7 @@ import java.util.*;
|
||||||
|
|
||||||
import com.sun.javadoc.*;
|
import com.sun.javadoc.*;
|
||||||
import com.sun.tools.javac.jvm.Profile;
|
import com.sun.tools.javac.jvm.Profile;
|
||||||
|
import com.sun.tools.javadoc.RootDocImpl;
|
||||||
import com.sun.tools.doclets.formats.html.markup.*;
|
import com.sun.tools.doclets.formats.html.markup.*;
|
||||||
import com.sun.tools.doclets.internal.toolkit.*;
|
import com.sun.tools.doclets.internal.toolkit.*;
|
||||||
import com.sun.tools.doclets.internal.toolkit.builders.*;
|
import com.sun.tools.doclets.internal.toolkit.builders.*;
|
||||||
|
@ -528,7 +529,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void addFunctionalInterfaceInfo (Content classInfoTree) {
|
public void addFunctionalInterfaceInfo (Content classInfoTree) {
|
||||||
if (classDoc.isFunctionalInterface()) {
|
if (isFunctionalInterface()) {
|
||||||
Content dt = HtmlTree.DT(getResource("doclet.Functional_Interface"));
|
Content dt = HtmlTree.DT(getResource("doclet.Functional_Interface"));
|
||||||
Content dl = HtmlTree.DL(dt);
|
Content dl = HtmlTree.DL(dt);
|
||||||
Content dd = new HtmlTree(HtmlTag.DD);
|
Content dd = new HtmlTree(HtmlTag.DD);
|
||||||
|
@ -538,6 +539,19 @@ public class ClassWriterImpl extends SubWriterHolderWriter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFunctionalInterface() {
|
||||||
|
if (configuration.root instanceof RootDocImpl) {
|
||||||
|
RootDocImpl root = (RootDocImpl) configuration.root;
|
||||||
|
AnnotationDesc[] annotationDescList = classDoc.annotations();
|
||||||
|
for (AnnotationDesc annoDesc : annotationDescList) {
|
||||||
|
if (root.isFunctionalInterface(annoDesc)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -288,10 +288,6 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFunctionalInterface() {
|
|
||||||
return env.types.isFunctionalInterface(tsym) && env.source.allowLambda();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the package that this class is contained in.
|
* Return the package that this class is contained in.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2014, 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
|
||||||
|
@ -381,6 +381,11 @@ public class RootDocImpl extends DocImpl implements RootDoc {
|
||||||
env.initDoclint(opts, customTagNames);
|
env.initDoclint(opts, customTagNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFunctionalInterface(AnnotationDesc annotationDesc) {
|
||||||
|
return annotationDesc.annotationType().qualifiedName().equals(
|
||||||
|
env.syms.functionalInterfaceType.toString()) && env.source.allowLambda();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean showTagMessages() {
|
public boolean showTagMessages() {
|
||||||
return env.showTagMessages();
|
return env.showTagMessages();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2014, 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 8004893 8022738
|
* @bug 8004893 8022738 8029143
|
||||||
* @summary Make sure that the lambda feature changes work fine in
|
* @summary Make sure that the lambda feature changes work fine in
|
||||||
* javadoc.
|
* javadoc.
|
||||||
* @author bpatel
|
* @author bpatel
|
||||||
|
@ -87,6 +87,11 @@ public class TestLambdaFeature extends JavadocTester {
|
||||||
"<pre>default default void defaultMethod()</pre>"},
|
"<pre>default default void defaultMethod()</pre>"},
|
||||||
{BUG_ID + FS + "pkg" + FS + "B.html",
|
{BUG_ID + FS + "pkg" + FS + "B.html",
|
||||||
"<td class=\"colFirst\"><code>default void</code></td>"},
|
"<td class=\"colFirst\"><code>default void</code></td>"},
|
||||||
|
{BUG_ID + FS + "pkg1" + FS + "NotAFuncInf.html",
|
||||||
|
"<dl>" + NL + "<dt>Functional Interface:</dt>" + NL +
|
||||||
|
"<dd>This is a functional interface and can therefore be used as " +
|
||||||
|
"the assignment target for a lambda expression or method " +
|
||||||
|
"reference.</dd>" + NL + "</dl>"},
|
||||||
{BUG_ID + FS + "pkg" + FS + "B.html",
|
{BUG_ID + FS + "pkg" + FS + "B.html",
|
||||||
"<dl>" + NL + "<dt>Functional Interface:</dt>"}
|
"<dl>" + NL + "<dt>Functional Interface:</dt>"}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2014, 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,6 +23,7 @@
|
||||||
|
|
||||||
package pkg;
|
package pkg;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
public interface A {
|
public interface A {
|
||||||
|
|
||||||
public void method1();
|
public void method1();
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
package pkg1;
|
package pkg1;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
public interface FuncInf<V> {
|
public interface FuncInf<V> {
|
||||||
|
|
||||||
V call() throws Exception;
|
V call() throws Exception;
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package pkg1;
|
||||||
|
|
||||||
|
public interface NotAFuncInf<V> {
|
||||||
|
|
||||||
|
V call() throws Exception;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue