mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 04:51:24 +07:00
[java] fixes Javadoc inspection false positive on @see tag (IDEA-168195)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,6 +37,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class JavadocHighlightUtil {
|
||||
@@ -192,7 +193,7 @@ public class JavadocHighlightUtil {
|
||||
if (dataElements.length == 0 || dataElements.length == 1 && empty(dataElements[0])) {
|
||||
holder.problem(tag.getNameElement(), InspectionsBundle.message("inspection.javadoc.problem.see.tag.expecting.ref"), null);
|
||||
}
|
||||
else if (!isValidSeeRef(dataElements[0])) {
|
||||
else if (!isValidSeeRef(dataElements)) {
|
||||
holder.problem(dataElements[0], InspectionsBundle.message("inspection.javadoc.problem.see.tag.expecting.ref"), null);
|
||||
}
|
||||
}
|
||||
@@ -201,13 +202,13 @@ public class JavadocHighlightUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isValidSeeRef(PsiElement e) {
|
||||
if (SEE_TAG_REFS.contains(e.getNode().getElementType())) return true;
|
||||
private static boolean isValidSeeRef(PsiElement... elements) {
|
||||
if (SEE_TAG_REFS.contains(elements[0].getNode().getElementType())) return true;
|
||||
|
||||
String text = e.getText().trim();
|
||||
String text = Stream.of(elements).map(e -> e.getText().trim()).collect(Collectors.joining(" ")).trim();
|
||||
if (StringUtil.isQuotedString(text) && text.charAt(0) == '"') return true;
|
||||
|
||||
if (text.toLowerCase(Locale.US).startsWith("<a href=")) return true;
|
||||
if (text.toLowerCase(Locale.US).matches("^<a\\s+href=.+")) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
class Test {
|
||||
/**
|
||||
* @see
|
||||
* <a href="http://docs.oracle.com/javase/8/docs/technotes/tools/unix/javadoc.html#CHDCDBGG">
|
||||
* <a
|
||||
* href="http://docs.oracle.com/javase/8/docs/technotes/tools/unix/javadoc.html#CHDCDBGG">
|
||||
* Oracle Docs</a>
|
||||
*/
|
||||
void m() { }
|
||||
|
||||
Reference in New Issue
Block a user