mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IG: correct fix for IDEA-203289; balanced curly braces are allowed
This commit is contained in:
+14
-2
@@ -25,6 +25,7 @@ import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.javadoc.PsiDocToken;
|
||||
import com.intellij.psi.javadoc.PsiInlineDocTag;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -148,18 +149,29 @@ public class HtmlTagCanBeJavadocTagInspection extends BaseInspection {
|
||||
}
|
||||
|
||||
private static boolean hasMatchingCloseTag(PsiElement element, int offset) {
|
||||
int balance = 0;
|
||||
while (element != null) {
|
||||
@NonNls final String text = element.getText();
|
||||
final int endIndex = StringUtil.indexOfIgnoreCase(text, "</code>", offset);
|
||||
final int end = endIndex >= 0 ? endIndex : text.length();
|
||||
if (containsHtmlTag(text, offset, end) || StringUtil.containsAnyChar(text, "{}", offset, end)) {
|
||||
if (text.equals("{")) {
|
||||
balance++;
|
||||
}
|
||||
else if (text.equals("}")) {
|
||||
balance--;
|
||||
if (balance < 0) return false;
|
||||
}
|
||||
if (containsHtmlTag(text, offset, end)) {
|
||||
return false;
|
||||
}
|
||||
if (endIndex >= 0) {
|
||||
return true;
|
||||
return balance == 0;
|
||||
}
|
||||
offset = 0;
|
||||
element = element.getNextSibling();
|
||||
if (element instanceof PsiInlineDocTag) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
+7
-1
@@ -3,7 +3,7 @@ package com.siyeh.igtest.javadoc.html_tag_can_be_javadoc_tag;
|
||||
class HtmlTagCanBeJavadocTag {
|
||||
|
||||
/**
|
||||
* <code>if (something) { this.doSomething(); }</code>
|
||||
* <warning descr="'<code>...</code>' can be replaced with '{@code ...}'"><code></warning>if (something) { this.doSomething(); }</code>
|
||||
* <warning descr="'<code>...</code>' can be replaced with '{@code ...}'"><code></warning>
|
||||
* asdf
|
||||
* </code>
|
||||
@@ -32,4 +32,10 @@ class HtmlTagCanBeJavadocTag {
|
||||
* <code>x2 = {@link #x x} * 2</code>
|
||||
*/
|
||||
public int x2 = x*2;
|
||||
|
||||
/**
|
||||
* <warning descr="'<code>...</code>' can be replaced with '{@code ...}'"><code></warning>{}</code>
|
||||
* <code>}{</code>
|
||||
*/
|
||||
private String indubitably = null;
|
||||
}
|
||||
Reference in New Issue
Block a user