feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,988 @@
/*
* Copyright (c) 2012, 2016, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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 com.sun.tools.doclint;
import java.io.IOException;
import java.io.StringWriter;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Deque;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Name;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.tools.Diagnostic.Kind;
import javax.tools.JavaFileObject;
import com.sun.source.doctree.AttributeTree;
import com.sun.source.doctree.AuthorTree;
import com.sun.source.doctree.DocCommentTree;
import com.sun.source.doctree.DocRootTree;
import com.sun.source.doctree.DocTree;
import com.sun.source.doctree.EndElementTree;
import com.sun.source.doctree.EntityTree;
import com.sun.source.doctree.ErroneousTree;
import com.sun.source.doctree.IdentifierTree;
import com.sun.source.doctree.InheritDocTree;
import com.sun.source.doctree.LinkTree;
import com.sun.source.doctree.LiteralTree;
import com.sun.source.doctree.ParamTree;
import com.sun.source.doctree.ReferenceTree;
import com.sun.source.doctree.ReturnTree;
import com.sun.source.doctree.SerialDataTree;
import com.sun.source.doctree.SerialFieldTree;
import com.sun.source.doctree.SinceTree;
import com.sun.source.doctree.StartElementTree;
import com.sun.source.doctree.TextTree;
import com.sun.source.doctree.ThrowsTree;
import com.sun.source.doctree.UnknownBlockTagTree;
import com.sun.source.doctree.UnknownInlineTagTree;
import com.sun.source.doctree.ValueTree;
import com.sun.source.doctree.VersionTree;
import com.sun.source.util.DocTreePath;
import com.sun.source.util.DocTreePathScanner;
import com.sun.source.util.TreePath;
import com.sun.tools.doclint.HtmlTag.AttrKind;
import com.sun.tools.javac.tree.DocPretty;
import com.sun.tools.javac.util.StringUtils;
import static com.sun.tools.doclint.Messages.Group.*;
/**
* Validate a doc comment.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own
* risk. This code and its internal interfaces are subject to change
* or deletion without notice.</b></p>
*/
public class Checker extends DocTreePathScanner<Void, Void> {
final Env env;
Set<Element> foundParams = new HashSet<>();
Set<TypeMirror> foundThrows = new HashSet<>();
Map<Element, Set<String>> foundAnchors = new HashMap<>();
boolean foundInheritDoc = false;
boolean foundReturn = false;
public enum Flag {
TABLE_HAS_CAPTION,
HAS_ELEMENT,
HAS_INLINE_TAG,
HAS_TEXT,
REPORTED_BAD_INLINE
}
static class TagStackItem {
final DocTree tree; // typically, but not always, StartElementTree
final HtmlTag tag;
final Set<HtmlTag.Attr> attrs;
final Set<Flag> flags;
TagStackItem(DocTree tree, HtmlTag tag) {
this.tree = tree;
this.tag = tag;
attrs = EnumSet.noneOf(HtmlTag.Attr.class);
flags = EnumSet.noneOf(Flag.class);
}
@Override
public String toString() {
return String.valueOf(tag);
}
}
private final Deque<TagStackItem> tagStack; // TODO: maybe want to record starting tree as well
private HtmlTag currHeaderTag;
private final int implicitHeaderLevel;
// <editor-fold defaultstate="collapsed" desc="Top level">
Checker(Env env) {
env.getClass();
this.env = env;
tagStack = new LinkedList<>();
implicitHeaderLevel = env.implicitHeaderLevel;
}
public Void scan(DocCommentTree tree, TreePath p) {
env.setCurrent(p, tree);
boolean isOverridingMethod = !env.currOverriddenMethods.isEmpty();
if (p.getLeaf() == p.getCompilationUnit()) {
// If p points to a compilation unit, the implied declaration is the
// package declaration (if any) for the compilation unit.
// Handle this case specially, because doc comments are only
// expected in package-info files.
JavaFileObject fo = p.getCompilationUnit().getSourceFile();
boolean isPkgInfo = fo.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE);
if (tree == null) {
if (isPkgInfo)
reportMissing("dc.missing.comment");
return null;
} else {
if (!isPkgInfo)
reportReference("dc.unexpected.comment");
}
} else {
if (tree == null) {
if (!isSynthetic() && !isOverridingMethod)
reportMissing("dc.missing.comment");
return null;
}
}
tagStack.clear();
currHeaderTag = null;
foundParams.clear();
foundThrows.clear();
foundInheritDoc = false;
foundReturn = false;
scan(new DocTreePath(p, tree), null);
if (!isOverridingMethod) {
switch (env.currElement.getKind()) {
case METHOD:
case CONSTRUCTOR: {
ExecutableElement ee = (ExecutableElement) env.currElement;
checkParamsDocumented(ee.getTypeParameters());
checkParamsDocumented(ee.getParameters());
switch (ee.getReturnType().getKind()) {
case VOID:
case NONE:
break;
default:
if (!foundReturn
&& !foundInheritDoc
&& !env.types.isSameType(ee.getReturnType(), env.java_lang_Void)) {
reportMissing("dc.missing.return");
}
}
checkThrowsDocumented(ee.getThrownTypes());
}
}
}
return null;
}
private void reportMissing(String code, Object... args) {
env.messages.report(MISSING, Kind.WARNING, env.currPath.getLeaf(), code, args);
}
private void reportReference(String code, Object... args) {
env.messages.report(REFERENCE, Kind.WARNING, env.currPath.getLeaf(), code, args);
}
@Override
public Void visitDocComment(DocCommentTree tree, Void ignore) {
super.visitDocComment(tree, ignore);
for (TagStackItem tsi: tagStack) {
warnIfEmpty(tsi, null);
if (tsi.tree.getKind() == DocTree.Kind.START_ELEMENT
&& tsi.tag.endKind == HtmlTag.EndKind.REQUIRED) {
StartElementTree t = (StartElementTree) tsi.tree;
env.messages.error(HTML, t, "dc.tag.not.closed", t.getName());
}
}
return null;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Text and entities.">
@Override
public Void visitText(TextTree tree, Void ignore) {
if (hasNonWhitespace(tree)) {
checkAllowsText(tree);
markEnclosingTag(Flag.HAS_TEXT);
}
return null;
}
@Override
public Void visitEntity(EntityTree tree, Void ignore) {
checkAllowsText(tree);
markEnclosingTag(Flag.HAS_TEXT);
String name = tree.getName().toString();
if (name.startsWith("#")) {
int v = StringUtils.toLowerCase(name).startsWith("#x")
? Integer.parseInt(name.substring(2), 16)
: Integer.parseInt(name.substring(1), 10);
if (!Entity.isValid(v)) {
env.messages.error(HTML, tree, "dc.entity.invalid", name);
}
} else if (!Entity.isValid(name)) {
env.messages.error(HTML, tree, "dc.entity.invalid", name);
}
return null;
}
void checkAllowsText(DocTree tree) {
TagStackItem top = tagStack.peek();
if (top != null
&& top.tree.getKind() == DocTree.Kind.START_ELEMENT
&& !top.tag.acceptsText()) {
if (top.flags.add(Flag.REPORTED_BAD_INLINE)) {
env.messages.error(HTML, tree, "dc.text.not.allowed",
((StartElementTree) top.tree).getName());
}
}
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="HTML elements">
@Override
public Void visitStartElement(StartElementTree tree, Void ignore) {
final Name treeName = tree.getName();
final HtmlTag t = HtmlTag.get(treeName);
if (t == null) {
env.messages.error(HTML, tree, "dc.tag.unknown", treeName);
} else {
boolean done = false;
for (TagStackItem tsi: tagStack) {
if (tsi.tag.accepts(t)) {
while (tagStack.peek() != tsi) {
warnIfEmpty(tagStack.peek(), null);
tagStack.pop();
}
done = true;
break;
} else if (tsi.tag.endKind != HtmlTag.EndKind.OPTIONAL) {
done = true;
break;
}
}
if (!done && HtmlTag.BODY.accepts(t)) {
while (!tagStack.isEmpty()) {
warnIfEmpty(tagStack.peek(), null);
tagStack.pop();
}
}
markEnclosingTag(Flag.HAS_ELEMENT);
checkStructure(tree, t);
// tag specific checks
switch (t) {
// check for out of sequence headers, such as <h1>...</h1> <h3>...</h3>
case H1: case H2: case H3: case H4: case H5: case H6:
checkHeader(tree, t);
break;
}
if (t.flags.contains(HtmlTag.Flag.NO_NEST)) {
for (TagStackItem i: tagStack) {
if (t == i.tag) {
env.messages.warning(HTML, tree, "dc.tag.nested.not.allowed", treeName);
break;
}
}
}
}
// check for self closing tags, such as <a id="name"/>
if (tree.isSelfClosing()) {
env.messages.error(HTML, tree, "dc.tag.self.closing", treeName);
}
try {
TagStackItem parent = tagStack.peek();
TagStackItem top = new TagStackItem(tree, t);
tagStack.push(top);
super.visitStartElement(tree, ignore);
// handle attributes that may or may not have been found in start element
if (t != null) {
switch (t) {
case CAPTION:
if (parent != null && parent.tag == HtmlTag.TABLE)
parent.flags.add(Flag.TABLE_HAS_CAPTION);
break;
case IMG:
if (!top.attrs.contains(HtmlTag.Attr.ALT))
env.messages.error(ACCESSIBILITY, tree, "dc.no.alt.attr.for.image");
break;
}
}
return null;
} finally {
if (t == null || t.endKind == HtmlTag.EndKind.NONE)
tagStack.pop();
}
}
private void checkStructure(StartElementTree tree, HtmlTag t) {
Name treeName = tree.getName();
TagStackItem top = tagStack.peek();
switch (t.blockType) {
case BLOCK:
if (top == null || top.tag.accepts(t))
return;
switch (top.tree.getKind()) {
case START_ELEMENT: {
if (top.tag.blockType == HtmlTag.BlockType.INLINE) {
Name name = ((StartElementTree) top.tree).getName();
env.messages.error(HTML, tree, "dc.tag.not.allowed.inline.element",
treeName, name);
return;
}
}
break;
case LINK:
case LINK_PLAIN: {
String name = top.tree.getKind().tagName;
env.messages.error(HTML, tree, "dc.tag.not.allowed.inline.tag",
treeName, name);
return;
}
}
break;
case INLINE:
if (top == null || top.tag.accepts(t))
return;
break;
case LIST_ITEM:
case TABLE_ITEM:
if (top != null) {
// reset this flag so subsequent bad inline content gets reported
top.flags.remove(Flag.REPORTED_BAD_INLINE);
if (top.tag.accepts(t))
return;
}
break;
case OTHER:
switch (t) {
case SCRIPT:
// <script> may or may not be allowed, depending on --allow-script-in-comments
// but we allow it here, and rely on a separate scanner to detect all uses
// of JavaScript, including <script> tags, and use in attributes, etc.
break;
default:
env.messages.error(HTML, tree, "dc.tag.not.allowed", treeName);
}
return;
}
env.messages.error(HTML, tree, "dc.tag.not.allowed.here", treeName);
}
private void checkHeader(StartElementTree tree, HtmlTag tag) {
// verify the new tag
if (getHeaderLevel(tag) > getHeaderLevel(currHeaderTag) + 1) {
if (currHeaderTag == null) {
env.messages.error(ACCESSIBILITY, tree, "dc.tag.header.sequence.1", tag);
} else {
env.messages.error(ACCESSIBILITY, tree, "dc.tag.header.sequence.2",
tag, currHeaderTag);
}
}
currHeaderTag = tag;
}
private int getHeaderLevel(HtmlTag tag) {
if (tag == null)
return implicitHeaderLevel;
switch (tag) {
case H1: return 1;
case H2: return 2;
case H3: return 3;
case H4: return 4;
case H5: return 5;
case H6: return 6;
default: throw new IllegalArgumentException();
}
}
@Override
public Void visitEndElement(EndElementTree tree, Void ignore) {
final Name treeName = tree.getName();
final HtmlTag t = HtmlTag.get(treeName);
if (t == null) {
env.messages.error(HTML, tree, "dc.tag.unknown", treeName);
} else if (t.endKind == HtmlTag.EndKind.NONE) {
env.messages.error(HTML, tree, "dc.tag.end.not.permitted", treeName);
} else {
boolean done = false;
while (!tagStack.isEmpty()) {
TagStackItem top = tagStack.peek();
if (t == top.tag) {
switch (t) {
case TABLE:
if (!top.attrs.contains(HtmlTag.Attr.SUMMARY)
&& !top.flags.contains(Flag.TABLE_HAS_CAPTION)) {
env.messages.error(ACCESSIBILITY, tree,
"dc.no.summary.or.caption.for.table");
}
}
warnIfEmpty(top, tree);
tagStack.pop();
done = true;
break;
} else if (top.tag == null || top.tag.endKind != HtmlTag.EndKind.REQUIRED) {
tagStack.pop();
} else {
boolean found = false;
for (TagStackItem si: tagStack) {
if (si.tag == t) {
found = true;
break;
}
}
if (found && top.tree.getKind() == DocTree.Kind.START_ELEMENT) {
env.messages.error(HTML, top.tree, "dc.tag.start.unmatched",
((StartElementTree) top.tree).getName());
tagStack.pop();
} else {
env.messages.error(HTML, tree, "dc.tag.end.unexpected", treeName);
done = true;
break;
}
}
}
if (!done && tagStack.isEmpty()) {
env.messages.error(HTML, tree, "dc.tag.end.unexpected", treeName);
}
}
return super.visitEndElement(tree, ignore);
}
void warnIfEmpty(TagStackItem tsi, DocTree endTree) {
if (tsi.tag != null && tsi.tree instanceof StartElementTree) {
if (tsi.tag.flags.contains(HtmlTag.Flag.EXPECT_CONTENT)
&& !tsi.flags.contains(Flag.HAS_TEXT)
&& !tsi.flags.contains(Flag.HAS_ELEMENT)
&& !tsi.flags.contains(Flag.HAS_INLINE_TAG)) {
DocTree tree = (endTree != null) ? endTree : tsi.tree;
Name treeName = ((StartElementTree) tsi.tree).getName();
env.messages.warning(HTML, tree, "dc.tag.empty", treeName);
}
}
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="HTML attributes">
@Override @SuppressWarnings("fallthrough")
public Void visitAttribute(AttributeTree tree, Void ignore) {
HtmlTag currTag = tagStack.peek().tag;
if (currTag != null) {
Name name = tree.getName();
HtmlTag.Attr attr = currTag.getAttr(name);
if (attr != null) {
boolean first = tagStack.peek().attrs.add(attr);
if (!first)
env.messages.error(HTML, tree, "dc.attr.repeated", name);
}
// for now, doclint allows all attribute names beginning with "on" as event handler names,
// without checking the validity or applicability of the name
if (!name.toString().startsWith("on")) {
AttrKind k = currTag.getAttrKind(name);
switch (k) {
case OK:
break;
case INVALID:
env.messages.error(HTML, tree, "dc.attr.unknown", name);
break;
case OBSOLETE:
env.messages.warning(ACCESSIBILITY, tree, "dc.attr.obsolete", name);
break;
case USE_CSS:
env.messages.warning(ACCESSIBILITY, tree, "dc.attr.obsolete.use.css", name);
break;
}
}
if (attr != null) {
switch (attr) {
case NAME:
if (currTag != HtmlTag.A) {
break;
}
// fallthrough
case ID:
String value = getAttrValue(tree);
if (value == null) {
env.messages.error(HTML, tree, "dc.anchor.value.missing");
} else {
if (!validName.matcher(value).matches()) {
env.messages.error(HTML, tree, "dc.invalid.anchor", value);
}
if (!checkAnchor(value)) {
env.messages.error(HTML, tree, "dc.anchor.already.defined", value);
}
}
break;
case HREF:
if (currTag == HtmlTag.A) {
String v = getAttrValue(tree);
if (v == null || v.isEmpty()) {
env.messages.error(HTML, tree, "dc.attr.lacks.value");
} else {
Matcher m = docRoot.matcher(v);
if (m.matches()) {
String rest = m.group(2);
if (!rest.isEmpty())
checkURI(tree, rest);
} else {
checkURI(tree, v);
}
}
}
break;
case VALUE:
if (currTag == HtmlTag.LI) {
String v = getAttrValue(tree);
if (v == null || v.isEmpty()) {
env.messages.error(HTML, tree, "dc.attr.lacks.value");
} else if (!validNumber.matcher(v).matches()) {
env.messages.error(HTML, tree, "dc.attr.not.number");
}
}
break;
}
}
}
// TODO: basic check on value
return super.visitAttribute(tree, ignore);
}
private boolean checkAnchor(String name) {
Element e = getEnclosingPackageOrClass(env.currElement);
if (e == null)
return true;
Set<String> set = foundAnchors.get(e);
if (set == null)
foundAnchors.put(e, set = new HashSet<>());
return set.add(name);
}
private Element getEnclosingPackageOrClass(Element e) {
while (e != null) {
switch (e.getKind()) {
case CLASS:
case ENUM:
case INTERFACE:
case PACKAGE:
return e;
default:
e = e.getEnclosingElement();
}
}
return e;
}
// http://www.w3.org/TR/html401/types.html#type-name
private static final Pattern validName = Pattern.compile("[A-Za-z][A-Za-z0-9-_:.]*");
private static final Pattern validNumber = Pattern.compile("-?[0-9]+");
// pattern to remove leading {@docRoot}/?
private static final Pattern docRoot = Pattern.compile("(?i)(\\{@docRoot *\\}/?)?(.*)");
private String getAttrValue(AttributeTree tree) {
if (tree.getValue() == null)
return null;
StringWriter sw = new StringWriter();
try {
new DocPretty(sw).print(tree.getValue());
} catch (IOException e) {
// cannot happen
}
// ignore potential use of entities for now
return sw.toString();
}
private void checkURI(AttributeTree tree, String uri) {
// allow URIs beginning with javascript:, which would otherwise be rejected by the URI API.
if (uri.startsWith("javascript:"))
return;
try {
URI u = new URI(uri);
} catch (URISyntaxException e) {
env.messages.error(HTML, tree, "dc.invalid.uri", uri);
}
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="javadoc tags">
@Override
public Void visitAuthor(AuthorTree tree, Void ignore) {
warnIfEmpty(tree, tree.getName());
return super.visitAuthor(tree, ignore);
}
@Override
public Void visitDocRoot(DocRootTree tree, Void ignore) {
markEnclosingTag(Flag.HAS_INLINE_TAG);
return super.visitDocRoot(tree, ignore);
}
@Override
public Void visitInheritDoc(InheritDocTree tree, Void ignore) {
markEnclosingTag(Flag.HAS_INLINE_TAG);
// TODO: verify on overridden method
foundInheritDoc = true;
return super.visitInheritDoc(tree, ignore);
}
@Override
public Void visitLink(LinkTree tree, Void ignore) {
markEnclosingTag(Flag.HAS_INLINE_TAG);
// simulate inline context on tag stack
HtmlTag t = (tree.getKind() == DocTree.Kind.LINK)
? HtmlTag.CODE : HtmlTag.SPAN;
tagStack.push(new TagStackItem(tree, t));
try {
return super.visitLink(tree, ignore);
} finally {
tagStack.pop();
}
}
@Override
public Void visitLiteral(LiteralTree tree, Void ignore) {
markEnclosingTag(Flag.HAS_INLINE_TAG);
if (tree.getKind() == DocTree.Kind.CODE) {
for (TagStackItem tsi: tagStack) {
if (tsi.tag == HtmlTag.CODE) {
env.messages.warning(HTML, tree, "dc.tag.code.within.code");
break;
}
}
}
return super.visitLiteral(tree, ignore);
}
@Override
@SuppressWarnings("fallthrough")
public Void visitParam(ParamTree tree, Void ignore) {
boolean typaram = tree.isTypeParameter();
IdentifierTree nameTree = tree.getName();
Element paramElement = nameTree != null ? env.trees.getElement(new DocTreePath(getCurrentPath(), nameTree)) : null;
if (paramElement == null) {
switch (env.currElement.getKind()) {
case CLASS: case INTERFACE: {
if (!typaram) {
env.messages.error(REFERENCE, tree, "dc.invalid.param");
break;
}
}
case METHOD: case CONSTRUCTOR: {
env.messages.error(REFERENCE, nameTree, "dc.param.name.not.found");
break;
}
default:
env.messages.error(REFERENCE, tree, "dc.invalid.param");
break;
}
} else {
foundParams.add(paramElement);
}
warnIfEmpty(tree, tree.getDescription());
return super.visitParam(tree, ignore);
}
private void checkParamsDocumented(List<? extends Element> list) {
if (foundInheritDoc)
return;
for (Element e: list) {
if (!foundParams.contains(e)) {
CharSequence paramName = (e.getKind() == ElementKind.TYPE_PARAMETER)
? "<" + e.getSimpleName() + ">"
: e.getSimpleName();
reportMissing("dc.missing.param", paramName);
}
}
}
@Override
public Void visitReference(ReferenceTree tree, Void ignore) {
String sig = tree.getSignature();
if (sig.contains("<") || sig.contains(">"))
env.messages.error(REFERENCE, tree, "dc.type.arg.not.allowed");
Element e = env.trees.getElement(getCurrentPath());
if (e == null)
env.messages.error(REFERENCE, tree, "dc.ref.not.found");
return super.visitReference(tree, ignore);
}
@Override
public Void visitReturn(ReturnTree tree, Void ignore) {
Element e = env.trees.getElement(env.currPath);
if (e.getKind() != ElementKind.METHOD
|| ((ExecutableElement) e).getReturnType().getKind() == TypeKind.VOID)
env.messages.error(REFERENCE, tree, "dc.invalid.return");
foundReturn = true;
warnIfEmpty(tree, tree.getDescription());
return super.visitReturn(tree, ignore);
}
@Override
public Void visitSerialData(SerialDataTree tree, Void ignore) {
warnIfEmpty(tree, tree.getDescription());
return super.visitSerialData(tree, ignore);
}
@Override
public Void visitSerialField(SerialFieldTree tree, Void ignore) {
warnIfEmpty(tree, tree.getDescription());
return super.visitSerialField(tree, ignore);
}
@Override
public Void visitSince(SinceTree tree, Void ignore) {
warnIfEmpty(tree, tree.getBody());
return super.visitSince(tree, ignore);
}
@Override
public Void visitThrows(ThrowsTree tree, Void ignore) {
ReferenceTree exName = tree.getExceptionName();
Element ex = env.trees.getElement(new DocTreePath(getCurrentPath(), exName));
if (ex == null) {
env.messages.error(REFERENCE, tree, "dc.ref.not.found");
} else if (isThrowable(ex.asType())) {
switch (env.currElement.getKind()) {
case CONSTRUCTOR:
case METHOD:
if (isCheckedException(ex.asType())) {
ExecutableElement ee = (ExecutableElement) env.currElement;
checkThrowsDeclared(exName, ex.asType(), ee.getThrownTypes());
}
break;
default:
env.messages.error(REFERENCE, tree, "dc.invalid.throws");
}
} else {
env.messages.error(REFERENCE, tree, "dc.invalid.throws");
}
warnIfEmpty(tree, tree.getDescription());
return scan(tree.getDescription(), ignore);
}
private boolean isThrowable(TypeMirror tm) {
switch (tm.getKind()) {
case DECLARED:
case TYPEVAR:
return env.types.isAssignable(tm, env.java_lang_Throwable);
}
return false;
}
private void checkThrowsDeclared(ReferenceTree tree, TypeMirror t, List<? extends TypeMirror> list) {
boolean found = false;
for (TypeMirror tl : list) {
if (env.types.isAssignable(t, tl)) {
foundThrows.add(tl);
found = true;
}
}
if (!found)
env.messages.error(REFERENCE, tree, "dc.exception.not.thrown", t);
}
private void checkThrowsDocumented(List<? extends TypeMirror> list) {
if (foundInheritDoc)
return;
for (TypeMirror tl: list) {
if (isCheckedException(tl) && !foundThrows.contains(tl))
reportMissing("dc.missing.throws", tl);
}
}
@Override
public Void visitUnknownBlockTag(UnknownBlockTagTree tree, Void ignore) {
checkUnknownTag(tree, tree.getTagName());
return super.visitUnknownBlockTag(tree, ignore);
}
@Override
public Void visitUnknownInlineTag(UnknownInlineTagTree tree, Void ignore) {
checkUnknownTag(tree, tree.getTagName());
return super.visitUnknownInlineTag(tree, ignore);
}
private void checkUnknownTag(DocTree tree, String tagName) {
if (env.customTags != null && !env.customTags.contains(tagName))
env.messages.error(SYNTAX, tree, "dc.tag.unknown", tagName);
}
@Override
public Void visitValue(ValueTree tree, Void ignore) {
ReferenceTree ref = tree.getReference();
if (ref == null || ref.getSignature().isEmpty()) {
if (!isConstant(env.currElement))
env.messages.error(REFERENCE, tree, "dc.value.not.allowed.here");
} else {
Element e = env.trees.getElement(new DocTreePath(getCurrentPath(), ref));
if (!isConstant(e))
env.messages.error(REFERENCE, tree, "dc.value.not.a.constant");
}
markEnclosingTag(Flag.HAS_INLINE_TAG);
return super.visitValue(tree, ignore);
}
private boolean isConstant(Element e) {
if (e == null)
return false;
switch (e.getKind()) {
case FIELD:
Object value = ((VariableElement) e).getConstantValue();
return (value != null); // can't distinguish "not a constant" from "constant is null"
default:
return false;
}
}
@Override
public Void visitVersion(VersionTree tree, Void ignore) {
warnIfEmpty(tree, tree.getBody());
return super.visitVersion(tree, ignore);
}
@Override
public Void visitErroneous(ErroneousTree tree, Void ignore) {
env.messages.error(SYNTAX, tree, null, tree.getDiagnostic().getMessage(null));
return null;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Utility methods">
private boolean isCheckedException(TypeMirror t) {
return !(env.types.isAssignable(t, env.java_lang_Error)
|| env.types.isAssignable(t, env.java_lang_RuntimeException));
}
private boolean isSynthetic() {
switch (env.currElement.getKind()) {
case CONSTRUCTOR:
// A synthetic default constructor has the same pos as the
// enclosing class
TreePath p = env.currPath;
return env.getPos(p) == env.getPos(p.getParentPath());
}
return false;
}
void markEnclosingTag(Flag flag) {
TagStackItem top = tagStack.peek();
if (top != null)
top.flags.add(flag);
}
String toString(TreePath p) {
StringBuilder sb = new StringBuilder("TreePath[");
toString(p, sb);
sb.append("]");
return sb.toString();
}
void toString(TreePath p, StringBuilder sb) {
TreePath parent = p.getParentPath();
if (parent != null) {
toString(parent, sb);
sb.append(",");
}
sb.append(p.getLeaf().getKind()).append(":").append(env.getPos(p)).append(":S").append(env.getStartPos(p));
}
void warnIfEmpty(DocTree tree, List<? extends DocTree> list) {
for (DocTree d: list) {
switch (d.getKind()) {
case TEXT:
if (hasNonWhitespace((TextTree) d))
return;
break;
default:
return;
}
}
env.messages.warning(SYNTAX, tree, "dc.empty", tree.getKind().tagName);
}
boolean hasNonWhitespace(TextTree tree) {
String s = tree.getBody();
for (int i = 0; i < s.length(); i++) {
if (!Character.isWhitespace(s.charAt(i)))
return true;
}
return false;
}
// </editor-fold>
}

View File

@@ -0,0 +1,379 @@
/*
* Copyright (c) 2012, 2013, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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 com.sun.tools.doclint;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Set;
import javax.lang.model.element.Name;
import javax.tools.JavaFileObject;
import javax.tools.StandardLocation;
import com.sun.source.doctree.DocCommentTree;
import com.sun.source.tree.ClassTree;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.MethodTree;
import com.sun.source.tree.Tree;
import com.sun.source.tree.VariableTree;
import com.sun.source.util.JavacTask;
import com.sun.source.util.Plugin;
import com.sun.source.util.TaskEvent;
import com.sun.source.util.TaskListener;
import com.sun.source.util.TreePath;
import com.sun.source.util.TreePathScanner;
import com.sun.tools.javac.api.JavacTaskImpl;
import com.sun.tools.javac.api.JavacTool;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.main.JavaCompiler;
import com.sun.tools.javac.util.Context;
/**
* Multi-function entry point for the doc check utility.
*
* This class can be invoked in the following ways:
* <ul>
* <li>From the command line
* <li>From javac, as a plugin
* <li>Directly, via a simple API
* </ul>
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own
* risk. This code and its internal interfaces are subject to change
* or deletion without notice.</b></p>
*/
public class DocLint implements Plugin {
public static final String XMSGS_OPTION = "-Xmsgs";
public static final String XMSGS_CUSTOM_PREFIX = "-Xmsgs:";
private static final String STATS = "-stats";
public static final String XIMPLICIT_HEADERS = "-XimplicitHeaders:";
public static final String XCUSTOM_TAGS_PREFIX = "-XcustomTags:";
public static final String TAGS_SEPARATOR = ",";
// <editor-fold defaultstate="collapsed" desc="Command-line entry point">
public static void main(String... args) {
DocLint dl = new DocLint();
try {
dl.run(args);
} catch (BadArgs e) {
System.err.println(e.getMessage());
System.exit(1);
} catch (IOException e) {
System.err.println(dl.localize("dc.main.ioerror", e.getLocalizedMessage()));
System.exit(2);
}
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Simple API">
public class BadArgs extends Exception {
private static final long serialVersionUID = 0;
BadArgs(String code, Object... args) {
super(localize(code, args));
this.code = code;
this.args = args;
}
final String code;
final Object[] args;
}
/**
* Simple API entry point.
*/
public void run(String... args) throws BadArgs, IOException {
PrintWriter out = new PrintWriter(System.out);
try {
run(out, args);
} finally {
out.flush();
}
}
public void run(PrintWriter out, String... args) throws BadArgs, IOException {
env = new Env();
processArgs(args);
if (needHelp)
showHelp(out);
if (javacFiles.isEmpty()) {
if (!needHelp)
out.println(localize("dc.main.no.files.given"));
}
JavacTool tool = JavacTool.create();
JavacFileManager fm = new JavacFileManager(new Context(), false, null);
fm.setSymbolFileEnabled(false);
fm.setLocation(StandardLocation.PLATFORM_CLASS_PATH, javacBootClassPath);
fm.setLocation(StandardLocation.CLASS_PATH, javacClassPath);
fm.setLocation(StandardLocation.SOURCE_PATH, javacSourcePath);
JavacTask task = tool.getTask(out, fm, null, javacOpts, null,
fm.getJavaFileObjectsFromFiles(javacFiles));
Iterable<? extends CompilationUnitTree> units = task.parse();
((JavacTaskImpl) task).enter();
env.init(task);
checker = new Checker(env);
DeclScanner ds = new DeclScanner() {
@Override
void visitDecl(Tree tree, Name name) {
TreePath p = getCurrentPath();
DocCommentTree dc = env.trees.getDocCommentTree(p);
checker.scan(dc, p);
}
};
ds.scan(units, null);
reportStats(out);
Context ctx = ((JavacTaskImpl) task).getContext();
JavaCompiler c = JavaCompiler.instance(ctx);
c.printCount("error", c.errorCount());
c.printCount("warn", c.warningCount());
}
void processArgs(String... args) throws BadArgs {
javacOpts = new ArrayList<>();
javacFiles = new ArrayList<>();
if (args.length == 0)
needHelp = true;
for (int i = 0; i < args.length; i++) {
String arg = args[i];
if (arg.matches("-Xmax(errs|warns)") && i + 1 < args.length) {
if (args[++i].matches("[0-9]+")) {
javacOpts.add(arg);
javacOpts.add(args[i]);
} else {
throw new BadArgs("dc.bad.value.for.option", arg, args[i]);
}
} else if (arg.equals(STATS)) {
env.messages.setStatsEnabled(true);
} else if (arg.equals("-bootclasspath") && i + 1 < args.length) {
javacBootClassPath = splitPath(args[++i]);
} else if (arg.equals("-classpath") && i + 1 < args.length) {
javacClassPath = splitPath(args[++i]);
} else if (arg.equals("-cp") && i + 1 < args.length) {
javacClassPath = splitPath(args[++i]);
} else if (arg.equals("-sourcepath") && i + 1 < args.length) {
javacSourcePath = splitPath(args[++i]);
} else if (arg.equals(XMSGS_OPTION)) {
env.messages.setOptions(null);
} else if (arg.startsWith(XMSGS_CUSTOM_PREFIX)) {
env.messages.setOptions(arg.substring(arg.indexOf(":") + 1));
} else if (arg.startsWith(XCUSTOM_TAGS_PREFIX)) {
env.setCustomTags(arg.substring(arg.indexOf(":") + 1));
} else if (arg.equals("-h") || arg.equals("-help") || arg.equals("--help")
|| arg.equals("-?") || arg.equals("-usage")) {
needHelp = true;
} else if (arg.startsWith("-")) {
throw new BadArgs("dc.bad.option", arg);
} else {
while (i < args.length)
javacFiles.add(new File(args[i++]));
}
}
}
void showHelp(PrintWriter out) {
String msg = localize("dc.main.usage");
for (String line: msg.split("\n"))
out.println(line);
}
List<File> splitPath(String path) {
List<File> files = new ArrayList<>();
for (String f: path.split(File.pathSeparator)) {
if (f.length() > 0)
files.add(new File(f));
}
return files;
}
List<File> javacBootClassPath;
List<File> javacClassPath;
List<File> javacSourcePath;
List<String> javacOpts;
List<File> javacFiles;
boolean needHelp = false;
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="javac Plugin">
@Override
public String getName() {
return "doclint";
}
@Override
public void init(JavacTask task, String... args) {
init(task, args, true);
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Embedding API">
public void init(JavacTask task, String[] args, boolean addTaskListener) {
env = new Env();
for (int i = 0; i < args.length; i++) {
String arg = args[i];
if (arg.equals(XMSGS_OPTION)) {
env.messages.setOptions(null);
} else if (arg.startsWith(XMSGS_CUSTOM_PREFIX)) {
env.messages.setOptions(arg.substring(arg.indexOf(":") + 1));
} else if (arg.matches(XIMPLICIT_HEADERS + "[1-6]")) {
char ch = arg.charAt(arg.length() - 1);
env.setImplicitHeaders(Character.digit(ch, 10));
} else if (arg.startsWith(XCUSTOM_TAGS_PREFIX)) {
env.setCustomTags(arg.substring(arg.indexOf(":") + 1));
} else
throw new IllegalArgumentException(arg);
}
env.init(task);
checker = new Checker(env);
if (addTaskListener) {
final DeclScanner ds = new DeclScanner() {
@Override
void visitDecl(Tree tree, Name name) {
TreePath p = getCurrentPath();
DocCommentTree dc = env.trees.getDocCommentTree(p);
checker.scan(dc, p);
}
};
TaskListener tl = new TaskListener() {
@Override
public void started(TaskEvent e) {
switch (e.getKind()) {
case ANALYZE:
CompilationUnitTree tree;
while ((tree = todo.poll()) != null)
ds.scan(tree, null);
break;
}
}
@Override
public void finished(TaskEvent e) {
switch (e.getKind()) {
case PARSE:
todo.add(e.getCompilationUnit());
break;
}
}
Queue<CompilationUnitTree> todo = new LinkedList<CompilationUnitTree>();
};
task.addTaskListener(tl);
}
}
public void scan(TreePath p) {
DocCommentTree dc = env.trees.getDocCommentTree(p);
checker.scan(dc, p);
}
public void reportStats(PrintWriter out) {
env.messages.reportStats(out);
}
// </editor-fold>
Env env;
Checker checker;
public static boolean isValidOption(String opt) {
if (opt.equals(XMSGS_OPTION))
return true;
if (opt.startsWith(XMSGS_CUSTOM_PREFIX))
return Messages.Options.isValidOptions(opt.substring(XMSGS_CUSTOM_PREFIX.length()));
return false;
}
private String localize(String code, Object... args) {
Messages m = (env != null) ? env.messages : new Messages(null);
return m.localize(code, args);
}
// <editor-fold defaultstate="collapsed" desc="DeclScanner">
static abstract class DeclScanner extends TreePathScanner<Void, Void> {
abstract void visitDecl(Tree tree, Name name);
@Override
public Void visitCompilationUnit(CompilationUnitTree tree, Void ignore) {
if (tree.getPackageName() != null) {
visitDecl(tree, null);
}
return super.visitCompilationUnit(tree, ignore);
}
@Override
public Void visitClass(ClassTree tree, Void ignore) {
visitDecl(tree, tree.getSimpleName());
return super.visitClass(tree, ignore);
}
@Override
public Void visitMethod(MethodTree tree, Void ignore) {
visitDecl(tree, tree.getName());
//return super.visitMethod(tree, ignore);
return null;
}
@Override
public Void visitVariable(VariableTree tree, Void ignore) {
visitDecl(tree, tree.getName());
return super.visitVariable(tree, ignore);
}
}
// </editor-fold>
}

View File

@@ -0,0 +1,326 @@
/*
* Copyright (c) 2012, 2013, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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 com.sun.tools.doclint;
import java.util.HashMap;
import java.util.Map;
/**
* Table of entities defined in HTML 4.01.
*
* <p> Derived from
* <a href="http://www.w3.org/TR/html4/sgml/entities.html">Character entity references in HTML 4</a>.
*
* The name of the member follows the name of the entity,
* except when it clashes with a keyword, in which case
* it is prefixed by '_'.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own
* risk. This code and its internal interfaces are subject to change
* or deletion without notice.</b></p>
*/
public enum Entity {
nbsp(160),
iexcl(161),
cent(162),
pound(163),
curren(164),
yen(165),
brvbar(166),
sect(167),
uml(168),
copy(169),
ordf(170),
laquo(171),
not(172),
shy(173),
reg(174),
macr(175),
deg(176),
plusmn(177),
sup2(178),
sup3(179),
acute(180),
micro(181),
para(182),
middot(183),
cedil(184),
sup1(185),
ordm(186),
raquo(187),
frac14(188),
frac12(189),
frac34(190),
iquest(191),
Agrave(192),
Aacute(193),
Acirc(194),
Atilde(195),
Auml(196),
Aring(197),
AElig(198),
Ccedil(199),
Egrave(200),
Eacute(201),
Ecirc(202),
Euml(203),
Igrave(204),
Iacute(205),
Icirc(206),
Iuml(207),
ETH(208),
Ntilde(209),
Ograve(210),
Oacute(211),
Ocirc(212),
Otilde(213),
Ouml(214),
times(215),
Oslash(216),
Ugrave(217),
Uacute(218),
Ucirc(219),
Uuml(220),
Yacute(221),
THORN(222),
szlig(223),
agrave(224),
aacute(225),
acirc(226),
atilde(227),
auml(228),
aring(229),
aelig(230),
ccedil(231),
egrave(232),
eacute(233),
ecirc(234),
euml(235),
igrave(236),
iacute(237),
icirc(238),
iuml(239),
eth(240),
ntilde(241),
ograve(242),
oacute(243),
ocirc(244),
otilde(245),
ouml(246),
divide(247),
oslash(248),
ugrave(249),
uacute(250),
ucirc(251),
uuml(252),
yacute(253),
thorn(254),
yuml(255),
fnof(402),
Alpha(913),
Beta(914),
Gamma(915),
Delta(916),
Epsilon(917),
Zeta(918),
Eta(919),
Theta(920),
Iota(921),
Kappa(922),
Lambda(923),
Mu(924),
Nu(925),
Xi(926),
Omicron(927),
Pi(928),
Rho(929),
Sigma(931),
Tau(932),
Upsilon(933),
Phi(934),
Chi(935),
Psi(936),
Omega(937),
alpha(945),
beta(946),
gamma(947),
delta(948),
epsilon(949),
zeta(950),
eta(951),
theta(952),
iota(953),
kappa(954),
lambda(955),
mu(956),
nu(957),
xi(958),
omicron(959),
pi(960),
rho(961),
sigmaf(962),
sigma(963),
tau(964),
upsilon(965),
phi(966),
chi(967),
psi(968),
omega(969),
thetasym(977),
upsih(978),
piv(982),
bull(8226),
hellip(8230),
prime(8242),
Prime(8243),
oline(8254),
frasl(8260),
weierp(8472),
image(8465),
real(8476),
trade(8482),
alefsym(8501),
larr(8592),
uarr(8593),
rarr(8594),
darr(8595),
harr(8596),
crarr(8629),
lArr(8656),
uArr(8657),
rArr(8658),
dArr(8659),
hArr(8660),
forall(8704),
part(8706),
exist(8707),
empty(8709),
nabla(8711),
isin(8712),
notin(8713),
ni(8715),
prod(8719),
sum(8721),
minus(8722),
lowast(8727),
radic(8730),
prop(8733),
infin(8734),
ang(8736),
and(8743),
or(8744),
cap(8745),
cup(8746),
_int(8747),
there4(8756),
sim(8764),
cong(8773),
asymp(8776),
ne(8800),
equiv(8801),
le(8804),
ge(8805),
sub(8834),
sup(8835),
nsub(8836),
sube(8838),
supe(8839),
oplus(8853),
otimes(8855),
perp(8869),
sdot(8901),
lceil(8968),
rceil(8969),
lfloor(8970),
rfloor(8971),
lang(9001),
rang(9002),
loz(9674),
spades(9824),
clubs(9827),
hearts(9829),
diams(9830),
quot(34),
amp(38),
lt(60),
gt(62),
OElig(338),
oelig(339),
Scaron(352),
scaron(353),
Yuml(376),
circ(710),
tilde(732),
ensp(8194),
emsp(8195),
thinsp(8201),
zwnj(8204),
zwj(8205),
lrm(8206),
rlm(8207),
ndash(8211),
mdash(8212),
lsquo(8216),
rsquo(8217),
sbquo(8218),
ldquo(8220),
rdquo(8221),
bdquo(8222),
dagger(8224),
Dagger(8225),
permil(8240),
lsaquo(8249),
rsaquo(8250),
euro(8364);
int code;
private Entity(int code) {
this.code = code;
}
static boolean isValid(String name) {
return names.containsKey(name);
}
static boolean isValid(int code) {
// allow numeric codes for standard ANSI characters
return codes.containsKey(code) || ( 32 <= code && code < 2127);
}
private static final Map<String,Entity> names = new HashMap<String,Entity>();
private static final Map<Integer,Entity> codes = new HashMap<Integer,Entity>();
static {
for (Entity e: values()) {
String name = e.name();
int code = e.code;
if (name.startsWith("_")) name = name.substring(1);
names.put(name, e);
codes.put(code, e);
}
}
}

View File

@@ -0,0 +1,185 @@
/*
* Copyright (c) 2012, 2013, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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 com.sun.tools.doclint;
import java.util.Set;
import java.util.LinkedHashSet;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import com.sun.source.doctree.DocCommentTree;
import com.sun.source.util.DocTrees;
import com.sun.source.util.JavacTask;
import com.sun.source.util.SourcePositions;
import com.sun.source.util.TreePath;
import com.sun.tools.javac.model.JavacTypes;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.util.StringUtils;
/**
* Utility container for current execution environment,
* providing the current declaration and its doc comment.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own
* risk. This code and its internal interfaces are subject to change
* or deletion without notice.</b></p>
*/
public class Env {
/**
* Access kinds for declarations.
*/
public enum AccessKind {
PRIVATE,
PACKAGE,
PROTECTED,
PUBLIC;
static boolean accepts(String opt) {
for (AccessKind g: values())
if (opt.equals(StringUtils.toLowerCase(g.name()))) return true;
return false;
}
static AccessKind of(Set<Modifier> mods) {
if (mods.contains(Modifier.PUBLIC))
return AccessKind.PUBLIC;
else if (mods.contains(Modifier.PROTECTED))
return AccessKind.PROTECTED;
else if (mods.contains(Modifier.PRIVATE))
return AccessKind.PRIVATE;
else
return AccessKind.PACKAGE;
}
};
/** Message handler. */
final Messages messages;
int implicitHeaderLevel = 0;
Set<String> customTags;
// Utility classes
DocTrees trees;
Elements elements;
Types types;
// Types used when analysing doc comments.
TypeMirror java_lang_Error;
TypeMirror java_lang_RuntimeException;
TypeMirror java_lang_Throwable;
TypeMirror java_lang_Void;
/** The path for the declaration containing the comment currently being analyzed. */
TreePath currPath;
/** The element for the declaration containing the comment currently being analyzed. */
Element currElement;
/** The comment current being analyzed. */
DocCommentTree currDocComment;
/**
* The access kind of the declaration containing the comment currently being analyzed.
* This is the minimum (most restrictive) access kind of the declaration itself
* and that of its containers. For example, a public method in a private class is
* noted as private.
*/
AccessKind currAccess;
/** The set of methods, if any, that the current declaration overrides. */
Set<? extends ExecutableElement> currOverriddenMethods;
Env() {
messages = new Messages(this);
}
void init(JavacTask task) {
init(DocTrees.instance(task), task.getElements(), task.getTypes());
}
void init(DocTrees trees, Elements elements, Types types) {
this.trees = trees;
this.elements = elements;
this.types = types;
java_lang_Error = elements.getTypeElement("java.lang.Error").asType();
java_lang_RuntimeException = elements.getTypeElement("java.lang.RuntimeException").asType();
java_lang_Throwable = elements.getTypeElement("java.lang.Throwable").asType();
java_lang_Void = elements.getTypeElement("java.lang.Void").asType();
}
void setImplicitHeaders(int n) {
implicitHeaderLevel = n;
}
void setCustomTags(String cTags) {
customTags = new LinkedHashSet<String>();
for (String s : cTags.split(DocLint.TAGS_SEPARATOR)) {
if (!s.isEmpty())
customTags.add(s);
}
}
/** Set the current declaration and its doc comment. */
void setCurrent(TreePath path, DocCommentTree comment) {
currPath = path;
currDocComment = comment;
currElement = trees.getElement(currPath);
currOverriddenMethods = ((JavacTypes) types).getOverriddenMethods(currElement);
AccessKind ak = AccessKind.PUBLIC;
for (TreePath p = path; p != null; p = p.getParentPath()) {
Element e = trees.getElement(p);
if (e != null && e.getKind() != ElementKind.PACKAGE) {
ak = min(ak, AccessKind.of(e.getModifiers()));
}
}
currAccess = ak;
}
AccessKind getAccessKind() {
return currAccess;
}
long getPos(TreePath p) {
return ((JCTree) p.getLeaf()).pos;
}
long getStartPos(TreePath p) {
SourcePositions sp = trees.getSourcePositions();
return sp.getStartPosition(p.getCompilationUnit(), p.getLeaf());
}
private <T extends Comparable<T>> T min(T item1, T item2) {
return (item1 == null) ? item2
: (item2 == null) ? item1
: item1.compareTo(item2) <= 0 ? item1 : item2;
}
}

View File

@@ -0,0 +1,465 @@
/*
* Copyright (c) 2010, 2016, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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 com.sun.tools.doclint;
import java.util.Set;
import java.util.Collections;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import javax.lang.model.element.Name;
import static com.sun.tools.doclint.HtmlTag.Attr.*;
import com.sun.tools.javac.util.StringUtils;
/**
* Enum representing HTML tags.
*
* The intent of this class is to embody the semantics of W3C HTML 4.01
* to the extent supported/used by javadoc.
* In time, we may wish to transition javadoc and doclint to using HTML 5.
*
* This is derivative of com.sun.tools.doclets.formats.html.markup.HtmlTag.
* Eventually, these two should be merged back together, and possibly made
* public.
*
* @see <a href="http://www.w3.org/TR/REC-html40/">HTML 4.01 Specification</a>
* @see <a href="http://www.w3.org/TR/html5/">HTML 5 Specification</a>
* @author Bhavesh Patel
* @author Jonathan Gibbons (revised)
*/
public enum HtmlTag {
A(BlockType.INLINE, EndKind.REQUIRED,
attrs(AttrKind.OK, HREF, TARGET, NAME)),
B(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
BIG(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT)),
BLOCKQUOTE(BlockType.BLOCK, EndKind.REQUIRED,
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)),
BODY(BlockType.OTHER, EndKind.REQUIRED),
BR(BlockType.INLINE, EndKind.NONE,
attrs(AttrKind.USE_CSS, CLEAR)),
CAPTION(BlockType.TABLE_ITEM, EndKind.REQUIRED,
EnumSet.of(Flag.ACCEPTS_INLINE, Flag.EXPECT_CONTENT)),
CENTER(BlockType.BLOCK, EndKind.REQUIRED,
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)),
CITE(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
CODE(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
DD(BlockType.LIST_ITEM, EndKind.OPTIONAL,
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE, Flag.EXPECT_CONTENT)),
DFN(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
DIV(BlockType.BLOCK, EndKind.REQUIRED,
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)),
DL(BlockType.BLOCK, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT),
attrs(AttrKind.USE_CSS, COMPACT)) {
@Override
public boolean accepts(HtmlTag t) {
return (t == DT) || (t == DD);
}
},
DT(BlockType.LIST_ITEM, EndKind.OPTIONAL,
EnumSet.of(Flag.ACCEPTS_INLINE, Flag.EXPECT_CONTENT)),
EM(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.NO_NEST)),
FONT(BlockType.INLINE, EndKind.REQUIRED, // tag itself is deprecated
EnumSet.of(Flag.EXPECT_CONTENT),
attrs(AttrKind.USE_CSS, SIZE, COLOR, FACE)),
FRAME(BlockType.OTHER, EndKind.NONE),
FRAMESET(BlockType.OTHER, EndKind.REQUIRED),
H1(BlockType.BLOCK, EndKind.REQUIRED),
H2(BlockType.BLOCK, EndKind.REQUIRED),
H3(BlockType.BLOCK, EndKind.REQUIRED),
H4(BlockType.BLOCK, EndKind.REQUIRED),
H5(BlockType.BLOCK, EndKind.REQUIRED),
H6(BlockType.BLOCK, EndKind.REQUIRED),
HEAD(BlockType.OTHER, EndKind.REQUIRED),
HR(BlockType.BLOCK, EndKind.NONE,
attrs(AttrKind.OK, WIDTH)), // OK in 4.01; not allowed in 5
HTML(BlockType.OTHER, EndKind.REQUIRED),
I(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
IMG(BlockType.INLINE, EndKind.NONE,
attrs(AttrKind.OK, SRC, ALT, HEIGHT, WIDTH),
attrs(AttrKind.OBSOLETE, NAME),
attrs(AttrKind.USE_CSS, ALIGN, HSPACE, VSPACE, BORDER)),
LI(BlockType.LIST_ITEM, EndKind.OPTIONAL,
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE),
attrs(AttrKind.OK, VALUE)),
LINK(BlockType.OTHER, EndKind.NONE),
MENU(BlockType.BLOCK, EndKind.REQUIRED) {
@Override
public boolean accepts(HtmlTag t) {
return (t == LI);
}
},
META(BlockType.OTHER, EndKind.NONE),
NOFRAMES(BlockType.OTHER, EndKind.REQUIRED),
NOSCRIPT(BlockType.BLOCK, EndKind.REQUIRED),
OL(BlockType.BLOCK, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT),
attrs(AttrKind.OK, START, TYPE)) {
@Override
public boolean accepts(HtmlTag t) {
return (t == LI);
}
},
P(BlockType.BLOCK, EndKind.OPTIONAL,
EnumSet.of(Flag.EXPECT_CONTENT),
attrs(AttrKind.USE_CSS, ALIGN)),
PRE(BlockType.BLOCK, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT)) {
@Override
public boolean accepts(HtmlTag t) {
switch (t) {
case IMG: case BIG: case SMALL: case SUB: case SUP:
return false;
default:
return (t.blockType == BlockType.INLINE);
}
}
},
SCRIPT(BlockType.OTHER, EndKind.REQUIRED,
attrs(AttrKind.OK, SRC)),
SMALL(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT)),
SPAN(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT)),
STRONG(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT)),
SUB(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
SUP(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
TABLE(BlockType.BLOCK, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT),
attrs(AttrKind.OK, SUMMARY, Attr.FRAME, RULES, BORDER,
CELLPADDING, CELLSPACING, WIDTH), // width OK in 4.01; not allowed in 5
attrs(AttrKind.USE_CSS, ALIGN, BGCOLOR)) {
@Override
public boolean accepts(HtmlTag t) {
switch (t) {
case CAPTION:
case THEAD: case TBODY: case TFOOT:
case TR: // HTML 3.2
return true;
default:
return false;
}
}
},
TBODY(BlockType.TABLE_ITEM, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT),
attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN)) {
@Override
public boolean accepts(HtmlTag t) {
return (t == TR);
}
},
TD(BlockType.TABLE_ITEM, EndKind.OPTIONAL,
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE),
attrs(AttrKind.OK, COLSPAN, ROWSPAN, HEADERS, SCOPE, ABBR, AXIS,
ALIGN, CHAR, CHAROFF, VALIGN),
attrs(AttrKind.USE_CSS, WIDTH, BGCOLOR, HEIGHT, NOWRAP)),
TFOOT(BlockType.TABLE_ITEM, EndKind.REQUIRED,
attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN)) {
@Override
public boolean accepts(HtmlTag t) {
return (t == TR);
}
},
TH(BlockType.TABLE_ITEM, EndKind.OPTIONAL,
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE),
attrs(AttrKind.OK, COLSPAN, ROWSPAN, HEADERS, SCOPE, ABBR, AXIS,
ALIGN, CHAR, CHAROFF, VALIGN),
attrs(AttrKind.USE_CSS, WIDTH, BGCOLOR, HEIGHT, NOWRAP)),
THEAD(BlockType.TABLE_ITEM, EndKind.REQUIRED,
attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN)) {
@Override
public boolean accepts(HtmlTag t) {
return (t == TR);
}
},
TITLE(BlockType.OTHER, EndKind.REQUIRED),
TR(BlockType.TABLE_ITEM, EndKind.OPTIONAL,
attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN),
attrs(AttrKind.USE_CSS, BGCOLOR)) {
@Override
public boolean accepts(HtmlTag t) {
return (t == TH) || (t == TD);
}
},
TT(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
U(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
UL(BlockType.BLOCK, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT),
attrs(AttrKind.OK, COMPACT, TYPE)) { // OK in 4.01; not allowed in 5
@Override
public boolean accepts(HtmlTag t) {
return (t == LI);
}
},
VAR(BlockType.INLINE, EndKind.REQUIRED);
/**
* Enum representing the type of HTML element.
*/
public static enum BlockType {
BLOCK,
INLINE,
LIST_ITEM,
TABLE_ITEM,
OTHER;
}
/**
* Enum representing HTML end tag requirement.
*/
public static enum EndKind {
NONE,
OPTIONAL,
REQUIRED;
}
public static enum Flag {
ACCEPTS_BLOCK,
ACCEPTS_INLINE,
EXPECT_CONTENT,
NO_NEST
}
public static enum Attr {
ABBR,
ALIGN,
ALT,
AXIS,
BGCOLOR,
BORDER,
CELLSPACING,
CELLPADDING,
CHAR,
CHAROFF,
CLEAR,
CLASS,
COLOR,
COLSPAN,
COMPACT,
FACE,
FRAME,
HEADERS,
HEIGHT,
HREF,
HSPACE,
ID,
NAME,
NOWRAP,
REVERSED,
ROWSPAN,
RULES,
SCOPE,
SIZE,
SPACE,
SRC,
START,
STYLE,
SUMMARY,
TARGET,
TYPE,
VALIGN,
VALUE,
VSPACE,
WIDTH;
public String getText() {
return StringUtils.toLowerCase(name());
}
static final Map<String,Attr> index = new HashMap<String,Attr>();
static {
for (Attr t: values()) {
index.put(t.getText(), t);
}
}
}
public static enum AttrKind {
INVALID,
OBSOLETE,
USE_CSS,
OK
}
// This class exists to avoid warnings from using parameterized vararg type
// Map<Attr,AttrKind> in signature of HtmlTag constructor.
private static class AttrMap extends EnumMap<Attr,AttrKind> {
private static final long serialVersionUID = 0;
AttrMap() {
super(Attr.class);
}
}
public final BlockType blockType;
public final EndKind endKind;
public final Set<Flag> flags;
private final Map<Attr,AttrKind> attrs;
HtmlTag(BlockType blockType, EndKind endKind, AttrMap... attrMaps) {
this(blockType, endKind, Collections.<Flag>emptySet(), attrMaps);
}
HtmlTag(BlockType blockType, EndKind endKind, Set<Flag> flags, AttrMap... attrMaps) {
this.blockType = blockType;
this.endKind = endKind;
this.flags = flags;
this.attrs = new EnumMap<Attr,AttrKind>(Attr.class);
for (Map<Attr,AttrKind> m: attrMaps)
this.attrs.putAll(m);
attrs.put(Attr.CLASS, AttrKind.OK);
attrs.put(Attr.ID, AttrKind.OK);
attrs.put(Attr.STYLE, AttrKind.OK);
}
public boolean accepts(HtmlTag t) {
if (flags.contains(Flag.ACCEPTS_BLOCK) && flags.contains(Flag.ACCEPTS_INLINE)) {
return (t.blockType == BlockType.BLOCK) || (t.blockType == BlockType.INLINE);
} else if (flags.contains(Flag.ACCEPTS_BLOCK)) {
return (t.blockType == BlockType.BLOCK);
} else if (flags.contains(Flag.ACCEPTS_INLINE)) {
return (t.blockType == BlockType.INLINE);
} else
switch (blockType) {
case BLOCK:
case INLINE:
return (t.blockType == BlockType.INLINE);
case OTHER:
// OTHER tags are invalid in doc comments, and will be
// reported separately, so silently accept/ignore any content
return true;
default:
// any combination which could otherwise arrive here
// ought to have been handled in an overriding method
throw new AssertionError(this + ":" + t);
}
}
public boolean acceptsText() {
// generally, anywhere we can put text we can also put inline tag
// so check if a typical inline tag is allowed
return accepts(B);
}
public String getText() {
return StringUtils.toLowerCase(name());
}
public Attr getAttr(Name attrName) {
return Attr.index.get(StringUtils.toLowerCase(attrName.toString()));
}
public AttrKind getAttrKind(Name attrName) {
AttrKind k = attrs.get(getAttr(attrName)); // null-safe
return (k == null) ? AttrKind.INVALID : k;
}
private static AttrMap attrs(AttrKind k, Attr... attrs) {
AttrMap map = new AttrMap();
for (Attr a: attrs) map.put(a, k);
return map;
}
private static final Map<String,HtmlTag> index = new HashMap<String,HtmlTag>();
static {
for (HtmlTag t: values()) {
index.put(t.getText(), t);
}
}
static HtmlTag get(Name tagName) {
return index.get(StringUtils.toLowerCase(tagName.toString()));
}
}

