mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-inspections] Blank line should be replaced with <p>: false positive when multiple blank lines before block tag
IDEA-315871 GitOrigin-RevId: 40520ca3deae8894318cd7ef0fde19c9935a4f64
This commit is contained in:
committed by
intellij-monorepo-bot
parent
692e481786
commit
7a4cf98cdd
+11
-4
@@ -74,10 +74,7 @@ public class JavadocBlankLinesInspection extends LocalInspectionTool {
|
||||
}
|
||||
|
||||
private static boolean isBeforeParagraphOrBlockTag(PsiElement element) {
|
||||
PsiElement nextSibling = element.getNextSibling();
|
||||
if (!(nextSibling instanceof PsiDocToken)) return true;
|
||||
if (((PsiDocToken)nextSibling).getTokenType() != JavaDocTokenType.DOC_COMMENT_LEADING_ASTERISKS) return true;
|
||||
nextSibling = nextSibling.getNextSibling();
|
||||
PsiElement nextSibling = skipWhitespacesAndLeadingAsterisksForward(element);
|
||||
if (nextSibling == null) return true;
|
||||
String text = nextSibling.getText();
|
||||
return isNullOrBlockTag(nextSibling) ||
|
||||
@@ -85,6 +82,16 @@ public class JavadocBlankLinesInspection extends LocalInspectionTool {
|
||||
isNullOrBlockTag(nextSibling.getNextSibling());
|
||||
}
|
||||
|
||||
private static PsiElement skipWhitespacesAndLeadingAsterisksForward(PsiElement element) {
|
||||
for (PsiElement e = element.getNextSibling(); e != null; e = e.getNextSibling()) {
|
||||
if (!(e instanceof PsiWhiteSpace ||
|
||||
e instanceof PsiDocToken docToken && docToken.getTokenType() == JavaDocTokenType.DOC_COMMENT_LEADING_ASTERISKS)) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean startsWithHtmlBlockTag(String text) {
|
||||
String startTag = HtmlUtil.getStartTag(text);
|
||||
if (startTag == null) return false;
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Insert <p>" "false"
|
||||
class Test {
|
||||
/**
|
||||
* Answer to the ultimate question of life, the universe, and everything
|
||||
*<caret>
|
||||
*
|
||||
* @return The number 42
|
||||
*/
|
||||
int answer() {
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user