6492694: @deprecated tag doesn't work in package-info files

Reviewed-by: jjg
This commit is contained in:
Bhavesh Patel 2011-05-02 02:13:02 -07:00
parent 80d69a4f40
commit 746cdfda77
31 changed files with 608 additions and 108 deletions

View File

@ -149,11 +149,20 @@ public class ClassUseWriter extends SubWriterHolderWriter {
ClassUseMapper mapper = new ClassUseMapper(configuration.root, classtree);
ClassDoc[] classes = configuration.root.classes();
for (int i = 0; i < classes.length; i++) {
ClassUseWriter.generate(configuration, mapper, classes[i]);
// If -nodeprecated option is set and the containing package is marked
// as deprecated, do not generate the class-use page. We will still generate
// the class-use page if the class is marked as deprecated but the containing
// package is not since it could still be linked from that package-use page.
if (!(configuration.nodeprecated &&
Util.isDeprecated(classes[i].containingPackage())))
ClassUseWriter.generate(configuration, mapper, classes[i]);
}
PackageDoc[] pkgs = configuration.packages;
for (int i = 0; i < pkgs.length; i++) {
PackageUseWriter.generate(configuration, mapper, pkgs[i]);
// If -nodeprecated option is set and the package is marked
// as deprecated, do not generate the package-use page.
if (!(configuration.nodeprecated && Util.isDeprecated(pkgs[i])))
PackageUseWriter.generate(configuration, mapper, pkgs[i]);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2011, 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
@ -42,15 +42,15 @@ import com.sun.tools.doclets.formats.html.markup.*;
public class DeprecatedListWriter extends SubWriterHolderWriter {
private static final String[] ANCHORS = new String[] {
"interface", "class", "enum", "exception", "error", "annotation_type",
"field", "method", "constructor", "enum_constant",
"package", "interface", "class", "enum", "exception", "error",
"annotation_type", "field", "method", "constructor", "enum_constant",
"annotation_type_member"
};
private static final String[] HEADING_KEYS = new String[] {
"doclet.Deprecated_Interfaces", "doclet.Deprecated_Classes",
"doclet.Deprecated_Enums", "doclet.Deprecated_Exceptions",
"doclet.Deprecated_Errors",
"doclet.Deprecated_Packages", "doclet.Deprecated_Interfaces",
"doclet.Deprecated_Classes", "doclet.Deprecated_Enums",
"doclet.Deprecated_Exceptions", "doclet.Deprecated_Errors",
"doclet.Deprecated_Annotation_Types",
"doclet.Deprecated_Fields",
"doclet.Deprecated_Methods", "doclet.Deprecated_Constructors",
@ -59,9 +59,9 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
};
private static final String[] SUMMARY_KEYS = new String[] {
"doclet.deprecated_interfaces", "doclet.deprecated_classes",
"doclet.deprecated_enums", "doclet.deprecated_exceptions",
"doclet.deprecated_errors",
"doclet.deprecated_packages", "doclet.deprecated_interfaces",
"doclet.deprecated_classes", "doclet.deprecated_enums",
"doclet.deprecated_exceptions", "doclet.deprecated_errors",
"doclet.deprecated_annotation_types",
"doclet.deprecated_fields",
"doclet.deprecated_methods", "doclet.deprecated_constructors",
@ -70,7 +70,7 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
};
private static final String[] HEADER_KEYS = new String[] {
"doclet.Interface", "doclet.Class",
"doclet.Package", "doclet.Interface", "doclet.Class",
"doclet.Enum", "doclet.Exceptions",
"doclet.Errors",
"doclet.AnnotationType",
@ -116,7 +116,7 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
DeprecatedListWriter depr =
new DeprecatedListWriter(configuration, filename);
depr.generateDeprecatedListFile(
new DeprecatedAPIListBuilder(configuration.root));
new DeprecatedAPIListBuilder(configuration));
depr.close();
} catch (IOException exc) {
configuration.standardmessage.error(
@ -149,8 +149,14 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
memberTableHeader[0] = configuration.getText("doclet.0_and_1",
configuration.getText(HEADER_KEYS[i]),
configuration.getText("doclet.Description"));
writers[i].addDeprecatedAPI(deprapi.getList(i),
HEADING_KEYS[i], memberTableSummary, memberTableHeader, div);
// DeprecatedAPIListBuilder.PACKAGE == 0, so if i == 0, it is
// a PackageDoc.
if (i == DeprecatedAPIListBuilder.PACKAGE)
addPackageDeprecatedAPI(deprapi.getList(i),
HEADING_KEYS[i], memberTableSummary, memberTableHeader, div);
else
writers[i - 1].addDeprecatedAPI(deprapi.getList(i),
HEADING_KEYS[i], memberTableSummary, memberTableHeader, div);
}
}
body.addContent(div);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2011, 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
@ -198,23 +198,27 @@ public class HtmlDoclet extends AbstractDoclet {
PackageIndexFrameWriter.generate(configuration);
}
PackageDoc prev = null, next;
for(int i = 0; i < packages.length; i++) {
PackageFrameWriter.generate(configuration, packages[i]);
next = (i + 1 < packages.length && packages[i+1].name().length() > 0) ?
packages[i+1] : null;
//If the next package is unnamed package, skip 2 ahead if possible
next = (i + 2 < packages.length && next == null) ?
packages[i+2]: next;
AbstractBuilder packageSummaryBuilder = configuration.
getBuilderFactory().getPackageSummaryBuilder(
packages[i], prev, next);
packageSummaryBuilder.build();
if (configuration.createtree) {
PackageTreeWriter.generate(configuration,
packages[i], prev, next,
configuration.nodeprecated);
for (int i = 0; i < packages.length; i++) {
// if -nodeprecated option is set and the package is marked as
// deprecated, do not generate the package-summary.html, package-frame.html
// and package-tree.html pages for that package.
if (!(configuration.nodeprecated && Util.isDeprecated(packages[i]))) {
PackageFrameWriter.generate(configuration, packages[i]);
next = (i + 1 < packages.length &&
packages[i + 1].name().length() > 0) ? packages[i + 1] : null;
//If the next package is unnamed package, skip 2 ahead if possible
next = (i + 2 < packages.length && next == null) ? packages[i + 2] : next;
AbstractBuilder packageSummaryBuilder =
configuration.getBuilderFactory().getPackageSummaryBuilder(
packages[i], prev, next);
packageSummaryBuilder.build();
if (configuration.createtree) {
PackageTreeWriter.generate(configuration,
packages[i], prev, next,
configuration.nodeprecated);
}
prev = packages[i];
}
prev = packages[i];
}
}

View File

@ -1394,6 +1394,44 @@ public class HtmlDocletWriter extends HtmlDocWriter {
return new StringContent(packageName);
}
/**
* Add package deprecation information to the documentation tree
*
* @param deprPkgs list of deprecated packages
* @param headingKey the caption for the deprecated package table
* @param tableSummary the summary for the deprecated package table
* @param tableHeader table headers for the deprecated package table
* @param contentTree the content tree to which the deprecated package table will be added
*/
protected void addPackageDeprecatedAPI(List<Doc> deprPkgs, String headingKey,
String tableSummary, String[] tableHeader, Content contentTree) {
if (deprPkgs.size() > 0) {
Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
getTableCaption(configuration().getText(headingKey)));
table.addContent(getSummaryTableHeader(tableHeader, "col"));
Content tbody = new HtmlTree(HtmlTag.TBODY);
for (int i = 0; i < deprPkgs.size(); i++) {
PackageDoc pkg = (PackageDoc) deprPkgs.get(i);
HtmlTree td = HtmlTree.TD(HtmlStyle.colOne,
getPackageLink(pkg, getPackageName(pkg)));
if (pkg.tags("deprecated").length > 0) {
addInlineDeprecatedComment(pkg, pkg.tags("deprecated")[0], td);
}
HtmlTree tr = HtmlTree.TR(td);
if (i % 2 == 0) {
tr.addStyle(HtmlStyle.altColor);
} else {
tr.addStyle(HtmlStyle.rowColor);
}
tbody.addContent(tr);
}
table.addContent(tbody);
Content li = HtmlTree.LI(HtmlStyle.blockList, table);
Content ul = HtmlTree.UL(HtmlStyle.blockList, li);
contentTree.addContent(ul);
}
}
/**
* Prine table header information about color, column span and the font.
*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, 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
@ -93,7 +93,7 @@ public class PackageFrameWriter extends HtmlDocletWriter {
packgen = new PackageFrameWriter(configuration, packageDoc);
String pkgName = Util.getPackageName(packageDoc);
Content body = packgen.getBody(false, packgen.getWindowTitle(pkgName));
Content pkgNameContent = new StringContent(pkgName);
Content pkgNameContent = new RawHtml(pkgName);
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar,
packgen.getTargetPackageLink(packageDoc, "classFrame", pkgNameContent));
body.addContent(heading);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, 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
@ -80,7 +80,10 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
HtmlTree ul = new HtmlTree(HtmlTag.UL);
ul.addAttr(HtmlAttr.TITLE, packagesLabel.toString());
for(int i = 0; i < packages.length; i++) {
if (packages[i] != null) {
// Do not list the package if -nodeprecated option is set and the
// package is marked as deprecated.
if (packages[i] != null &&
(!(configuration.nodeprecated && Util.isDeprecated(packages[i])))) {
ul.addContent(getPackage(packages[i]));
}
}

View File

@ -137,6 +137,8 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter {
protected void addPackagesList(PackageDoc[] packages, Content tbody) {
for (int i = 0; i < packages.length; i++) {
if (packages[i] != null && packages[i].name().length() > 0) {
if (configuration.nodeprecated && Util.isDeprecated(packages[i]))
continue;
Content packageLinkContent = getPackageLink(packages[i],
getPackageName(packages[i]));
Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, packageLinkContent);

View File

@ -242,11 +242,16 @@ public class PackageUseWriter extends SubWriterHolderWriter {
*/
protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException {
Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst,
getHyperLink("", pkg.name(), new StringContent(Util.getPackageName(pkg))));
getHyperLink("", Util.getPackageName(pkg),
new RawHtml(Util.getPackageName(pkg))));
contentTree.addContent(tdFirst);
HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
tdLast.addStyle(HtmlStyle.colLast);
addSummaryComment(pkg, tdLast);
if (pkg != null && pkg.name().length() != 0) {
addSummaryComment(pkg, tdLast);
} else {
tdLast.addContent(getSpace());
}
contentTree.addContent(tdLast);
}

