mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
[xml] WEB-55214 Disable XML/HTML inspections about id for languages other than XML and plain HTML
Fixes also WEB-62929, WEB-69040, IDEA-26085, IDEA-53377, IDEA-91453, WEB-10365, IDEA-145560, IDEA-188945, WEB-38290, WEB-42484, WEB-43981, WEB-50211, WEB-52988, IDEA-286606 GitOrigin-RevId: 4e164feaab1a2d9aa31635348904dcb36ebacacc
This commit is contained in:
committed by
intellij-monorepo-bot
parent
83013a628c
commit
dbdb70c41f
@@ -1,5 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports a duplicate <code>id</code> attribute in XML.
|
||||
Reports a duplicate values of the <code>id</code> attribute in XML and HTML.
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports an unresolved <code>id</code> reference in XML.
|
||||
Reports the use of the <code>id</code> that is not defined anywhere in XML and HTML.
|
||||
</body>
|
||||
</html>
|
||||
@@ -5,6 +5,8 @@ import com.intellij.codeInspection.ProblemHighlightType;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.codeInspection.XmlSuppressableInspectionTool;
|
||||
import com.intellij.codeInspection.ex.UnfairLocalInspectionTool;
|
||||
import com.intellij.lang.html.HTMLLanguage;
|
||||
import com.intellij.lang.xml.XMLLanguage;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.psi.xml.XmlAttribute;
|
||||
@@ -21,6 +23,11 @@ public class XmlDuplicatedIdInspection extends XmlSuppressableInspectionTool imp
|
||||
|
||||
@Override
|
||||
public @NotNull PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder, final boolean isOnTheFly) {
|
||||
// Enable check only for plain XML and HTML files
|
||||
if (holder.getFile().getLanguage() != XMLLanguage.INSTANCE
|
||||
&& holder.getFile().getLanguage() != HTMLLanguage.INSTANCE) {
|
||||
return PsiElementVisitor.EMPTY_VISITOR;
|
||||
}
|
||||
return new XmlElementVisitor() {
|
||||
@Override
|
||||
public void visitXmlAttributeValue(final @NotNull XmlAttributeValue value) {
|
||||
@@ -28,9 +35,6 @@ public class XmlDuplicatedIdInspection extends XmlSuppressableInspectionTool imp
|
||||
return;
|
||||
}
|
||||
final PsiFile file = value.getContainingFile();
|
||||
if (!(file instanceof XmlFile)) {
|
||||
return;
|
||||
}
|
||||
PsiFile baseFile = PsiUtilCore.getTemplateLanguageFile(file);
|
||||
if (baseFile != file && !(baseFile instanceof XmlFile)) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user