mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 11:34:38 +02:00
8006251: doclint: incorrect position for diagnostic for illegal text in tags
Reviewed-by: mcimadamore
This commit is contained in:
parent
7967c92db0
commit
f251cc24ca
17 changed files with 725 additions and 108 deletions
|
@ -95,7 +95,8 @@ public class Checker extends DocTreeScanner<Void, Void> {
|
||||||
public enum Flag {
|
public enum Flag {
|
||||||
TABLE_HAS_CAPTION,
|
TABLE_HAS_CAPTION,
|
||||||
HAS_ELEMENT,
|
HAS_ELEMENT,
|
||||||
HAS_TEXT
|
HAS_TEXT,
|
||||||
|
REPORTED_BAD_INLINE
|
||||||
}
|
}
|
||||||
|
|
||||||
static class TagStackItem {
|
static class TagStackItem {
|
||||||
|
@ -195,7 +196,8 @@ public class Checker extends DocTreeScanner<Void, Void> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visitText(TextTree tree, Void ignore) {
|
public Void visitText(TextTree tree, Void ignore) {
|
||||||
if (!tree.getBody().trim().isEmpty()) {
|
if (hasNonWhitespace(tree)) {
|
||||||
|
checkAllowsText(tree);
|
||||||
markEnclosingTag(Flag.HAS_TEXT);
|
markEnclosingTag(Flag.HAS_TEXT);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -203,6 +205,7 @@ public class Checker extends DocTreeScanner<Void, Void> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visitEntity(EntityTree tree, Void ignore) {
|
public Void visitEntity(EntityTree tree, Void ignore) {
|
||||||
|
checkAllowsText(tree);
|
||||||
markEnclosingTag(Flag.HAS_TEXT);
|
markEnclosingTag(Flag.HAS_TEXT);
|
||||||
String name = tree.getName().toString();
|
String name = tree.getName().toString();
|
||||||
if (name.startsWith("#")) {
|
if (name.startsWith("#")) {
|
||||||
|
@ -218,6 +221,18 @@ public class Checker extends DocTreeScanner<Void, Void> {
|
||||||
return null;
|
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>
|
||||||
|
|
||||||
// <editor-fold defaultstate="collapsed" desc="HTML elements">
|
// <editor-fold defaultstate="collapsed" desc="HTML elements">
|
||||||
|
@ -230,53 +245,22 @@ public class Checker extends DocTreeScanner<Void, Void> {
|
||||||
if (t == null) {
|
if (t == null) {
|
||||||
env.messages.error(HTML, tree, "dc.tag.unknown", treeName);
|
env.messages.error(HTML, tree, "dc.tag.unknown", treeName);
|
||||||
} else {
|
} else {
|
||||||
|
for (TagStackItem tsi: tagStack) {
|
||||||
|
if (tsi.tag.accepts(t)) {
|
||||||
|
while (tagStack.peek() != tsi) tagStack.pop();
|
||||||
|
break;
|
||||||
|
} else if (tsi.tag.endKind != HtmlTag.EndKind.OPTIONAL)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
checkStructure(tree, t);
|
||||||
|
|
||||||
// tag specific checks
|
// tag specific checks
|
||||||
switch (t) {
|
switch (t) {
|
||||||
// check for out of sequence headers, such as <h1>...</h1> <h3>...</h3>
|
// check for out of sequence headers, such as <h1>...</h1> <h3>...</h3>
|
||||||
case H1: case H2: case H3: case H4: case H5: case H6:
|
case H1: case H2: case H3: case H4: case H5: case H6:
|
||||||
checkHeader(tree, t);
|
checkHeader(tree, t);
|
||||||
break;
|
break;
|
||||||
// <p> inside <pre>
|
|
||||||
case P:
|
|
||||||
TagStackItem top = tagStack.peek();
|
|
||||||
if (top != null && top.tag == HtmlTag.PRE)
|
|
||||||
env.messages.warning(HTML, tree, "dc.tag.p.in.pre");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check that only block tags and inline tags are used,
|
|
||||||
// and that blocks tags are not used within inline tags
|
|
||||||
switch (t.blockType) {
|
|
||||||
case INLINE:
|
|
||||||
break;
|
|
||||||
case BLOCK:
|
|
||||||
TagStackItem top = tagStack.peek();
|
|
||||||
if (top != null && top.tag != null && top.tag.blockType == HtmlTag.BlockType.INLINE) {
|
|
||||||
switch (top.tree.getKind()) {
|
|
||||||
case START_ELEMENT: {
|
|
||||||
Name name = ((StartElementTree) top.tree).getName();
|
|
||||||
env.messages.error(HTML, tree, "dc.tag.not.allowed.inline.element",
|
|
||||||
treeName, name);
|
|
||||||
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);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
env.messages.error(HTML, tree, "dc.tag.not.allowed.inline.other",
|
|
||||||
treeName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OTHER:
|
|
||||||
env.messages.error(HTML, tree, "dc.tag.not.allowed", treeName);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t.flags.contains(HtmlTag.Flag.NO_NEST)) {
|
if (t.flags.contains(HtmlTag.Flag.NO_NEST)) {
|
||||||
|
@ -324,6 +308,58 @@ public class Checker extends DocTreeScanner<Void, Void> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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:
|
||||||
|
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) {
|
private void checkHeader(StartElementTree tree, HtmlTag tag) {
|
||||||
// verify the new tag
|
// verify the new tag
|
||||||
if (getHeaderLevel(tag) > getHeaderLevel(currHeaderTag) + 1) {
|
if (getHeaderLevel(tag) > getHeaderLevel(currHeaderTag) + 1) {
|
||||||
|
@ -378,10 +414,6 @@ public class Checker extends DocTreeScanner<Void, Void> {
|
||||||
&& !top.flags.contains(Flag.HAS_ELEMENT)) {
|
&& !top.flags.contains(Flag.HAS_ELEMENT)) {
|
||||||
env.messages.warning(HTML, tree, "dc.tag.empty", treeName);
|
env.messages.warning(HTML, tree, "dc.tag.empty", treeName);
|
||||||
}
|
}
|
||||||
if (t.flags.contains(HtmlTag.Flag.NO_TEXT)
|
|
||||||
&& top.flags.contains(Flag.HAS_TEXT)) {
|
|
||||||
env.messages.error(HTML, tree, "dc.text.not.allowed", treeName);
|
|
||||||
}
|
|
||||||
tagStack.pop();
|
tagStack.pop();
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
|
@ -763,7 +795,7 @@ public class Checker extends DocTreeScanner<Void, Void> {
|
||||||
for (DocTree d: list) {
|
for (DocTree d: list) {
|
||||||
switch (d.getKind()) {
|
switch (d.getKind()) {
|
||||||
case TEXT:
|
case TEXT:
|
||||||
if (!((TextTree) d).getBody().trim().isEmpty())
|
if (hasNonWhitespace((TextTree) d))
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -772,6 +804,16 @@ public class Checker extends DocTreeScanner<Void, Void> {
|
||||||
}
|
}
|
||||||
env.messages.warning(SYNTAX, tree, "dc.empty", tree.getKind().tagName);
|
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>
|
// </editor-fold>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,16 +57,22 @@ public enum HtmlTag {
|
||||||
B(BlockType.INLINE, EndKind.REQUIRED,
|
B(BlockType.INLINE, EndKind.REQUIRED,
|
||||||
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
|
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
|
||||||
|
|
||||||
BLOCKQUOTE,
|
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),
|
BODY(BlockType.OTHER, EndKind.REQUIRED),
|
||||||
|
|
||||||
BR(BlockType.INLINE, EndKind.NONE,
|
BR(BlockType.INLINE, EndKind.NONE,
|
||||||
attrs(AttrKind.USE_CSS, CLEAR)),
|
attrs(AttrKind.USE_CSS, CLEAR)),
|
||||||
|
|
||||||
CAPTION(EnumSet.of(Flag.EXPECT_CONTENT)),
|
CAPTION(BlockType.TABLE_ITEM, EndKind.REQUIRED,
|
||||||
|
EnumSet.of(Flag.ACCEPTS_INLINE, Flag.EXPECT_CONTENT)),
|
||||||
|
|
||||||
CENTER,
|
CENTER(BlockType.BLOCK, EndKind.REQUIRED,
|
||||||
|
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)),
|
||||||
|
|
||||||
CITE(BlockType.INLINE, EndKind.REQUIRED,
|
CITE(BlockType.INLINE, EndKind.REQUIRED,
|
||||||
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
|
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
|
||||||
|
@ -74,17 +80,23 @@ public enum HtmlTag {
|
||||||
CODE(BlockType.INLINE, EndKind.REQUIRED,
|
CODE(BlockType.INLINE, EndKind.REQUIRED,
|
||||||
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
|
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
|
||||||
|
|
||||||
DD(BlockType.BLOCK, EndKind.OPTIONAL,
|
DD(BlockType.LIST_ITEM, EndKind.OPTIONAL,
|
||||||
EnumSet.of(Flag.EXPECT_CONTENT)),
|
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE, Flag.EXPECT_CONTENT)),
|
||||||
|
|
||||||
DIV,
|
DIV(BlockType.BLOCK, EndKind.REQUIRED,
|
||||||
|
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)),
|
||||||
|
|
||||||
DL(BlockType.BLOCK, EndKind.REQUIRED,
|
DL(BlockType.BLOCK, EndKind.REQUIRED,
|
||||||
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_TEXT),
|
EnumSet.of(Flag.EXPECT_CONTENT),
|
||||||
attrs(AttrKind.USE_CSS, COMPACT)),
|
attrs(AttrKind.USE_CSS, COMPACT)) {
|
||||||
|
@Override
|
||||||
|
public boolean accepts(HtmlTag t) {
|
||||||
|
return (t == DT) || (t == DD);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
DT(BlockType.BLOCK, EndKind.OPTIONAL,
|
DT(BlockType.LIST_ITEM, EndKind.OPTIONAL,
|
||||||
EnumSet.of(Flag.EXPECT_CONTENT)),
|
EnumSet.of(Flag.ACCEPTS_INLINE, Flag.EXPECT_CONTENT)),
|
||||||
|
|
||||||
EM(BlockType.INLINE, EndKind.REQUIRED,
|
EM(BlockType.INLINE, EndKind.REQUIRED,
|
||||||
EnumSet.of(Flag.NO_NEST)),
|
EnumSet.of(Flag.NO_NEST)),
|
||||||
|
@ -97,12 +109,12 @@ public enum HtmlTag {
|
||||||
|
|
||||||
FRAMESET(BlockType.OTHER, EndKind.REQUIRED),
|
FRAMESET(BlockType.OTHER, EndKind.REQUIRED),
|
||||||
|
|
||||||
H1,
|
H1(BlockType.BLOCK, EndKind.REQUIRED),
|
||||||
H2,
|
H2(BlockType.BLOCK, EndKind.REQUIRED),
|
||||||
H3,
|
H3(BlockType.BLOCK, EndKind.REQUIRED),
|
||||||
H4,
|
H4(BlockType.BLOCK, EndKind.REQUIRED),
|
||||||
H5,
|
H5(BlockType.BLOCK, EndKind.REQUIRED),
|
||||||
H6,
|
H6(BlockType.BLOCK, EndKind.REQUIRED),
|
||||||
|
|
||||||
HEAD(BlockType.OTHER, EndKind.REQUIRED),
|
HEAD(BlockType.OTHER, EndKind.REQUIRED),
|
||||||
|
|
||||||
|
@ -118,31 +130,54 @@ public enum HtmlTag {
|
||||||
attrs(AttrKind.OBSOLETE, NAME),
|
attrs(AttrKind.OBSOLETE, NAME),
|
||||||
attrs(AttrKind.USE_CSS, ALIGN, HSPACE, VSPACE, BORDER)),
|
attrs(AttrKind.USE_CSS, ALIGN, HSPACE, VSPACE, BORDER)),
|
||||||
|
|
||||||
LI(BlockType.BLOCK, EndKind.OPTIONAL),
|
LI(BlockType.LIST_ITEM, EndKind.OPTIONAL,
|
||||||
|
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)),
|
||||||
|
|
||||||
LINK(BlockType.OTHER, EndKind.NONE),
|
LINK(BlockType.OTHER, EndKind.NONE),
|
||||||
|
|
||||||
MENU,
|
MENU(BlockType.BLOCK, EndKind.REQUIRED) {
|
||||||
|
@Override
|
||||||
|
public boolean accepts(HtmlTag t) {
|
||||||
|
return (t == LI);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
META(BlockType.OTHER, EndKind.NONE),
|
META(BlockType.OTHER, EndKind.NONE),
|
||||||
|
|
||||||
NOFRAMES(BlockType.OTHER, EndKind.REQUIRED),
|
NOFRAMES(BlockType.OTHER, EndKind.REQUIRED),
|
||||||
|
|
||||||
NOSCRIPT(BlockType.OTHER, EndKind.REQUIRED),
|
NOSCRIPT(BlockType.BLOCK, EndKind.REQUIRED),
|
||||||
|
|
||||||
OL(BlockType.BLOCK, EndKind.REQUIRED,
|
OL(BlockType.BLOCK, EndKind.REQUIRED,
|
||||||
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_TEXT),
|
EnumSet.of(Flag.EXPECT_CONTENT),
|
||||||
attrs(AttrKind.USE_CSS, START, TYPE)),
|
attrs(AttrKind.USE_CSS, START, TYPE)){
|
||||||
|
@Override
|
||||||
|
public boolean accepts(HtmlTag t) {
|
||||||
|
return (t == LI);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
P(BlockType.BLOCK, EndKind.OPTIONAL,
|
P(BlockType.BLOCK, EndKind.OPTIONAL,
|
||||||
EnumSet.of(Flag.EXPECT_CONTENT),
|
EnumSet.of(Flag.EXPECT_CONTENT),
|
||||||
attrs(AttrKind.USE_CSS, ALIGN)),
|
attrs(AttrKind.USE_CSS, ALIGN)),
|
||||||
|
|
||||||
PRE(EnumSet.of(Flag.EXPECT_CONTENT)),
|
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),
|
SCRIPT(BlockType.OTHER, EndKind.REQUIRED),
|
||||||
|
|
||||||
SMALL(BlockType.INLINE, EndKind.REQUIRED),
|
SMALL(BlockType.INLINE, EndKind.REQUIRED,
|
||||||
|
EnumSet.of(Flag.EXPECT_CONTENT)),
|
||||||
|
|
||||||
SPAN(BlockType.INLINE, EndKind.REQUIRED,
|
SPAN(BlockType.INLINE, EndKind.REQUIRED,
|
||||||
EnumSet.of(Flag.EXPECT_CONTENT)),
|
EnumSet.of(Flag.EXPECT_CONTENT)),
|
||||||
|
@ -157,37 +192,70 @@ public enum HtmlTag {
|
||||||
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
|
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
|
||||||
|
|
||||||
TABLE(BlockType.BLOCK, EndKind.REQUIRED,
|
TABLE(BlockType.BLOCK, EndKind.REQUIRED,
|
||||||
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_TEXT),
|
EnumSet.of(Flag.EXPECT_CONTENT),
|
||||||
attrs(AttrKind.OK, SUMMARY, Attr.FRAME, RULES, BORDER,
|
attrs(AttrKind.OK, SUMMARY, Attr.FRAME, RULES, BORDER,
|
||||||
CELLPADDING, CELLSPACING),
|
CELLPADDING, CELLSPACING),
|
||||||
attrs(AttrKind.USE_CSS, ALIGN, WIDTH, BGCOLOR)),
|
attrs(AttrKind.USE_CSS, ALIGN, WIDTH, 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.BLOCK, EndKind.REQUIRED,
|
TBODY(BlockType.TABLE_ITEM, EndKind.REQUIRED,
|
||||||
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_TEXT),
|
EnumSet.of(Flag.EXPECT_CONTENT),
|
||||||
attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN)),
|
attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN)) {
|
||||||
|
@Override
|
||||||
|
public boolean accepts(HtmlTag t) {
|
||||||
|
return (t == TR);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
TD(BlockType.BLOCK, EndKind.OPTIONAL,
|
TD(BlockType.TABLE_ITEM, EndKind.OPTIONAL,
|
||||||
|
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE),
|
||||||
attrs(AttrKind.OK, COLSPAN, ROWSPAN, HEADERS, SCOPE, ABBR, AXIS,
|
attrs(AttrKind.OK, COLSPAN, ROWSPAN, HEADERS, SCOPE, ABBR, AXIS,
|
||||||
ALIGN, CHAR, CHAROFF, VALIGN),
|
ALIGN, CHAR, CHAROFF, VALIGN),
|
||||||
attrs(AttrKind.USE_CSS, WIDTH, BGCOLOR, HEIGHT, NOWRAP)),
|
attrs(AttrKind.USE_CSS, WIDTH, BGCOLOR, HEIGHT, NOWRAP)),
|
||||||
|
|
||||||
TFOOT(BlockType.BLOCK, EndKind.REQUIRED,
|
TFOOT(BlockType.TABLE_ITEM, EndKind.REQUIRED,
|
||||||
attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN)),
|
attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN)) {
|
||||||
|
@Override
|
||||||
|
public boolean accepts(HtmlTag t) {
|
||||||
|
return (t == TR);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
TH(BlockType.BLOCK, EndKind.OPTIONAL,
|
TH(BlockType.TABLE_ITEM, EndKind.OPTIONAL,
|
||||||
|
EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE),
|
||||||
attrs(AttrKind.OK, COLSPAN, ROWSPAN, HEADERS, SCOPE, ABBR, AXIS,
|
attrs(AttrKind.OK, COLSPAN, ROWSPAN, HEADERS, SCOPE, ABBR, AXIS,
|
||||||
ALIGN, CHAR, CHAROFF, VALIGN),
|
ALIGN, CHAR, CHAROFF, VALIGN),
|
||||||
attrs(AttrKind.USE_CSS, WIDTH, BGCOLOR, HEIGHT, NOWRAP)),
|
attrs(AttrKind.USE_CSS, WIDTH, BGCOLOR, HEIGHT, NOWRAP)),
|
||||||
|
|
||||||
THEAD(BlockType.BLOCK, EndKind.REQUIRED,
|
THEAD(BlockType.TABLE_ITEM, EndKind.REQUIRED,
|
||||||
attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN)),
|
attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN)) {
|
||||||
|
@Override
|
||||||
|
public boolean accepts(HtmlTag t) {
|
||||||
|
return (t == TR);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
TITLE(BlockType.OTHER, EndKind.REQUIRED),
|
TITLE(BlockType.OTHER, EndKind.REQUIRED),
|
||||||
|
|
||||||
TR(BlockType.BLOCK, EndKind.OPTIONAL,
|
TR(BlockType.TABLE_ITEM, EndKind.OPTIONAL,
|
||||||
EnumSet.of(Flag.NO_TEXT),
|
|
||||||
attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN),
|
attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN),
|
||||||
attrs(AttrKind.USE_CSS, BGCOLOR)),
|
attrs(AttrKind.USE_CSS, BGCOLOR)) {
|
||||||
|
@Override
|
||||||
|
public boolean accepts(HtmlTag t) {
|
||||||
|
return (t == TH) || (t == TD);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
TT(BlockType.INLINE, EndKind.REQUIRED,
|
TT(BlockType.INLINE, EndKind.REQUIRED,
|
||||||
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
|
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
|
||||||
|
@ -196,8 +264,13 @@ public enum HtmlTag {
|
||||||
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
|
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
|
||||||
|
|
||||||
UL(BlockType.BLOCK, EndKind.REQUIRED,
|
UL(BlockType.BLOCK, EndKind.REQUIRED,
|
||||||
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_TEXT),
|
EnumSet.of(Flag.EXPECT_CONTENT),
|
||||||
attrs(AttrKind.USE_CSS, COMPACT, TYPE)),
|
attrs(AttrKind.USE_CSS, COMPACT, TYPE)){
|
||||||
|
@Override
|
||||||
|
public boolean accepts(HtmlTag t) {
|
||||||
|
return (t == LI);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
VAR(BlockType.INLINE, EndKind.REQUIRED);
|
VAR(BlockType.INLINE, EndKind.REQUIRED);
|
||||||
|
|
||||||
|
@ -207,6 +280,8 @@ public enum HtmlTag {
|
||||||
public static enum BlockType {
|
public static enum BlockType {
|
||||||
BLOCK,
|
BLOCK,
|
||||||
INLINE,
|
INLINE,
|
||||||
|
LIST_ITEM,
|
||||||
|
TABLE_ITEM,
|
||||||
OTHER;
|
OTHER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,9 +295,10 @@ public enum HtmlTag {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum Flag {
|
public static enum Flag {
|
||||||
|
ACCEPTS_BLOCK,
|
||||||
|
ACCEPTS_INLINE,
|
||||||
EXPECT_CONTENT,
|
EXPECT_CONTENT,
|
||||||
NO_NEST,
|
NO_NEST
|
||||||
NO_TEXT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum Attr {
|
public static enum Attr {
|
||||||
|
@ -300,22 +376,14 @@ public enum HtmlTag {
|
||||||
public final Set<Flag> flags;
|
public final Set<Flag> flags;
|
||||||
private final Map<Attr,AttrKind> attrs;
|
private final Map<Attr,AttrKind> attrs;
|
||||||
|
|
||||||
|
|
||||||
HtmlTag() {
|
|
||||||
this(BlockType.BLOCK, EndKind.REQUIRED);
|
|
||||||
}
|
|
||||||
|
|
||||||
HtmlTag(Set<Flag> flags) {
|
|
||||||
this(BlockType.BLOCK, EndKind.REQUIRED, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
HtmlTag(BlockType blockType, EndKind endKind, AttrMap... attrMaps) {
|
HtmlTag(BlockType blockType, EndKind endKind, AttrMap... attrMaps) {
|
||||||
this(blockType, endKind, Collections.<Flag>emptySet(), attrMaps);
|
this(blockType, endKind, Collections.<Flag>emptySet(), attrMaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
HtmlTag(BlockType blockType, EndKind endKind, Set<Flag> flags, AttrMap... attrMaps) {
|
HtmlTag(BlockType blockType, EndKind endKind, Set<Flag> flags, AttrMap... attrMaps) {
|
||||||
this.blockType = blockType;
|
this.blockType = blockType;
|
||||||
this.endKind = endKind;this.flags = flags;
|
this.endKind = endKind;
|
||||||
|
this.flags = flags;
|
||||||
this.attrs = new EnumMap<Attr,AttrKind>(Attr.class);
|
this.attrs = new EnumMap<Attr,AttrKind>(Attr.class);
|
||||||
for (Map<Attr,AttrKind> m: attrMaps)
|
for (Map<Attr,AttrKind> m: attrMaps)
|
||||||
this.attrs.putAll(m);
|
this.attrs.putAll(m);
|
||||||
|
@ -324,6 +392,35 @@ public enum HtmlTag {
|
||||||
attrs.put(Attr.STYLE, 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() {
|
public String getText() {
|
||||||
return name().toLowerCase();
|
return name().toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ dc.tag.end.unexpected = unexpected end tag: </{0}>
|
||||||
dc.tag.header.sequence.1 = header used out of sequence: <{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.header.sequence.2 = header used out of sequence: <{0}>
|
||||||
dc.tag.nested.not.allowed=nested tag not allowed: <{0}>
|
dc.tag.nested.not.allowed=nested tag not allowed: <{0}>
|
||||||
|
dc.tag.not.allowed.here = tag not allowed here: <{0}>
|
||||||
dc.tag.not.allowed = element not allowed in documentation comments: <{0}>
|
dc.tag.not.allowed = element not allowed in documentation comments: <{0}>
|
||||||
dc.tag.not.allowed.inline.element = block element not allowed within inline element <{1}>: {0}
|
dc.tag.not.allowed.inline.element = block element not allowed within inline element <{1}>: {0}
|
||||||
dc.tag.not.allowed.inline.tag = block element not allowed within @{1}: {0}
|
dc.tag.not.allowed.inline.tag = block element not allowed within @{1}: {0}
|
||||||
|
|
|
@ -54,5 +54,17 @@ public class HtmlTagsTest {
|
||||||
* <i> </b> </i>
|
* <i> </b> </i>
|
||||||
*/
|
*/
|
||||||
public void end_unexpected() { }
|
public void end_unexpected() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <ul> text <li> ... </li> </ul>
|
||||||
|
*/
|
||||||
|
public void text_not_allowed() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <ul> <b>text</b> <li> ... </li> </ul>
|
||||||
|
*/
|
||||||
|
public void inline_not_allowed() { }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,5 +34,11 @@ HtmlTagsTest.java:54: error: unexpected end tag: </b>
|
||||||
HtmlTagsTest.java:54: warning: empty <i> tag
|
HtmlTagsTest.java:54: warning: empty <i> tag
|
||||||
* <i> </b> </i>
|
* <i> </b> </i>
|
||||||
^
|
^
|
||||||
11 errors
|
HtmlTagsTest.java:59: error: text not allowed in <ul> element
|
||||||
|
* <ul> text <li> ... </li> </ul>
|
||||||
|
^
|
||||||
|
HtmlTagsTest.java:64: error: tag not allowed here: <b>
|
||||||
|
* <ul> <b>text</b> <li> ... </li> </ul>
|
||||||
|
^
|
||||||
|
13 errors
|
||||||
1 warning
|
1 warning
|
||||||
|
|
57
langtools/test/tools/doclint/html/BlockTagsTest.java
Normal file
57
langtools/test/tools/doclint/html/BlockTagsTest.java
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 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.
|
||||||
|
*
|
||||||
|
* 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 8006251
|
||||||
|
* @summary test block tags
|
||||||
|
* @library ..
|
||||||
|
* @build DocLintTester
|
||||||
|
* @run main DocLintTester -Xmsgs BlockTagsTest.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** */
|
||||||
|
public class BlockTagsTest {
|
||||||
|
/**
|
||||||
|
* <blockquote> abc </blockquote>
|
||||||
|
* <center> abc </center>
|
||||||
|
* <div> abc </div>
|
||||||
|
* <dl> <dt> abc <dd> def </dl>
|
||||||
|
* <div> abc </div>
|
||||||
|
* <h1> abc </h1>
|
||||||
|
* <h2> abc </h2>
|
||||||
|
* <h3> abc </h3>
|
||||||
|
* <h4> abc </h4>
|
||||||
|
* <h5> abc </h5>
|
||||||
|
* <h6> abc </h6>
|
||||||
|
* <hr>
|
||||||
|
* <menu> <li> abc </menu>
|
||||||
|
* <noscript> </noscript>
|
||||||
|
* <ol> <li> abc </ol>
|
||||||
|
* <p> abc </p>
|
||||||
|
* <pre> abc </pre>
|
||||||
|
* <table summary="abc"> <tr> <td> </table>
|
||||||
|
* <ul> <li> abc </ul>
|
||||||
|
*/
|
||||||
|
public void supportedTags() { }
|
||||||
|
}
|
57
langtools/test/tools/doclint/html/InlineTagsTest.java
Normal file
57
langtools/test/tools/doclint/html/InlineTagsTest.java
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 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.
|
||||||
|
*
|
||||||
|
* 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 8006251
|
||||||
|
* @summary test inline tags
|
||||||
|
* @library ..
|
||||||
|
* @build DocLintTester
|
||||||
|
* @run main DocLintTester -Xmsgs InlineTagsTest.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** */
|
||||||
|
public class InlineTagsTest {
|
||||||
|
/**
|
||||||
|
* <a href="#abc"> abc </a>
|
||||||
|
* <b> abc </b>
|
||||||
|
* <big> abc </big>
|
||||||
|
* <br>
|
||||||
|
* <cite> abc </cite>
|
||||||
|
* <code> abc </code>
|
||||||
|
* <em> abc </em>
|
||||||
|
* <font> abc </font>
|
||||||
|
* <i> abc </i>
|
||||||
|
* <img alt="image" src="image.png">
|
||||||
|
* <small> abc </small>
|
||||||
|
* <span> abc </span>
|
||||||
|
* <strong> abc </strong>
|
||||||
|
* <sub> abc </sub>
|
||||||
|
* <sup> abc </sup>
|
||||||
|
* <tt> abc </tt>
|
||||||
|
* <u> abc </u>
|
||||||
|
* <var> abc </var>
|
||||||
|
*/
|
||||||
|
public void supportedTags() { }
|
||||||
|
}
|
||||||
|
|
41
langtools/test/tools/doclint/html/ListTagsTest.java
Normal file
41
langtools/test/tools/doclint/html/ListTagsTest.java
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 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.
|
||||||
|
*
|
||||||
|
* 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 8006251
|
||||||
|
* @summary test list tags
|
||||||
|
* @library ..
|
||||||
|
* @build DocLintTester
|
||||||
|
* @run main DocLintTester -Xmsgs ListTagsTest.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** */
|
||||||
|
public class ListTagsTest {
|
||||||
|
/**
|
||||||
|
* <dl> <dt> abc <dd> def </dl>
|
||||||
|
* <ol> <li> abc </ol>
|
||||||
|
* <ul> <li> abc </ul>
|
||||||
|
*/
|
||||||
|
public void supportedTags() { }
|
||||||
|
}
|
24
langtools/test/tools/doclint/html/OtherTagsTest.java
Normal file
24
langtools/test/tools/doclint/html/OtherTagsTest.java
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* @test /nodynamiccopyright/
|
||||||
|
* @bug 8006251
|
||||||
|
* @summary test other tags
|
||||||
|
* @library ..
|
||||||
|
* @build DocLintTester
|
||||||
|
* @run main DocLintTester -Xmsgs -ref OtherTagsTest.out OtherTagsTest.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** */
|
||||||
|
public class OtherTagsTest {
|
||||||
|
/**
|
||||||
|
* <body> <p> abc </body>
|
||||||
|
* <frame>
|
||||||
|
* <frameset> </frameset>
|
||||||
|
* <head> </head>
|
||||||
|
* <link>
|
||||||
|
* <meta>
|
||||||
|
* <noframes> </noframes>
|
||||||
|
* <script> </script>
|
||||||
|
* <title> </title>
|
||||||
|
*/
|
||||||
|
public void knownInvalidTags() { }
|
||||||
|
}
|
28
langtools/test/tools/doclint/html/OtherTagsTest.out
Normal file
28
langtools/test/tools/doclint/html/OtherTagsTest.out
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
OtherTagsTest.java:13: error: element not allowed in documentation comments: <body>
|
||||||
|
* <body> <p> abc </body>
|
||||||
|
^
|
||||||
|
OtherTagsTest.java:14: error: element not allowed in documentation comments: <frame>
|
||||||
|
* <frame>
|
||||||
|
^
|
||||||
|
OtherTagsTest.java:15: error: element not allowed in documentation comments: <frameset>
|
||||||
|
* <frameset> </frameset>
|
||||||
|
^
|
||||||
|
OtherTagsTest.java:16: error: element not allowed in documentation comments: <head>
|
||||||
|
* <head> </head>
|
||||||
|
^
|
||||||
|
OtherTagsTest.java:17: error: element not allowed in documentation comments: <link>
|
||||||
|
* <link>
|
||||||
|
^
|
||||||
|
OtherTagsTest.java:18: error: element not allowed in documentation comments: <meta>
|
||||||
|
* <meta>
|
||||||
|
^
|
||||||
|
OtherTagsTest.java:19: error: element not allowed in documentation comments: <noframes>
|
||||||
|
* <noframes> </noframes>
|
||||||
|
^
|
||||||
|
OtherTagsTest.java:20: error: element not allowed in documentation comments: <script>
|
||||||
|
* <script> </script>
|
||||||
|
^
|
||||||
|
OtherTagsTest.java:21: error: element not allowed in documentation comments: <title>
|
||||||
|
* <title> </title>
|
||||||
|
^
|
||||||
|
9 errors
|
44
langtools/test/tools/doclint/html/TableTagsTest.java
Normal file
44
langtools/test/tools/doclint/html/TableTagsTest.java
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 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.
|
||||||
|
*
|
||||||
|
* 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 8006251
|
||||||
|
* @summary test table tags
|
||||||
|
* @library ..
|
||||||
|
* @build DocLintTester
|
||||||
|
* @run main DocLintTester -Xmsgs TableTagsTest.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** */
|
||||||
|
public class TableTagsTest {
|
||||||
|
/**
|
||||||
|
* <table summary="abc"> <tr> <td> </table>
|
||||||
|
* <table summary="abc"> <tr> <th> </table>
|
||||||
|
* <table> <caption> abc </caption> <tr> <td> </table>
|
||||||
|
* <table summary="abc"> <thead> <tr> </thead> <tr> <td> </table>
|
||||||
|
* <table summary="abc"> <tbody> <tr> <td> </tbody> </table>
|
||||||
|
* <table summary="abc"> <tr> <td> <tfoot> <tr> </tfoot></table>
|
||||||
|
*/
|
||||||
|
public void supportedTags() { }
|
||||||
|
}
|
30
langtools/test/tools/doclint/html/TagNotAllowed.java
Normal file
30
langtools/test/tools/doclint/html/TagNotAllowed.java
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* @test /nodynamiccopyright/
|
||||||
|
* @bug 8004832
|
||||||
|
* @summary Add new doclint package
|
||||||
|
* @library ..
|
||||||
|
* @build DocLintTester
|
||||||
|
* @run main DocLintTester -ref TagNotAllowed.out TagNotAllowed.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <dl> <b>abc</b> <dt> term </dt> <b>def</b> <dd> description </dd> <b>ghi</b> </dl>
|
||||||
|
* <ol> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ol>
|
||||||
|
* <ul> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ul>
|
||||||
|
*
|
||||||
|
* <table summary=description> <b>abc</b> </table>
|
||||||
|
* <table summary=description> <thead> <b>abc</b> </thead> </table>
|
||||||
|
* <table summary=description> <tbody> <b>abc</b> </tbody> </table>
|
||||||
|
* <table summary=description> <tfoot> <b>abc</b> </tfoot> </table>
|
||||||
|
* <table summary=description> <tr> <b>abc</b> </tr> </table>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <img alt="image" src="image.png">
|
||||||
|
* <p> para </p>
|
||||||
|
* <big> text </big>
|
||||||
|
* <small> text </small>
|
||||||
|
* <sub> text </sub>
|
||||||
|
* <sup> text </sup>
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
public class TagNotAllowed { }
|
61
langtools/test/tools/doclint/html/TagNotAllowed.out
Normal file
61
langtools/test/tools/doclint/html/TagNotAllowed.out
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
TagNotAllowed.java:11: error: tag not allowed here: <b>
|
||||||
|
* <dl> <b>abc</b> <dt> term </dt> <b>def</b> <dd> description </dd> <b>ghi</b> </dl>
|
||||||
|
^
|
||||||
|
TagNotAllowed.java:11: error: tag not allowed here: <b>
|
||||||
|
* <dl> <b>abc</b> <dt> term </dt> <b>def</b> <dd> description </dd> <b>ghi</b> </dl>
|
||||||
|
^
|
||||||
|
TagNotAllowed.java:11: error: tag not allowed here: <b>
|
||||||
|
* <dl> <b>abc</b> <dt> term </dt> <b>def</b> <dd> description </dd> <b>ghi</b> </dl>
|
||||||
|
^
|
||||||
|
TagNotAllowed.java:12: error: tag not allowed here: <b>
|
||||||
|
* <ol> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ol>
|
||||||
|
^
|
||||||
|
TagNotAllowed.java:12: error: tag not allowed here: <b>
|
||||||
|
* <ol> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ol>
|
||||||
|
^
|
||||||
|
TagNotAllowed.java:12: error: tag not allowed here: <b>
|
||||||
|
* <ol> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ol>
|
||||||
|
^
|
||||||
|
TagNotAllowed.java:13: error: tag not allowed here: <b>
|
||||||
|
* <ul> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ul>
|
||||||
|
^
|
||||||
|
TagNotAllowed.java:13: error: tag not allowed here: <b>
|
||||||
|
* <ul> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ul>
|
||||||
|
^
|
||||||
|
TagNotAllowed.java:13: error: tag not allowed here: <b>
|
||||||
|
* <ul> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ul>
|
||||||
|
^
|
||||||
|
TagNotAllowed.java:15: error: tag not allowed here: <b>
|
||||||
|
* <table summary=description> <b>abc</b> </table>
|
||||||
|
^
|
||||||
|
TagNotAllowed.java:16: error: tag not allowed here: <b>
|
||||||
|
* <table summary=description> <thead> <b>abc</b> </thead> </table>
|
||||||
|
^
|
||||||
|
TagNotAllowed.java:17: error: tag not allowed here: <b>
|
||||||
|
* <table summary=description> <tbody> <b>abc</b> </tbody> </table>
|
||||||
|
^
|
||||||
|
TagNotAllowed.java:18: error: tag not allowed here: <b>
|
||||||
|
* <table summary=description> <tfoot> <b>abc</b> </tfoot> </table>
|
||||||
|
^
|
||||||
|
TagNotAllowed.java:19: error: tag not allowed here: <b>
|
||||||
|
* <table summary=description> <tr> <b>abc</b> </tr> </table>
|
||||||
|
^
|
||||||
|
TagNotAllowed.java:22: error: tag not allowed here: <img>
|
||||||
|
* <img alt="image" src="image.png">
|
||||||
|
^
|
||||||
|
TagNotAllowed.java:23: error: tag not allowed here: <p>
|
||||||
|
* <p> para </p>
|
||||||
|
^
|
||||||
|
TagNotAllowed.java:24: error: tag not allowed here: <big>
|
||||||
|
* <big> text </big>
|
||||||
|
^
|
||||||
|
TagNotAllowed.java:25: error: tag not allowed here: <small>
|
||||||
|
* <small> text </small>
|
||||||
|
^
|
||||||
|
TagNotAllowed.java:26: error: tag not allowed here: <sub>
|
||||||
|
* <sub> text </sub>
|
||||||
|
^
|
||||||
|
TagNotAllowed.java:27: error: tag not allowed here: <sup>
|
||||||
|
* <sup> text </sup>
|
||||||
|
^
|
||||||
|
20 errors
|
32
langtools/test/tools/doclint/html/TextNotAllowed.java
Normal file
32
langtools/test/tools/doclint/html/TextNotAllowed.java
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* @test /nodynamiccopyright/
|
||||||
|
* @bug 8004832
|
||||||
|
* @summary Add new doclint package
|
||||||
|
* @library ..
|
||||||
|
* @build DocLintTester
|
||||||
|
* @run main DocLintTester -ref TextNotAllowed.out TextNotAllowed.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <dl> abc <dt> term </dt> def <dd> description </dd> ghi </dl>
|
||||||
|
* <ol> abc <li> item </li> def <li> item </li> ghi </ol>
|
||||||
|
* <ul> abc <li> item </li> def <li> item </li> ghi </ul>
|
||||||
|
*
|
||||||
|
* <table summary=description> abc </table>
|
||||||
|
* <table summary=description> <thead> abc </thead> </table>
|
||||||
|
* <table summary=description> <tbody> abc </tbody> </table>
|
||||||
|
* <table summary=description> <tfoot> abc </tfoot> </table>
|
||||||
|
* <table summary=description> <tr> abc </tr> </table>
|
||||||
|
*
|
||||||
|
* <dl> & <dt> term </dt> < <dd> description </dd> > </dl>
|
||||||
|
* <ol> & <li> item </li> < <li> item </li> > </ol>
|
||||||
|
* <ul> & <li> item </li> < <li> item </li> > </ul>
|
||||||
|
*
|
||||||
|
* <table summary=description> & </table>
|
||||||
|
* <table summary=description> <thead> & </thead> </table>
|
||||||
|
* <table summary=description> <tbody> & </tbody> </table>
|
||||||
|
* <table summary=description> <tfoot> & </tfoot> </table>
|
||||||
|
* <table summary=description> <tr> & </tr> </table>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class TextNotAllowed { }
|
85
langtools/test/tools/doclint/html/TextNotAllowed.out
Normal file
85
langtools/test/tools/doclint/html/TextNotAllowed.out
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
TextNotAllowed.java:11: error: text not allowed in <dl> element
|
||||||
|
* <dl> abc <dt> term </dt> def <dd> description </dd> ghi </dl>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:11: error: text not allowed in <dl> element
|
||||||
|
* <dl> abc <dt> term </dt> def <dd> description </dd> ghi </dl>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:11: error: text not allowed in <dl> element
|
||||||
|
* <dl> abc <dt> term </dt> def <dd> description </dd> ghi </dl>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:12: error: text not allowed in <ol> element
|
||||||
|
* <ol> abc <li> item </li> def <li> item </li> ghi </ol>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:12: error: text not allowed in <ol> element
|
||||||
|
* <ol> abc <li> item </li> def <li> item </li> ghi </ol>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:12: error: text not allowed in <ol> element
|
||||||
|
* <ol> abc <li> item </li> def <li> item </li> ghi </ol>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:13: error: text not allowed in <ul> element
|
||||||
|
* <ul> abc <li> item </li> def <li> item </li> ghi </ul>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:13: error: text not allowed in <ul> element
|
||||||
|
* <ul> abc <li> item </li> def <li> item </li> ghi </ul>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:13: error: text not allowed in <ul> element
|
||||||
|
* <ul> abc <li> item </li> def <li> item </li> ghi </ul>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:15: error: text not allowed in <table> element
|
||||||
|
* <table summary=description> abc </table>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:16: error: text not allowed in <thead> element
|
||||||
|
* <table summary=description> <thead> abc </thead> </table>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:17: error: text not allowed in <tbody> element
|
||||||
|
* <table summary=description> <tbody> abc </tbody> </table>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:18: error: text not allowed in <tfoot> element
|
||||||
|
* <table summary=description> <tfoot> abc </tfoot> </table>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:19: error: text not allowed in <tr> element
|
||||||
|
* <table summary=description> <tr> abc </tr> </table>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:21: error: text not allowed in <dl> element
|
||||||
|
* <dl> & <dt> term </dt> < <dd> description </dd> > </dl>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:21: error: text not allowed in <dl> element
|
||||||
|
* <dl> & <dt> term </dt> < <dd> description </dd> > </dl>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:21: error: text not allowed in <dl> element
|
||||||
|
* <dl> & <dt> term </dt> < <dd> description </dd> > </dl>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:22: error: text not allowed in <ol> element
|
||||||
|
* <ol> & <li> item </li> < <li> item </li> > </ol>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:22: error: text not allowed in <ol> element
|
||||||
|
* <ol> & <li> item </li> < <li> item </li> > </ol>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:22: error: text not allowed in <ol> element
|
||||||
|
* <ol> & <li> item </li> < <li> item </li> > </ol>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:23: error: text not allowed in <ul> element
|
||||||
|
* <ul> & <li> item </li> < <li> item </li> > </ul>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:23: error: text not allowed in <ul> element
|
||||||
|
* <ul> & <li> item </li> < <li> item </li> > </ul>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:23: error: text not allowed in <ul> element
|
||||||
|
* <ul> & <li> item </li> < <li> item </li> > </ul>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:25: error: text not allowed in <table> element
|
||||||
|
* <table summary=description> & </table>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:26: error: text not allowed in <thead> element
|
||||||
|
* <table summary=description> <thead> & </thead> </table>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:27: error: text not allowed in <tbody> element
|
||||||
|
* <table summary=description> <tbody> & </tbody> </table>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:28: error: text not allowed in <tfoot> element
|
||||||
|
* <table summary=description> <tfoot> & </tfoot> </table>
|
||||||
|
^
|
||||||
|
TextNotAllowed.java:29: error: text not allowed in <tr> element
|
||||||
|
* <table summary=description> <tr> & </tr> </table>
|
||||||
|
^
|
||||||
|
28 errors
|
|
@ -1,4 +1,4 @@
|
||||||
ParaInPre.java:16: warning: unexpected use of <p> inside <pre> element
|
ParaInPre.java:16: error: tag not allowed here: <p>
|
||||||
* <p>
|
* <p>
|
||||||
^
|
^
|
||||||
1 warning
|
1 error
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
TextNotAllowed.java:13: error: text not allowed in <table> element
|
TextNotAllowed.java:13: error: text not allowed in <table> element
|
||||||
* <table summary=description> abc </table>
|
* <table summary=description> abc </table>
|
||||||
^
|
^
|
||||||
TextNotAllowed.java:14: error: text not allowed in <tbody> element
|
TextNotAllowed.java:14: error: text not allowed in <tbody> element
|
||||||
* <table summary=description> <tbody> abc </tbody> </table>
|
* <table summary=description> <tbody> abc </tbody> </table>
|
||||||
^
|
^
|
||||||
TextNotAllowed.java:15: error: text not allowed in <tr> element
|
TextNotAllowed.java:15: error: text not allowed in <tr> element
|
||||||
* <table summary=description> <tr> abc </tr> </table>
|
* <table summary=description> <tr> abc </tr> </table>
|
||||||
^
|
^
|
||||||
TextNotAllowed.java:17: error: text not allowed in <dl> element
|
TextNotAllowed.java:17: error: text not allowed in <dl> element
|
||||||
* <dl> abc </dl>
|
* <dl> abc </dl>
|
||||||
^
|
^
|
||||||
TextNotAllowed.java:18: error: text not allowed in <ol> element
|
TextNotAllowed.java:18: error: text not allowed in <ol> element
|
||||||
* <ol> abc </ol>
|
* <ol> abc </ol>
|
||||||
^
|
^
|
||||||
TextNotAllowed.java:19: error: text not allowed in <ul> element
|
TextNotAllowed.java:19: error: text not allowed in <ul> element
|
||||||
* <ul> abc </ul>
|
* <ul> abc </ul>
|
||||||
^
|
^
|
||||||
6 errors
|
6 errors
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue