8314213: DocLint should warn about unknown standard tags

Reviewed-by: jjg
This commit is contained in:
Pavel Rappo 2023-08-17 07:43:07 +00:00
parent 4331193010
commit 6f1071f5ed
2 changed files with 16 additions and 1 deletions

View File

@ -358,7 +358,7 @@ public class TagletManager {
if (!name.isEmpty() && name.charAt(0) == '@') {
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))) {
messages.warning(ch.getDocTreePath(tag), "doclet.UnknownTagLowercase", ch.getTagName(tag));
continue;

View File

@ -41,6 +41,8 @@ import java.util.Objects;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
@ -1138,10 +1140,23 @@ public class Checker extends DocTreePathScanner<Void, Void> {
}
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))
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)
public Void visitUses(UsesTree tree, Void ignore) {
Element e = env.trees.getElement(env.currPath);