View File

@ -114,11 +114,12 @@ public class PackageWriterImpl extends HtmlDocletWriter
Content packageHead = new RawHtml(heading);
tHeading.addContent(packageHead);
div.addContent(tHeading);
addDeprecationInfo(div);
if (packageDoc.inlineTags().length > 0 && ! configuration.nocomment) {
HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV);
subTitleDiv.addStyle(HtmlStyle.subTitle);
addSummaryComment(packageDoc, subTitleDiv);
div.addContent(subTitleDiv);
HtmlTree docSummaryDiv = new HtmlTree(HtmlTag.DIV);
docSummaryDiv.addStyle(HtmlStyle.docSummary);
addSummaryComment(packageDoc, docSummaryDiv);
div.addContent(docSummaryDiv);
Content space = getSpace();
Content descLink = getHyperLink("", "package_description",
descriptionLabel, "", "");
@ -138,6 +139,28 @@ public class PackageWriterImpl extends HtmlDocletWriter
return div;
}
/**
* Add the package deprecation information to the documentation tree.
*
* @param div the content tree to which the deprecation information will be added
*/
public void addDeprecationInfo(Content div) {
Tag[] deprs = packageDoc.tags("deprecated");
if (Util.isDeprecated(packageDoc)) {
HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV);
deprDiv.addStyle(HtmlStyle.deprecatedContent);
Content deprPhrase = HtmlTree.SPAN(HtmlStyle.strong, deprecatedPhrase);
deprDiv.addContent(deprPhrase);
if (deprs.length > 0) {
Tag[] commentTags = deprs[0].inlineTags();
if (commentTags.length > 0) {
addInlineDeprecatedComment(packageDoc, deprs[0], deprDiv);
}
}
div.addContent(deprDiv);
}
}
/**
* {@inheritDoc}
*/

View File

@ -82,12 +82,20 @@ public class SourceToHTMLConverter {
}
PackageDoc[] pds = rd.specifiedPackages();
for (int i = 0; i < pds.length; i++) {
convertPackage(configuration, pds[i], outputdir);
// If -nodeprecated option is set and the package is marked as deprecated,
// do not convert the package files to HTML.
if (!(configuration.nodeprecated && Util.isDeprecated(pds[i])))
convertPackage(configuration, pds[i], outputdir);
}
ClassDoc[] cds = rd.specifiedClasses();
for (int i = 0; i < cds.length; i++) {
convertClass(configuration, cds[i],
getPackageOutputDir(outputdir, cds[i].containingPackage()));
// If -nodeprecated option is set and the class is marked as deprecated
// or the containing package is deprecated, do not convert the
// package files to HTML.
if (!(configuration.nodeprecated &&
(Util.isDeprecated(cds[i]) || Util.isDeprecated(cds[i].containingPackage()))))
convertClass(configuration, cds[i],
getPackageOutputDir(outputdir, cds[i].containingPackage()));
}
}
@ -106,7 +114,12 @@ public class SourceToHTMLConverter {
String classOutputdir = getPackageOutputDir(outputdir, pd);
ClassDoc[] cds = pd.allClasses();
for (int i = 0; i < cds.length; i++) {
convertClass(configuration, cds[i], classOutputdir);
// If -nodeprecated option is set and the class is marked as deprecated,
// do not convert the package files to HTML. We do not check for
// containing package deprecation since it is already check in
// the calling method above.
if (!(configuration.nodeprecated && Util.isDeprecated(cds[i])))
convertClass(configuration, cds[i], classOutputdir);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2011, 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
@ -132,7 +132,11 @@ public class TreeWriter extends AbstractTreeWriter {
HtmlTree ul = new HtmlTree(HtmlTag.UL);
ul.addStyle(HtmlStyle.horizontal);
for (int i = 0; i < packages.length; i++) {
if (packages[i].name().length() == 0) {
// If the package name length is 0 or if -nodeprecated option
// is set and the package is marked as deprecated, do not include
// the page in the list of package hierarchies.
if (packages[i].name().length() == 0 ||
(configuration.nodeprecated && Util.isDeprecated(packages[i]))) {
continue;
}
String link = pathString(packages[i], "package-tree.html");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2011, 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
@ -46,6 +46,7 @@ public enum HtmlStyle {
contentContainer,
description,
details,
docSummary,
header,
horizontal,
footer,
@ -67,6 +68,7 @@ public enum HtmlStyle {
subNavList,
subTitle,
summary,
deprecatedContent,
tabEnd,
title,
topNav;

View File

@ -68,6 +68,7 @@ doclet.see.class_or_package_not_accessible=Tag {0}: reference not accessible: {1
doclet.see.malformed_tag=Tag {0}: Malformed: {1}
doclet.Inherited_API_Summary=Inherited API Summary
doclet.Deprecated_API=Deprecated API
doclet.Deprecated_Packages=Deprecated Packages
doclet.Deprecated_Classes=Deprecated Classes
doclet.Deprecated_Enums=Deprecated Enums
doclet.Deprecated_Interfaces=Deprecated Interfaces
@ -79,6 +80,7 @@ doclet.Deprecated_Constructors=Deprecated Constructors
doclet.Deprecated_Methods=Deprecated Methods
doclet.Deprecated_Enum_Constants=Deprecated Enum Constants
doclet.Deprecated_Annotation_Type_Members=Deprecated Annotation Type Elements
doclet.deprecated_packages=deprecated packages
doclet.deprecated_classes=deprecated classes
doclet.deprecated_enums=deprecated enums
doclet.deprecated_interfaces=deprecated interfaces

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2011, 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
@ -419,7 +419,7 @@ public abstract class Configuration {
docencoding = encoding;
}
classDocCatalog = new ClassDocCatalog(root.specifiedClasses());
classDocCatalog = new ClassDocCatalog(root.specifiedClasses(), this);
initTagletManager(customTagStrs);
}
@ -677,15 +677,18 @@ public abstract class Configuration {
}
/**
* Return true if the doc element is getting documented, depending upon
* -nodeprecated option and @deprecated tag used. Return true if
* -nodeprecated is not used or @deprecated tag is not used.
* Return true if the ClassDoc element is getting documented, depending upon
* -nodeprecated option and the deprecation information. Return true if
* -nodeprecated is not used. Return false if -nodeprecated is used and if
* either ClassDoc element is deprecated or the containing package is deprecated.
*
* @param cd the ClassDoc for which the page generation is checked
*/
public boolean isGeneratedDoc(Doc doc) {
public boolean isGeneratedDoc(ClassDoc cd) {
if (!nodeprecated) {
return true;
}
return (doc.tags("deprecated")).length == 0;
return !(Util.isDeprecated(cd) || Util.isDeprecated(cd.containingPackage()));
}
/**

View File

@ -159,6 +159,16 @@ Page header and footer styles
padding-top:10px;
}
/*
Content styles
*/
.deprecatedContent {
margin:0;
padding:10px 0;
}
.docSummary {
padding-top:10px;
}
/*
Page layout container styles
*/
.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2011, 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
@ -44,13 +44,6 @@ public class DeprecatedTaglet extends BaseTaglet{
name = "deprecated";
}
/**
* {@inheritDoc}
*/
public boolean inPackage() {
return false;
}
/**
* {@inheritDoc}
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2011, 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
@ -25,8 +25,9 @@
package com.sun.tools.doclets.internal.toolkit.util;
import com.sun.javadoc.*;
import java.util.*;
import com.sun.javadoc.*;
import com.sun.tools.doclets.internal.toolkit.Configuration;
/**
* This class acts as an artificial PackageDoc for classes specified
@ -88,13 +89,16 @@ import java.util.*;
*/
private Map<String,Set<ClassDoc>> interfaces;
private Configuration configuration;
/**
* Construct a new ClassDocCatalog.
*
* @param classdocs the array of ClassDocs to catalog
*/
public ClassDocCatalog (ClassDoc[] classdocs) {
public ClassDocCatalog (ClassDoc[] classdocs, Configuration config) {
init();
this.configuration = config;
for (int i = 0; i < classdocs.length; i++) {
addClassDoc(classdocs[i]);
}
@ -151,9 +155,10 @@ import java.util.*;
private void addClass(ClassDoc classdoc, Map<String,Set<ClassDoc>> map) {
PackageDoc pkg = classdoc.containingPackage();
if (pkg.isIncluded()) {
//No need to catalog this class since it's package is
//included on the command line
if (pkg.isIncluded() || (configuration.nodeprecated && Util.isDeprecated(pkg))) {
//No need to catalog this class if it's package is
//included on the command line or if -nodeprecated option is set
// and the containing package is marked as deprecated.
return;
}
String key = Util.getPackageName(pkg);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, 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
@ -122,8 +122,12 @@ public class ClassTree {
*/
private void buildTree(ClassDoc[] classes, Configuration configuration) {
for (int i = 0; i < classes.length; i++) {
// In the tree page (e.g overview-tree.html) do not include
// information of classes which are deprecated or are a part of a
// deprecated package.
if (configuration.nodeprecated &&
classes[i].tags("deprecated").length > 0) {
(Util.isDeprecated(classes[i]) ||
Util.isDeprecated(classes[i].containingPackage()))) {
continue;
}
if (classes[i].isEnum()) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, 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
@ -27,27 +27,29 @@ package com.sun.tools.doclets.internal.toolkit.util;
import com.sun.javadoc.*;
import java.util.*;
import com.sun.tools.doclets.internal.toolkit.Configuration;
/**
* Build list of all the deprecated classes, constructors, fields and methods.
* Build list of all the deprecated packages, classes, constructors, fields and methods.
*
* @author Atul M Dambalkar
*/
public class DeprecatedAPIListBuilder {
public static final int NUM_TYPES = 11;
public static final int NUM_TYPES = 12;
public static final int INTERFACE = 0;
public static final int CLASS = 1;
public static final int ENUM = 2;
public static final int EXCEPTION = 3;
public static final int ERROR = 4;
public static final int ANNOTATION_TYPE = 5;
public static final int FIELD = 6;
public static final int METHOD = 7;
public static final int CONSTRUCTOR = 8;
public static final int ENUM_CONSTANT = 9;
public static final int ANNOTATION_TYPE_MEMBER = 10;
public static final int PACKAGE = 0;
public static final int INTERFACE = 1;
public static final int CLASS = 2;
public static final int ENUM = 3;
public static final int EXCEPTION = 4;
public static final int ERROR = 5;
public static final int ANNOTATION_TYPE = 6;
public static final int FIELD = 7;
public static final int METHOD = 8;
public static final int CONSTRUCTOR = 9;
public static final int ENUM_CONSTANT = 10;
public static final int ANNOTATION_TYPE_MEMBER = 11;
/**
* List of deprecated type Lists.
@ -58,25 +60,33 @@ public class DeprecatedAPIListBuilder {
/**
* Constructor.
*
* @param root Root of the tree.
* @param configuration the current configuration of the doclet
*/
public DeprecatedAPIListBuilder(RootDoc root) {
public DeprecatedAPIListBuilder(Configuration configuration) {
deprecatedLists = new ArrayList<List<Doc>>();
for (int i = 0; i < NUM_TYPES; i++) {
deprecatedLists.add(i, new ArrayList<Doc>());
}
buildDeprecatedAPIInfo(root);
buildDeprecatedAPIInfo(configuration);
}
/**
* Build the sorted list of all the deprecated APIs in this run.
* Build separate lists for deprecated classes, constructors, methods and
* fields.
* Build separate lists for deprecated packages, classes, constructors,
* methods and fields.
*
* @param root Root of the tree.
* @param configuration the current configuration of the doclet.
*/
private void buildDeprecatedAPIInfo(RootDoc root) {
ClassDoc[] classes = root.classes();
private void buildDeprecatedAPIInfo(Configuration configuration) {
PackageDoc[] packages = configuration.packages;
PackageDoc pkg;
for (int c = 0; c < packages.length; c++) {
pkg = packages[c];
if (Util.isDeprecated(pkg)) {
getList(PACKAGE).add(pkg);
}
}
ClassDoc[] classes = configuration.root.classes();
for (int i = 0; i < classes.length; i++) {
ClassDoc cd = classes[i];
if (Util.isDeprecated(cd)) {
@ -90,7 +100,7 @@ public class DeprecatedAPIListBuilder {
getList(ENUM).add(cd);
} else if (cd.isError()) {
getList(ERROR).add(cd);
}else if (cd.isAnnotationType()) {
} else if (cd.isAnnotationType()) {
getList(ANNOTATION_TYPE).add(cd);
}
}
@ -102,7 +112,7 @@ public class DeprecatedAPIListBuilder {
}
if (cd.isAnnotationType()) {
composeDeprecatedList(getList(ANNOTATION_TYPE_MEMBER),
((AnnotationTypeDoc) cd).elements());
((AnnotationTypeDoc) cd).elements());
}
}
sortDeprecatedLists();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, 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
@ -207,7 +207,17 @@ public class IndexBuilder {
* Should this doc element be added to the index map?
*/
protected boolean shouldAddToIndexMap(Doc element) {
return !(noDeprecated && element.tags("deprecated").length > 0);
if (element instanceof PackageDoc)
// Do not add to index map if -nodeprecated option is set and the
// package is marked as deprecated.
return !(noDeprecated && Util.isDeprecated(element));
else
// Do not add to index map if -nodeprecated option is set and if the
// Doc is marked as deprecated or the containing package is marked as
// deprecated.
return !(noDeprecated &&
(Util.isDeprecated(element) ||
Util.isDeprecated(((ProgramElementDoc)element).containingPackage())));
}
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2011, 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
@ -76,13 +76,16 @@ public class PackageListWriter extends PrintWriter {
protected void generatePackageListFile(RootDoc root) {
PackageDoc[] packages = configuration.packages;
String[] names = new String[packages.length];
ArrayList<String> names = new ArrayList<String>();
for (int i = 0; i < packages.length; i++) {
names[i] = packages[i].name();
// if the -nodeprecated option is set and the package is marked as
// deprecated, do not include it in the packages list.
if (!(configuration.nodeprecated && Util.isDeprecated(packages[i])))
names.add(packages[i].name());
}
Arrays.sort(names);
for (int i = 0; i < packages.length; i++) {
println(names[i]);
Collections.sort(names);
for (int i = 0; i < names.size(); i++) {
println(names.get(i));
}
}
}

View File

@ -861,11 +861,15 @@ public class Util {
* @param doc the Doc to check.
* @return true if the given Doc is deprecated.
*/
public static boolean isDeprecated(ProgramElementDoc doc) {
public static boolean isDeprecated(Doc doc) {
if (doc.tags("deprecated").length > 0) {
return true;
}
AnnotationDesc[] annotationDescList = doc.annotations();
AnnotationDesc[] annotationDescList;
if (doc instanceof PackageDoc)
annotationDescList = ((PackageDoc)doc).annotations();
else
annotationDescList = ((ProgramElementDoc)doc).annotations();
for (int i = 0; i < annotationDescList.length; i++) {
if (annotationDescList[i].annotationType().qualifiedName().equals(
java.lang.Deprecated.class.getName())){

View File

@ -0,0 +1,55 @@
/*
* Copyright (c) 2011, 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.
*/
/**
* Another test class.
*
* @author Bhavesh Patel
*/
public class C2 {
public static enum ModalExclusionType {
/**
* Test comment.
*/
NO_EXCLUDE,
/**
* Another comment.
*/
APPLICATION_EXCLUDE
};
/**
* A string constant.
*/
public static final String CONSTANT1 = "C2";
/**
* A sample method.
*
* @param param some parameter.
*/
public void method(String param) {
}
}

View File

@ -0,0 +1,34 @@
/*
* Copyright (c) 2011, 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.
*/
import java.util.*;
/**
* Test Deprecated class
* @deprecated This class is Deprecated.
*/
public class FooDepr {
public void method(Vector<Object> o){}
}

View File

@ -0,0 +1,103 @@
/*
* Copyright (c) 2011, 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.
*/
/*
* @test
* @bug 6492694
* @summary Test package deprecation.
* @author bpatel
* @library ../lib/
* @build JavadocTester TestPackageDeprecation
* @run main TestPackageDeprecation
*/
public class TestPackageDeprecation extends JavadocTester {
//Test information.
private static final String BUG_ID = "6492694";
//Javadoc arguments.
private static final String[] ARGS1 = new String[]{
"-d", BUG_ID + "-1", "-source", "1.5", "-sourcepath", SRC_DIR, "-use", "pkg", "pkg1",
SRC_DIR + FS + "C2.java", SRC_DIR + FS + "FooDepr.java"
};
private static final String[] ARGS2 = new String[]{
"-d", BUG_ID + "-2", "-source", "1.5", "-sourcepath", SRC_DIR, "-use", "-nodeprecated",
"pkg", "pkg1", SRC_DIR + FS + "C2.java", SRC_DIR + FS + "FooDepr.java"
};
//Input for string search tests.
private static final String[][] TEST1 = {
{BUG_ID + "-1" + FS + "pkg1" + FS + "package-summary.html",
"<div class=\"deprecatedContent\"><span class=\"strong\">Deprecated.</span>" + NL +
"<div class=\"block\"><i>This package is Deprecated.</i></div>"
},
{BUG_ID + "-1" + FS + "deprecated-list.html",
"<li><a href=\"#package\">Deprecated Packages</a></li>"
}
};
private static final String[][] TEST2 = NO_TEST;
private static final String[][] NEGATED_TEST1 = NO_TEST;
private static final String[][] NEGATED_TEST2 = {
{BUG_ID + "-2" + FS + "overview-summary.html", "pkg1"},
{BUG_ID + "-2" + FS + "allclasses-frame.html", "FooDepr"}
};
/**
* The entry point of the test.
* @param args the array of command line arguments.
*/
public static void main(String[] args) {
TestPackageDeprecation tester = new TestPackageDeprecation();
run(tester, ARGS1, TEST1, NEGATED_TEST1);
run(tester, ARGS2, TEST2, NEGATED_TEST2);
if ((new java.io.File(BUG_ID + "-2" + FS + "pkg1" + FS +
"package-summary.html")).exists()) {
throw new Error("Test Fails: packages summary should not be" +
"generated for deprecated package.");
} else {
System.out.println("Test passes: package-summary.html not found.");
}
if ((new java.io.File(BUG_ID + "-2" + FS + "FooDepr.html")).exists()) {
throw new Error("Test Fails: FooDepr should not be" +
"generated as it is deprecated.");
} else {
System.out.println("Test passes: FooDepr.html not found.");
}
tester.printSummary();
}
/**
* {@inheritDoc}
*/
public String getBugId() {
return BUG_ID;
}
/**
* {@inheritDoc}
*/
public String getBugName() {
return getClass().getName();
}
}

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2011, 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 pkg;
public class A {
/** Test constant. */
public static final String DEMO= "y";
public static final String THIS_IS_OK= "(x)";
public String DEMO_STRING = "<Hello World>";
public A() {
}
}

View File

@ -0,0 +1,31 @@
/*
* Copyright (c) 2011, 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 class ClassUseTest1 <T extends Foo & Foo2> {
public <T extends Foo & Foo2> T method(T t) {
return null;
}
}

View File

@ -0,0 +1,36 @@
/*
* Copyright (c) 2011, 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;
import java.util.*;
/**
* Test Deprecated class
* @deprecated This class is Deprecated.
*/
public class Foo {
public void method(Vector<Object> o){}
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2011, 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 Foo2 {}

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2011, 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.
*/
/**
* Test pkg1 used.
* @deprecated This package is Deprecated.
*/
package pkg1;

View File

@ -37,8 +37,7 @@ public class TestSubTitle extends JavadocTester {
private static final String BUG_ID = "7010342";
private static final String[][] TEST = {
{BUG_ID + FS + "pkg" + FS + "package-summary.html",
"<div class=\"subTitle\">" + NL + "<div class=\"block\">This is the " +
"description of package pkg.</div>" + NL + "</div>"
"<div class=\"block\">This is the description of package pkg.</div>"
},
{BUG_ID + FS + "pkg" + FS + "C.html",
"<div class=\"subTitle\">pkg</div>"