View File

@@ -0,0 +1,349 @@
/*
* Copyright (c) 2012, 2013, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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 com.sun.tools.doclint;
import java.io.PrintWriter;
import java.text.MessageFormat;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import javax.tools.Diagnostic;
import com.sun.source.doctree.DocTree;
import com.sun.source.tree.Tree;
import com.sun.tools.doclint.Env.AccessKind;
import com.sun.tools.javac.util.StringUtils;
/**
* Message reporting for DocLint.
*
* Options are used to filter out messages based on group and access level.
* Support can be enabled for accumulating statistics of different kinds of
* messages.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own
* risk. This code and its internal interfaces are subject to change
* or deletion without notice.</b></p>
*/
public class Messages {
/**
* Groups used to categorize messages, so that messages in each group
* can be enabled or disabled via options.
*/
public enum Group {
ACCESSIBILITY,
HTML,
MISSING,
SYNTAX,
REFERENCE;
String optName() { return StringUtils.toLowerCase(name()); }
String notOptName() { return "-" + optName(); }
static boolean accepts(String opt) {
for (Group g: values())
if (opt.equals(g.optName())) return true;
return false;
}
};
private final Options options;
private final Stats stats;
ResourceBundle bundle;
Env env;
Messages(Env env) {
this.env = env;
String name = getClass().getPackage().getName() + ".resources.doclint";
bundle = ResourceBundle.getBundle(name, Locale.ENGLISH);
stats = new Stats(bundle);
options = new Options(stats);
}
void error(Group group, DocTree tree, String code, Object... args) {
report(group, Diagnostic.Kind.ERROR, tree, code, args);
}
void warning(Group group, DocTree tree, String code, Object... args) {
report(group, Diagnostic.Kind.WARNING, tree, code, args);
}
void setOptions(String opts) {
options.setOptions(opts);
}
void setStatsEnabled(boolean b) {
stats.setEnabled(b);
}
void reportStats(PrintWriter out) {
stats.report(out);
}
protected void report(Group group, Diagnostic.Kind dkind, DocTree tree, String code, Object... args) {
if (options.isEnabled(group, env.currAccess)) {
String msg = (code == null) ? (String) args[0] : localize(code, args);
env.trees.printMessage(dkind, msg, tree,
env.currDocComment, env.currPath.getCompilationUnit());
stats.record(group, dkind, code);
}
}
protected void report(Group group, Diagnostic.Kind dkind, Tree tree, String code, Object... args) {
if (options.isEnabled(group, env.currAccess)) {
String msg = localize(code, args);
env.trees.printMessage(dkind, msg, tree, env.currPath.getCompilationUnit());
stats.record(group, dkind, code);
}
}
String localize(String code, Object... args) {
String msg = bundle.getString(code);
if (msg == null) {
StringBuilder sb = new StringBuilder();
sb.append("message file broken: code=").append(code);
if (args.length > 0) {
sb.append(" arguments={0}");
for (int i = 1; i < args.length; i++) {
sb.append(", {").append(i).append("}");
}
}
msg = sb.toString();
}
return MessageFormat.format(msg, args);
}
// <editor-fold defaultstate="collapsed" desc="Options">
/**
* Handler for (sub)options specific to message handling.
*/
static class Options {
Map<String, Env.AccessKind> map = new HashMap<String, Env.AccessKind>();
private final Stats stats;
static boolean isValidOptions(String opts) {
for (String opt: opts.split(",")) {
if (!isValidOption(StringUtils.toLowerCase(opt.trim())))
return false;
}
return true;
}
private static boolean isValidOption(String opt) {
if (opt.equals("none") || opt.equals(Stats.OPT))
return true;
int begin = opt.startsWith("-") ? 1 : 0;
int sep = opt.indexOf("/");
String grp = opt.substring(begin, (sep != -1) ? sep : opt.length());
return ((begin == 0 && grp.equals("all")) || Group.accepts(grp))
&& ((sep == -1) || AccessKind.accepts(opt.substring(sep + 1)));
}
Options(Stats stats) {
this.stats = stats;
}
/** Determine if a message group is enabled for a particular access level. */
boolean isEnabled(Group g, Env.AccessKind access) {
if (map.isEmpty())
map.put("all", Env.AccessKind.PROTECTED);
Env.AccessKind ak = map.get(g.optName());
if (ak != null && access.compareTo(ak) >= 0)
return true;
ak = map.get(ALL);
if (ak != null && access.compareTo(ak) >= 0) {
ak = map.get(g.notOptName());
if (ak == null || access.compareTo(ak) > 0) // note >, not >=
return true;
}
return false;
}
void setOptions(String opts) {
if (opts == null)
setOption(ALL, Env.AccessKind.PRIVATE);
else {
for (String opt: opts.split(","))
setOption(StringUtils.toLowerCase(opt.trim()));
}
}
private void setOption(String arg) throws IllegalArgumentException {
if (arg.equals(Stats.OPT)) {
stats.setEnabled(true);
return;
}
int sep = arg.indexOf("/");
if (sep > 0) {
Env.AccessKind ak = Env.AccessKind.valueOf(StringUtils.toUpperCase(arg.substring(sep + 1)));
setOption(arg.substring(0, sep), ak);
} else {
setOption(arg, null);
}
}
private void setOption(String opt, Env.AccessKind ak) {
map.put(opt, (ak != null) ? ak
: opt.startsWith("-") ? Env.AccessKind.PUBLIC : Env.AccessKind.PRIVATE);
}
private static final String ALL = "all";
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Statistics">
/**
* Optionally record statistics of different kinds of message.
*/
static class Stats {
public static final String OPT = "stats";
public static final String NO_CODE = "";
final ResourceBundle bundle;
// tables only initialized if enabled
int[] groupCounts;
int[] dkindCounts;
Map<String, Integer> codeCounts;
Stats(ResourceBundle bundle) {
this.bundle = bundle;
}
void setEnabled(boolean b) {
if (b) {
groupCounts = new int[Messages.Group.values().length];
dkindCounts = new int[Diagnostic.Kind.values().length];
codeCounts = new HashMap<String, Integer>();
} else {
groupCounts = null;
dkindCounts = null;
codeCounts = null;
}
}
void record(Messages.Group g, Diagnostic.Kind dkind, String code) {
if (codeCounts == null) {
return;
}
groupCounts[g.ordinal()]++;
dkindCounts[dkind.ordinal()]++;
if (code == null) {
code = NO_CODE;
}
Integer i = codeCounts.get(code);
codeCounts.put(code, (i == null) ? 1 : i + 1);
}
void report(PrintWriter out) {
if (codeCounts == null) {
return;
}
out.println("By group...");
Table groupTable = new Table();
for (Messages.Group g : Messages.Group.values()) {
groupTable.put(g.optName(), groupCounts[g.ordinal()]);
}
groupTable.print(out);
out.println();
out.println("By diagnostic kind...");
Table dkindTable = new Table();
for (Diagnostic.Kind k : Diagnostic.Kind.values()) {
dkindTable.put(StringUtils.toLowerCase(k.toString()), dkindCounts[k.ordinal()]);
}
dkindTable.print(out);
out.println();
out.println("By message kind...");
Table codeTable = new Table();
for (Map.Entry<String, Integer> e : codeCounts.entrySet()) {
String code = e.getKey();
String msg;
try {
msg = code.equals(NO_CODE) ? "OTHER" : bundle.getString(code);
} catch (MissingResourceException ex) {
msg = code;
}
codeTable.put(msg, e.getValue());
}
codeTable.print(out);
}
/**
* A table of (int, String) sorted by decreasing int.
*/
private static class Table {
private static final Comparator<Integer> DECREASING = new Comparator<Integer>() {
public int compare(Integer o1, Integer o2) {
return o2.compareTo(o1);
}
};
private final TreeMap<Integer, Set<String>> map = new TreeMap<Integer, Set<String>>(DECREASING);
void put(String label, int n) {
if (n == 0) {
return;
}
Set<String> labels = map.get(n);
if (labels == null) {
map.put(n, labels = new TreeSet<String>());
}
labels.add(label);
}
void print(PrintWriter out) {
for (Map.Entry<Integer, Set<String>> e : map.entrySet()) {
int count = e.getKey();
Set<String> labels = e.getValue();
for (String label : labels) {
out.println(String.format("%6d: %s", count, label));
}
}
}
}
}
// </editor-fold>
}

View File

@@ -0,0 +1,59 @@
package com.sun.tools.doclint.resources;
public final class doclint extends java.util.ListResourceBundle {
protected final Object[][] getContents() {
return new Object[][] {
{ "dc.anchor.already.defined", "anchor already defined: {0}" },
{ "dc.anchor.value.missing", "no value given for anchor" },
{ "dc.attr.lacks.value", "attribute lacks value" },
{ "dc.attr.not.number", "attribute value is not a number" },
{ "dc.attr.obsolete", "attribute obsolete: {0}" },
{ "dc.attr.obsolete.use.css", "attribute obsolete, use CSS instead: {0}" },
{ "dc.attr.repeated", "repeated attribute: {0}" },
{ "dc.attr.unknown", "unknown attribute: {0}" },
{ "dc.bad.option", "bad option: {0}" },
{ "dc.bad.value.for.option", "bad value for option: {0} {1}" },
{ "dc.empty", "no description for @{0}" },
{ "dc.entity.invalid", "invalid entity &{0};" },
{ "dc.exception.not.thrown", "exception not thrown: {0}" },
{ "dc.invalid.anchor", "invalid name for anchor: \"{0}\"" },
{ "dc.invalid.param", "invalid use of @param" },
{ "dc.invalid.return", "invalid use of @return" },
{ "dc.invalid.throws", "invalid use of @throws" },
{ "dc.invalid.uri", "invalid uri: \"{0}\"" },
{ "dc.main.ioerror", "IO error: {0}" },
{ "dc.main.no.files.given", "No files given" },
{ "dc.main.usage", "Usage:\n doclint [options] source-files...\n\nOptions:\n -Xmsgs \n Same as -Xmsgs:all\n -Xmsgs:values\n Specify categories of issues to be checked, where ''values''\n is a comma-separated list of any of the following:\n reference show places where comments contain incorrect\n references to Java source code elements\n syntax show basic syntax errors within comments\n html show issues with HTML tags and attributes\n accessibility show issues for accessibility\n missing show issues with missing documentation\n all all of the above\n Precede a value with ''-'' to negate it\n Categories may be qualified by one of:\n /public /protected /package /private\n For positive categories (not beginning with ''-'')\n the qualifier applies to that access level and above.\n For negative categories (beginning with ''-'')\n the qualifier applies to that access level and below.\n If a qualifier is missing, the category applies to\n all access levels.\n For example, -Xmsgs:all,-syntax/private\n This will enable all messages, except syntax errors\n in the doc comments of private methods.\n If no -Xmsgs options are provided, the default is\n equivalent to -Xmsgs:all/protected, meaning that\n all messages are reported for protected and public\n declarations only. \n -stats\n Report statistics on the reported issues.\n -h -help --help -usage -?\n Show this message.\n\nThe following javac options are also supported\n -bootclasspath, -classpath, -cp, -sourcepath, -Xmaxerrs, -Xmaxwarns\n\nTo run doclint on part of a project, put the compiled classes for your\nproject on the classpath (or bootclasspath), then specify the source files\nto be checked on the command line." },
{ "dc.missing.comment", "no comment" },
{ "dc.missing.param", "no @param for {0}" },
{ "dc.missing.return", "no @return" },
{ "dc.missing.throws", "no @throws for {0}" },
{ "dc.no.alt.attr.for.image", "no \"alt\" attribute for image" },
{ "dc.no.summary.or.caption.for.table", "no summary or caption for table" },
{ "dc.param.name.not.found", "@param name not found" },
{ "dc.ref.not.found", "reference not found" },
{ "dc.tag.code.within.code", "'{@code'} within <code>" },
{ "dc.tag.empty", "empty <{0}> tag" },
{ "dc.tag.end.not.permitted", "invalid end tag: </{0}>" },
{ "dc.tag.end.unexpected", "unexpected end tag: </{0}>" },
{ "dc.tag.header.sequence.1", "header used out of sequence: <{0}>" },
{ "dc.tag.header.sequence.2", "header used out of sequence: <{0}>" },
{ "dc.tag.nested.not.allowed", "nested tag not allowed: <{0}>" },
{ "dc.tag.not.allowed", "element not allowed in documentation comments: <{0}>" },
{ "dc.tag.not.allowed.here", "tag not allowed here: <{0}>" },
{ "dc.tag.not.allowed.inline.element", "block element not allowed within inline element <{1}>: {0}" },
{ "dc.tag.not.allowed.inline.other", "block element not allowed here: {0}" },
{ "dc.tag.not.allowed.inline.tag", "block element not allowed within @{1}: {0}" },
{ "dc.tag.not.closed", "element not closed: {0}" },
{ "dc.tag.p.in.pre", "unexpected use of <p> inside <pre> element" },
{ "dc.tag.self.closing", "self-closing element not allowed" },
{ "dc.tag.start.unmatched", "end tag missing: </{0}>" },
{ "dc.tag.unknown", "unknown tag: {0}" },
{ "dc.text.not.allowed", "text not allowed in <{0}> element" },
{ "dc.type.arg.not.allowed", "type arguments not allowed here" },
{ "dc.unexpected.comment", "documentation comment not expected here" },
{ "dc.value.not.a.constant", "value does not refer to a constant" },
{ "dc.value.not.allowed.here", "'{@value}' not allowed here" },
};
}
}

View File

@@ -0,0 +1,59 @@
package com.sun.tools.doclint.resources;
public final class doclint_ja extends java.util.ListResourceBundle {
protected final Object[][] getContents() {
return new Object[][] {
{ "dc.anchor.already.defined", "\u30A2\u30F3\u30AB\u30FC\u304C\u3059\u3067\u306B\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059: {0}" },
{ "dc.anchor.value.missing", "\u30A2\u30F3\u30AB\u30FC\u306B\u5024\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093" },
{ "dc.attr.lacks.value", "\u5C5E\u6027\u306B\u5024\u304C\u3042\u308A\u307E\u305B\u3093" },
{ "dc.attr.not.number", "\u5C5E\u6027\u5024\u304C\u6570\u5B57\u3067\u306F\u3042\u308A\u307E\u305B\u3093" },
{ "dc.attr.obsolete", "\u5C5E\u6027\u306F\u5EC3\u6B62\u3055\u308C\u3066\u3044\u307E\u3059: {0}" },
{ "dc.attr.obsolete.use.css", "\u5C5E\u6027\u306F\u5EC3\u6B62\u3055\u308C\u3066\u3044\u307E\u3059\u3002\u304B\u308F\u308A\u306BCSS\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044: {0}" },
{ "dc.attr.repeated", "\u7E70\u308A\u8FD4\u3055\u308C\u305F\u5C5E\u6027: {0}" },
{ "dc.attr.unknown", "\u4E0D\u660E\u306A\u5C5E\u6027: {0}" },
{ "dc.bad.option", "\u7121\u52B9\u306A\u30AA\u30D7\u30B7\u30E7\u30F3: {0}" },
{ "dc.bad.value.for.option", "\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u5024\u304C\u4E0D\u6B63\u3067\u3059: {0} {1}" },
{ "dc.empty", "@{0}\u306E\u8AAC\u660E\u304C\u3042\u308A\u307E\u305B\u3093" },
{ "dc.entity.invalid", "\u7121\u52B9\u306A\u30A8\u30F3\u30C6\u30A3\u30C6\u30A3&{0};" },
{ "dc.exception.not.thrown", "\u4F8B\u5916\u304C\u30B9\u30ED\u30FC\u3055\u308C\u3066\u3044\u307E\u305B\u3093: {0}" },
{ "dc.invalid.anchor", "\u30A2\u30F3\u30AB\u30FC\u306E\u540D\u524D\u304C\u7121\u52B9\u3067\u3059: \"{0}\"" },
{ "dc.invalid.param", "\u7121\u52B9\u306A@param\u306E\u4F7F\u7528" },
{ "dc.invalid.return", "\u7121\u52B9\u306A@return\u306E\u4F7F\u7528" },
{ "dc.invalid.throws", "\u7121\u52B9\u306A@throws\u306E\u4F7F\u7528" },
{ "dc.invalid.uri", "\u7121\u52B9\u306AURI: \"{0}\"" },
{ "dc.main.ioerror", "IO\u30A8\u30E9\u30FC: {0}" },
{ "dc.main.no.files.given", "\u30D5\u30A1\u30A4\u30EB\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093" },
{ "dc.main.usage", "\u4F7F\u7528\u65B9\u6CD5:\n doclint [options] source-files...\n\n\u30AA\u30D7\u30B7\u30E7\u30F3:\n -Xmsgs \n -Xmsgs:all\u3068\u540C\u3058\n -Xmsgs:values\n \u30C1\u30A7\u30C3\u30AF\u3059\u308B\u554F\u984C\u306E\u30AB\u30C6\u30B4\u30EA\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002\u3053\u3053\u3067\u306E''values''\u306F\u3001\n \u30AB\u30F3\u30DE\u3067\u533A\u5207\u3089\u308C\u305F\u6B21\u306E\u5024\u306E\u30EA\u30B9\u30C8\u3067\u3059:\n reference Java\u30BD\u30FC\u30B9\u30FB\u30B3\u30FC\u30C9\u8981\u7D20\u3078\u306E\u4E0D\u6B63\u306A\u53C2\u7167\u3092\u542B\u3080\u30B3\u30E1\u30F3\u30C8\u306E\n \u5834\u6240\u3092\u8868\u793A\u3057\u307E\u3059\n syntax \u30B3\u30E1\u30F3\u30C8\u5185\u306E\u57FA\u672C\u69CB\u6587\u30A8\u30E9\u30FC\u3092\u8868\u793A\u3057\u307E\u3059\n html HTML\u30BF\u30D6\u304A\u3088\u3073\u5C5E\u6027\u306E\u554F\u984C\u3092\u8868\u793A\u3057\u307E\u3059\n accessibility \u30A2\u30AF\u30BB\u30B7\u30D3\u30EA\u30C6\u30A3\u306E\u554F\u984C\u3092\u8868\u793A\u3057\u307E\u3059\n missing \u6B20\u843D\u3057\u3066\u3044\u308B\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u554F\u984C\u3092\u8868\u793A\u3057\u307E\u3059\n all \u524D\u8FF0\u306E\u3059\u3079\u3066\n \u3053\u308C\u3092\u5426\u5B9A\u3059\u308B\u306B\u306F\u3001\u5024\u306E\u524D\u306B''-''\u3092\u6307\u5B9A\u3057\u307E\u3059\n \u30AB\u30C6\u30B4\u30EA\u306F\u3001\u6B21\u306E\u3044\u305A\u308C\u304B\u3067\u4FEE\u98FE\u3067\u304D\u307E\u3059:\n /public /protected /package /private\n \u6B63\u306E\u30AB\u30C6\u30B4\u30EA(''-''\u3067\u59CB\u307E\u3089\u306A\u3044)\u306E\u5834\u5408\n \u4FEE\u98FE\u5B50\u306F\u3001\u305D\u306E\u30A2\u30AF\u30BB\u30B9\u30FB\u30EC\u30D9\u30EB\u4EE5\u4E0A\u306B\u9069\u7528\u3055\u308C\u307E\u3059\u3002\n \u8CA0\u306E\u30AB\u30C6\u30B4\u30EA(''-''\u3067\u59CB\u307E\u308B)\u306E\u5834\u5408\n \u4FEE\u98FE\u5B50\u306F\u3001\u305D\u306E\u30A2\u30AF\u30BB\u30B9\u30FB\u30EC\u30D9\u30EB\u4EE5\u4E0B\u306B\u9069\u7528\u3055\u308C\u307E\u3059\u3002\n \u4FEE\u98FE\u5B50\u304C\u306A\u3044\u5834\u5408\u3001\u30AB\u30C6\u30B4\u30EA\u306F\u3059\u3079\u3066\u306E\u30A2\u30AF\u30BB\u30B9\u30FB\u30EC\u30D9\u30EB\u306B\n \u9069\u7528\u3055\u308C\u307E\u3059\u3002\n \u4F8B: -Xmsgs:all,-syntax/private\n \u3053\u306E\u5834\u5408\u3001private\u30E1\u30BD\u30C3\u30C9\u306Edoc\u30B3\u30E1\u30F3\u30C8\u5185\u306E\u69CB\u6587\u30A8\u30E9\u30FC\u3092\u9664\u304D\u3001\n \u3059\u3079\u3066\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u6709\u52B9\u5316\u3055\u308C\u307E\u3059\u3002\n -Xmsgs\u30AA\u30D7\u30B7\u30E7\u30F3\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u306A\u3044\u5834\u5408\u3001\u30C7\u30D5\u30A9\u30EB\u30C8\u306F\u3001\n -Xmsgs:all/protected\u3068\u540C\u7B49\u306B\u306A\u308A\u3001\u3053\u308C\u306F\n \u3059\u3079\u3066\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u3001protected\u304A\u3088\u3073public\u306E\u5BA3\u8A00\u306E\u307F\u306B\u5831\u544A\u3055\u308C\u308B\u3053\u3068\u3092\n \u610F\u5473\u3057\u307E\u3059\u3002\n -stats\n \u5831\u544A\u3055\u308C\u305F\u554F\u984C\u306B\u5BFE\u3057\u3066\u7D71\u8A08\u3092\u5831\u544A\u3057\u307E\u3059\u3002\n -h -help --help -usage -?\n \u3053\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u8868\u793A\u3055\u308C\u307E\u3059\u3002\n\n\u6B21\u306Ejavac\u30AA\u30D7\u30B7\u30E7\u30F3\u3082\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u3059\n -bootclasspath\u3001-classpath\u3001-cp\u3001-sourcepath\u3001-Xmaxerrs\u3001-Xmaxwarns\n\n\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u4E00\u90E8\u306B\u5BFE\u3057\u3066doclint\u3092\u5B9F\u884C\u3059\u308B\u306B\u306F\u3001\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u30B3\u30F3\u30D1\u30A4\u30EB\u3055\u308C\u305F\u30AF\u30E9\u30B9\u3092\n\u30AF\u30E9\u30B9\u30D1\u30B9(\u307E\u305F\u306F\u30D6\u30FC\u30C8\u30FB\u30AF\u30E9\u30B9\u30D1\u30B9)\u306B\u6307\u5B9A\u3057\u3001\u30B3\u30DE\u30F3\u30C9\u884C\u3067\n\u30C1\u30A7\u30C3\u30AF\u3059\u308B\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u6307\u5B9A\u3057\u307E\u3059\u3002" },
{ "dc.missing.comment", "\u30B3\u30E1\u30F3\u30C8\u306A\u3057" },
{ "dc.missing.param", "{0}\u306E@param\u304C\u3042\u308A\u307E\u305B\u3093" },
{ "dc.missing.return", "@return\u304C\u3042\u308A\u307E\u305B\u3093" },
{ "dc.missing.throws", "{0}\u306E@throws\u304C\u3042\u308A\u307E\u305B\u3093" },
{ "dc.no.alt.attr.for.image", "\u30A4\u30E1\u30FC\u30B8\u306E\"alt\"\u5C5E\u6027\u304C\u3042\u308A\u307E\u305B\u3093" },
{ "dc.no.summary.or.caption.for.table", "\u8868\u306E\u8981\u7D04\u307E\u305F\u306F\u30AD\u30E3\u30D7\u30B7\u30E7\u30F3\u304C\u3042\u308A\u307E\u305B\u3093" },
{ "dc.param.name.not.found", "@param name\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093" },
{ "dc.ref.not.found", "\u53C2\u7167\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093" },
{ "dc.tag.code.within.code", "<code>\u5185\u306E'{@code'}" },
{ "dc.tag.empty", "\u7A7A\u306E<{0}>\u30BF\u30B0" },
{ "dc.tag.end.not.permitted", "\u7121\u52B9\u306A\u7D42\u4E86\u30BF\u30B0: </{0}>" },
{ "dc.tag.end.unexpected", "\u4E88\u671F\u3057\u306A\u3044\u7D42\u4E86\u30BF\u30B0: </{0}>" },
{ "dc.tag.header.sequence.1", "\u30D8\u30C3\u30C0\u30FC\u306E\u6307\u5B9A\u9806\u5E8F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093: <{0}>" },
{ "dc.tag.header.sequence.2", "\u30D8\u30C3\u30C0\u30FC\u306E\u6307\u5B9A\u9806\u5E8F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093: <{0}>" },
{ "dc.tag.nested.not.allowed", "\u30CD\u30B9\u30C8\u3057\u305F\u30BF\u30B0\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093: <{0}>" },
{ "dc.tag.not.allowed", "\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u30FB\u30B3\u30E1\u30F3\u30C8\u3067\u4F7F\u7528\u3067\u304D\u306A\u3044\u8981\u7D20\u3067\u3059: <{0}>" },
{ "dc.tag.not.allowed.here", "\u3053\u3053\u3067\u306F\u30BF\u30B0\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093: <{0}>" },
{ "dc.tag.not.allowed.inline.element", "\u30A4\u30F3\u30E9\u30A4\u30F3\u8981\u7D20<{1}>\u5185\u3067\u4F7F\u7528\u3067\u304D\u306A\u3044\u30D6\u30ED\u30C3\u30AF\u8981\u7D20\u3067\u3059: {0}" },
{ "dc.tag.not.allowed.inline.other", "\u3053\u3053\u3067\u306F\u30D6\u30ED\u30C3\u30AF\u8981\u7D20\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093: {0}" },
{ "dc.tag.not.allowed.inline.tag", "@{1}\u5185\u3067\u4F7F\u7528\u3067\u304D\u306A\u3044\u30D6\u30ED\u30C3\u30AF\u8981\u7D20\u3067\u3059: {0}" },
{ "dc.tag.not.closed", "\u8981\u7D20\u304C\u9589\u3058\u3089\u308C\u3066\u3044\u307E\u305B\u3093: {0}" },
{ "dc.tag.p.in.pre", "<pre>\u8981\u7D20\u5185\u3067\u4E88\u671F\u3057\u306A\u3044<p>\u304C\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059" },
{ "dc.tag.self.closing", "\u81EA\u5DF1\u7D42\u4E86\u8981\u7D20\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093" },
{ "dc.tag.start.unmatched", "\u7D42\u4E86\u30BF\u30B0\u304C\u3042\u308A\u307E\u305B\u3093: </{0}>" },
{ "dc.tag.unknown", "\u4E0D\u660E\u306A\u30BF\u30B0: {0}" },
{ "dc.text.not.allowed", "<{0}>\u8981\u7D20\u3067\u306F\u30C6\u30AD\u30B9\u30C8\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093" },
{ "dc.type.arg.not.allowed", "\u578B\u5F15\u6570\u306F\u3053\u3053\u3067\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093" },
{ "dc.unexpected.comment", "\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u30FB\u30B3\u30E1\u30F3\u30C8\u306F\u3053\u3053\u3067\u306F\u5FC5\u8981\u3042\u308A\u307E\u305B\u3093" },
{ "dc.value.not.a.constant", "\u5024\u304C\u5B9A\u6570\u3092\u53C2\u7167\u3057\u3066\u3044\u307E\u305B\u3093" },
{ "dc.value.not.allowed.here", "'{@value}'\u306F\u3053\u3053\u3067\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093" },
};
}
}

View File

@@ -0,0 +1,59 @@
package com.sun.tools.doclint.resources;
public final class doclint_zh_CN extends java.util.ListResourceBundle {
protected final Object[][] getContents() {
return new Object[][] {
{ "dc.anchor.already.defined", "\u951A\u5B9A\u70B9\u5DF2\u5B9A\u4E49: {0}" },
{ "dc.anchor.value.missing", "\u6CA1\u6709\u4E3A\u951A\u5B9A\u70B9\u6307\u5B9A\u503C" },
{ "dc.attr.lacks.value", "\u5C5E\u6027\u7F3A\u5C11\u503C" },
{ "dc.attr.not.number", "\u5C5E\u6027\u503C\u4E0D\u662F\u6570\u5B57" },
{ "dc.attr.obsolete", "\u5C5E\u6027\u5DF2\u8FC7\u65F6: {0}" },
{ "dc.attr.obsolete.use.css", "\u5C5E\u6027\u5DF2\u8FC7\u65F6, \u8BF7\u6539\u7528 CSS: {0}" },
{ "dc.attr.repeated", "\u5C5E\u6027\u91CD\u590D: {0}" },
{ "dc.attr.unknown", "\u672A\u77E5\u5C5E\u6027: {0}" },
{ "dc.bad.option", "\u9009\u9879\u9519\u8BEF: {0}" },
{ "dc.bad.value.for.option", "\u9009\u9879\u7684\u503C\u9519\u8BEF: {0} {1}" },
{ "dc.empty", "@{0} \u6CA1\u6709\u8BF4\u660E" },
{ "dc.entity.invalid", "\u5B9E\u4F53 &{0}; \u65E0\u6548" },
{ "dc.exception.not.thrown", "\u672A\u629B\u51FA\u5F02\u5E38\u9519\u8BEF: {0}" },
{ "dc.invalid.anchor", "\u951A\u5B9A\u70B9\u7684\u540D\u79F0\u65E0\u6548: \"{0}\"" },
{ "dc.invalid.param", "@param \u7684\u7528\u6CD5\u65E0\u6548" },
{ "dc.invalid.return", "@return \u7684\u7528\u6CD5\u65E0\u6548" },
{ "dc.invalid.throws", "@throws \u7684\u7528\u6CD5\u65E0\u6548" },
{ "dc.invalid.uri", "URI \u65E0\u6548: \"{0}\"" },
{ "dc.main.ioerror", "IO \u9519\u8BEF: {0}" },
{ "dc.main.no.files.given", "\u672A\u6307\u5B9A\u6587\u4EF6" },
{ "dc.main.usage", "\u7528\u6CD5:\n doclint [options] source-files...\n\n\u9009\u9879:\n -Xmsgs \n \u4E0E -Xmsgs:all \u76F8\u540C\n -Xmsgs:values\n \u6307\u5B9A\u8981\u68C0\u67E5\u7684\u95EE\u9898\u7684\u7C7B\u522B, \u5176\u4E2D ''values''\n \u662F\u4EFB\u610F\u4EE5\u4E0B\u5185\u5BB9\u7684\u4EE5\u9017\u53F7\u5206\u9694\u7684\u5217\u8868:\n reference \u663E\u793A\u5305\u542B\u5BF9 Java \u6E90\u4EE3\u7801\u5143\u7D20\n \u9519\u8BEF\u5F15\u7528\u7684\u6CE8\u91CA\u7684\u4F4D\u7F6E\n syntax \u663E\u793A\u6CE8\u91CA\u4E2D\u7684\u57FA\u672C\u8BED\u6CD5\u9519\u8BEF\n html \u663E\u793A HTML \u6807\u8BB0\u548C\u5C5E\u6027\u95EE\u9898\n accessibility \u663E\u793A\u53EF\u8BBF\u95EE\u6027\u7684\u95EE\u9898\n missing \u663E\u793A\u7F3A\u5C11\u6587\u6863\u7684\u95EE\u9898\n all \u6240\u6709\u4EE5\u4E0A\u5185\u5BB9\n \u5728\u503C\u4E4B\u524D\u4F7F\u7528 ''-'' \u53EF\u4F7F\u7528\u5176\u53CD\u503C\n \u53EF\u4EE5\u4F7F\u7528\u4EE5\u4E0B\u4E00\u9879\u6765\u9650\u5B9A\u7C7B\u522B:\n /public /protected /package /private\n \u5BF9\u4E8E\u6B63\u7C7B\u522B (\u4E0D\u4EE5 ''-'' \u5F00\u5934)\n \u9650\u5B9A\u7B26\u9002\u7528\u4E8E\u8BE5\u8BBF\u95EE\u7EA7\u522B\u53CA\u66F4\u9AD8\u7EA7\u522B\u3002\n \u5BF9\u4E8E\u8D1F\u7C7B\u522B (\u4EE5 ''-'' \u5F00\u5934)\n \u9650\u5B9A\u7B26\u9002\u7528\u4E8E\u8BE5\u8BBF\u95EE\u7EA7\u522B\u53CA\u66F4\u4F4E\u7EA7\u522B\u3002\n \u5982\u679C\u6CA1\u6709\u9650\u5B9A\u7B26, \u5219\u8BE5\u7C7B\u522B\u9002\u7528\u4E8E\n \u6240\u6709\u8BBF\u95EE\u7EA7\u522B\u3002\n \u4F8B\u5982, -Xmsgs:all,-syntax/private\n \u8FD9\u5C06\u5728\u4E13\u7528\u65B9\u6CD5\u7684\u6587\u6863\u6CE8\u91CA\u4E2D\n \u542F\u7528\u9664\u8BED\u6CD5\u9519\u8BEF\u4E4B\u5916\u7684\u6240\u6709\u6D88\u606F\u3002\n \u5982\u679C\u672A\u63D0\u4F9B -Xmsgs \u9009\u9879, \u5219\u9ED8\u8BA4\u503C\n \u7B49\u540C\u4E8E -Xmsgs:all/protected, \u8868\u793A\n \u4EC5\u62A5\u544A\u53D7\u4FDD\u62A4\u548C\u516C\u5171\u58F0\u660E\u4E2D\u7684\n \u6240\u6709\u6D88\u606F\n -stats\n \u62A5\u544A\u6240\u62A5\u544A\u95EE\u9898\u7684\u7EDF\u8BA1\u4FE1\u606F\u3002\n -h -help --help -usage -?\n \u663E\u793A\u6B64\u6D88\u606F\u3002\n\n\u8FD8\u652F\u6301\u4EE5\u4E0B javac \u9009\u9879\n -bootclasspath, -classpath, -cp, -sourcepath, -Xmaxerrs, -Xmaxwarns\n\n\u8981\u5728\u9879\u76EE\u7684\u4E00\u90E8\u5206\u4E0A\u8FD0\u884C doclint, \u8BF7\u5C06\u9879\u76EE\u4E2D\u5DF2\u7F16\u8BD1\u7684\u7C7B\n\u653E\u5728\u7C7B\u8DEF\u5F84 (\u6216\u5F15\u5BFC\u7C7B\u8DEF\u5F84) \u4E0A, \u7136\u540E\u5728\u547D\u4EE4\u884C\u4E0A\u6307\u5B9A\n\u8981\u68C0\u67E5\u7684\u6E90\u6587\u4EF6\u3002" },
{ "dc.missing.comment", "\u6CA1\u6709\u6CE8\u91CA" },
{ "dc.missing.param", "{0}\u6CA1\u6709 @param" },
{ "dc.missing.return", "\u6CA1\u6709 @return" },
{ "dc.missing.throws", "{0}\u6CA1\u6709 @throws" },
{ "dc.no.alt.attr.for.image", "\u56FE\u50CF\u6CA1\u6709 \"alt\" \u5C5E\u6027" },
{ "dc.no.summary.or.caption.for.table", "\u8868\u6CA1\u6709\u6982\u8981\u6216\u6807\u9898" },
{ "dc.param.name.not.found", "@param name \u672A\u627E\u5230" },
{ "dc.ref.not.found", "\u627E\u4E0D\u5230\u5F15\u7528" },
{ "dc.tag.code.within.code", "'{@code'} \u5728 <code> \u4E2D" },
{ "dc.tag.empty", "<{0}> \u6807\u8BB0\u4E3A\u7A7A" },
{ "dc.tag.end.not.permitted", "\u65E0\u6548\u7684\u7ED3\u675F\u6807\u8BB0: </{0}>" },
{ "dc.tag.end.unexpected", "\u610F\u5916\u7684\u7ED3\u675F\u6807\u8BB0: </{0}>" },
{ "dc.tag.header.sequence.1", "\u4F7F\u7528\u7684\u6807\u9898\u8D85\u51FA\u5E8F\u5217: <{0}>" },
{ "dc.tag.header.sequence.2", "\u4F7F\u7528\u7684\u6807\u9898\u8D85\u51FA\u5E8F\u5217: <{0}>" },
{ "dc.tag.nested.not.allowed", "\u4E0D\u5141\u8BB8\u4F7F\u7528\u5D4C\u5957\u6807\u8BB0: <{0}>" },
{ "dc.tag.not.allowed", "\u6587\u6863\u6CE8\u91CA\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528\u5143\u7D20: <{0}>" },
{ "dc.tag.not.allowed.here", "\u6B64\u5904\u4E0D\u5141\u8BB8\u4F7F\u7528\u6807\u8BB0: <{0}>" },
{ "dc.tag.not.allowed.inline.element", "\u5185\u5D4C\u5143\u7D20 <{1}> \u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528\u5757\u5143\u7D20: {0}" },
{ "dc.tag.not.allowed.inline.other", "\u6B64\u5904\u4E0D\u5141\u8BB8\u4F7F\u7528\u5757\u5143\u7D20: {0}" },
{ "dc.tag.not.allowed.inline.tag", "@{1} \u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528\u5757\u5143\u7D20: {0}" },
{ "dc.tag.not.closed", "\u5143\u7D20\u672A\u5173\u95ED: {0}" },
{ "dc.tag.p.in.pre", "<pre> \u5143\u7D20\u5185\u90E8\u610F\u5916\u5730\u4F7F\u7528\u4E86 <p>" },
{ "dc.tag.self.closing", "\u4E0D\u5141\u8BB8\u4F7F\u7528\u81EA\u5173\u95ED\u5143\u7D20" },
{ "dc.tag.start.unmatched", "\u7F3A\u5C11\u7ED3\u675F\u6807\u8BB0: </{0}>" },
{ "dc.tag.unknown", "\u672A\u77E5\u6807\u8BB0: {0}" },
{ "dc.text.not.allowed", "<{0}> \u5143\u7D20\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528\u6587\u672C" },
{ "dc.type.arg.not.allowed", "\u6B64\u5904\u4E0D\u5141\u8BB8\u4F7F\u7528\u7C7B\u578B\u53C2\u6570" },
{ "dc.unexpected.comment", "\u6B64\u5904\u672A\u9884\u671F\u6587\u6863\u6CE8\u91CA" },
{ "dc.value.not.a.constant", "\u503C\u4E0D\u5F15\u7528\u5E38\u91CF" },
{ "dc.value.not.allowed.here", "\u6B64\u5904\u4E0D\u5141\u8BB8\u4F7F\u7528 '{@value}'" },
};
}
}