8314213: DocLint should warn about unknown standard tags
Reviewed-by: jjg
This commit is contained in:
parent
4331193010
commit
6f1071f5ed
@ -358,7 +358,7 @@ public class TagletManager {
|
|||||||
if (!name.isEmpty() && name.charAt(0) == '@') {
|
if (!name.isEmpty() && name.charAt(0) == '@') {
|
||||||
name = name.substring(1);
|
name = name.substring(1);
|
||||||
}
|
}
|
||||||
if (! (standardTags.contains(name) || allTaglets.containsKey(name))) {
|
if (! (standardTags.contains(name) || allTaglets.containsKey(name))) { // defunct, see 8314213
|
||||||
if (standardTagsLowercase.contains(Utils.toLowerCase(name))) {
|
if (standardTagsLowercase.contains(Utils.toLowerCase(name))) {
|
||||||
messages.warning(ch.getDocTreePath(tag), "doclet.UnknownTagLowercase", ch.getTagName(tag));
|
messages.warning(ch.getDocTreePath(tag), "doclet.UnknownTagLowercase", ch.getTagName(tag));
|
||||||
continue;
|
continue;
|
||||||
|
@ -41,6 +41,8 @@ import java.util.Objects;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import javax.lang.model.SourceVersion;
|
import javax.lang.model.SourceVersion;
|
||||||
import javax.lang.model.element.Element;
|
import javax.lang.model.element.Element;
|
||||||
@ -1138,10 +1140,23 @@ public class Checker extends DocTreePathScanner<Void, Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkUnknownTag(DocTree tree, String tagName) {
|
private void checkUnknownTag(DocTree tree, String tagName) {
|
||||||
|
// if it were a standard tag, this method wouldn't be called:
|
||||||
|
// a standard tag is never represented by Unknown{Block,Inline}TagTree
|
||||||
|
assert tree instanceof UnknownBlockTagTree
|
||||||
|
|| tree instanceof UnknownInlineTagTree;
|
||||||
|
assert !getStandardTags().contains(tagName);
|
||||||
|
// report an unknown tag only if custom tags are set, see 8314213
|
||||||
if (env.customTags != null && !env.customTags.contains(tagName))
|
if (env.customTags != null && !env.customTags.contains(tagName))
|
||||||
env.messages.error(SYNTAX, tree, "dc.tag.unknown", tagName);
|
env.messages.error(SYNTAX, tree, "dc.tag.unknown", tagName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Set<String> getStandardTags() {
|
||||||
|
return Stream.of(DocTree.Kind.values())
|
||||||
|
.filter(k -> k.tagName != null) // not all DocTree represent tags
|
||||||
|
.map(k -> k.tagName)
|
||||||
|
.collect(Collectors.toUnmodifiableSet());
|
||||||
|
}
|
||||||
|
|
||||||
@Override @DefinedBy(Api.COMPILER_TREE)
|
@Override @DefinedBy(Api.COMPILER_TREE)
|
||||||
public Void visitUses(UsesTree tree, Void ignore) {
|
public Void visitUses(UsesTree tree, Void ignore) {
|
||||||
Element e = env.trees.getElement(env.currPath);
|
Element e = env.trees.getElement(env.currPath);
|
||||||
|
Loading…
Reference in New Issue
Block a user