提交 cf124cb4 编写于 作者: J jjg

8006236: doclint: structural issue hidden

Reviewed-by: darcy
上级 e119c6fd
......@@ -25,6 +25,7 @@
package com.sun.tools.doclint;
import com.sun.source.doctree.LiteralTree;
import java.util.regex.Matcher;
import com.sun.source.doctree.LinkTree;
import java.net.URI;
......@@ -359,9 +360,8 @@ public class Checker extends DocTreeScanner<Void, Void> {
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 if (tagStack.isEmpty()) {
env.messages.error(HTML, tree, "dc.tag.end.unexpected", treeName);
} else {
boolean done = false;
while (!tagStack.isEmpty()) {
TagStackItem top = tagStack.peek();
if (t == top.tag) {
......@@ -383,6 +383,7 @@ public class Checker extends DocTreeScanner<Void, Void> {
env.messages.error(HTML, tree, "dc.text.not.allowed", treeName);
}
tagStack.pop();
done = true;
break;
} else if (top.tag == null || top.tag.endKind != HtmlTag.EndKind.REQUIRED) {
tagStack.pop();
......@@ -400,10 +401,15 @@ public class Checker extends DocTreeScanner<Void, Void> {
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);
......@@ -545,6 +551,19 @@ public class Checker extends DocTreeScanner<Void, Void> {
}
}
@Override
public Void visitLiteral(LiteralTree tree, Void ignore) {
if (tree.getKind() == DocTree.Kind.CODE) {
for (TagStackItem tsi: tagStack) {
if (tsi.tag == HtmlTag.CODE) {
env.messages.warning(HTML, tree, "dc.tag.nested.not.allowed", "code");
break;
}
}
}
return super.visitLiteral(tree, ignore);
}
@Override
public Void visitParam(ParamTree tree, Void ignore) {
boolean typaram = tree.isTypeParameter();
......
/*
* @test /nodynamiccopyright/
* @bug 8006236
* @summary doclint: structural issue hidden
* @build DocLintTester
* @run main DocLintTester -Xmsgs:-html EndTagsTest.java
* @run main DocLintTester -ref EndTagsTest.out EndTagsTest.java
*/
/** */
public class EndTagsTest {
/** <p> <a name="a1"> text <img alt="image" src="image.png"> </a> </p> */
public void valid_all() { }
/** <p> <a name="a2"> text <img alt="image" src="image.png"> </a> */
public void valid_omit_optional_close() { }
/** </a> */
public void invalid_missing_start() { }
/** <p> </a> */
public void invalid_missing_start_2() { }
/** <p> text </p> </a> */
public void invalid_missing_start_3() { }
/** <img alt="image" src="image.png"> </img> */
public void invalid_end() { }
/** <invalid> </invalid> */
public void unknown_start_end() { }
/** <invalid> */
public void unknown_start() { }
/** </invalid> */
public void unknown_end() { }
}
EndTagsTest.java:18: error: unexpected end tag: </a>
/** </a> */
^
EndTagsTest.java:21: error: unexpected end tag: </a>
/** <p> </a> */
^
EndTagsTest.java:24: error: unexpected end tag: </a>
/** <p> text </p> </a> */
^
EndTagsTest.java:27: error: invalid end tag: </img>
/** <img alt="image" src="image.png"> </img> */
^
EndTagsTest.java:30: error: unknown tag: invalid
/** <invalid> </invalid> */
^
EndTagsTest.java:30: error: unknown tag: invalid
/** <invalid> </invalid> */
^
EndTagsTest.java:33: error: unknown tag: invalid
/** <invalid> */
^
EndTagsTest.java:36: error: unknown tag: invalid
/** </invalid> */
^
8 errors
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册