mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
WEB-67650 React JSX: false positive attribute className is not allowed here with the new type evaluation
Merge-request: IJ-MR-139501 Merged-by: Andrey Vorobev <Andrey.Vorobev@jetbrains.com> GitOrigin-RevId: cb4528978aa1dfb163066334cdf8ab723565fb7c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1af4f1f880
commit
2fa85150a2
@@ -17,6 +17,7 @@ package com.intellij.codeInspection.htmlInspections;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.RemoveAttributeIntentionFix;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.ProblemHighlightType;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Key;
|
||||
@@ -90,13 +91,14 @@ public class HtmlUnknownAttributeInspectionBase extends HtmlUnknownElementInspec
|
||||
((XmlAttributeDescriptorEx)attributeDescriptor).validateAttributeName(attribute, holder, isOnTheFly);
|
||||
}
|
||||
|
||||
addUnknownXmlAttributeQuickFixes(tag, name, quickfixes, holder, isFixRequired);
|
||||
var highlightType = addUnknownXmlAttributeQuickFixes(tag, name, quickfixes, holder, isFixRequired);
|
||||
|
||||
if (!quickfixes.isEmpty()) {
|
||||
registerProblemOnAttributeName(
|
||||
attribute,
|
||||
XmlAnalysisBundle.message("xml.inspections.attribute.is.not.allowed.here", name),
|
||||
holder,
|
||||
highlightType,
|
||||
quickfixes.toArray(LocalQuickFix.EMPTY_ARRAY)
|
||||
);
|
||||
}
|
||||
@@ -116,13 +118,19 @@ public class HtmlUnknownAttributeInspectionBase extends HtmlUnknownElementInspec
|
||||
}
|
||||
}
|
||||
|
||||
private static void addUnknownXmlAttributeQuickFixes(XmlTag tag,
|
||||
String name,
|
||||
ArrayList<? super LocalQuickFix> quickfixes,
|
||||
ProblemsHolder holder,
|
||||
boolean isFixRequired) {
|
||||
private static ProblemHighlightType addUnknownXmlAttributeQuickFixes(XmlTag tag,
|
||||
String name,
|
||||
ArrayList<? super LocalQuickFix> quickfixes,
|
||||
ProblemsHolder holder,
|
||||
boolean isFixRequired) {
|
||||
var highlightType = ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
|
||||
for (XmlUnknownAttributeQuickFixProvider fixProvider : XmlUnknownAttributeQuickFixProvider.EP_NAME.getExtensionList()) {
|
||||
quickfixes.addAll(fixProvider.getOrRegisterAttributeFixes(tag, name, holder, isFixRequired));
|
||||
var providerHighlightType = fixProvider.getProblemHighlightType(tag);
|
||||
if (providerHighlightType != ProblemHighlightType.GENERIC_ERROR_OR_WARNING) {
|
||||
highlightType = providerHighlightType;
|
||||
}
|
||||
}
|
||||
return highlightType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.codeInspection.htmlInspections;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.RemoveAttributeIntentionFix;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.ProblemHighlightType;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.codeInspection.XmlQuickFixFactory;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -96,7 +97,7 @@ public class HtmlUnknownBooleanAttributeInspectionBase extends HtmlUnknownElemen
|
||||
error = XmlAnalysisBundle.message("html.inspections.attribute.is.not.boolean", attribute.getName());
|
||||
}
|
||||
if (error != null) {
|
||||
registerProblemOnAttributeName(attribute, error, holder, quickFixes);
|
||||
registerProblemOnAttributeName(attribute, error, holder, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, quickFixes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ public abstract class HtmlUnknownElementInspection extends HtmlLocalInspectionTo
|
||||
protected static void registerProblemOnAttributeName(@NotNull XmlAttribute attribute,
|
||||
@InspectionMessage String message,
|
||||
@NotNull ProblemsHolder holder,
|
||||
@NotNull ProblemHighlightType highlightType,
|
||||
@NotNull LocalQuickFix @NotNull ... quickfixes) {
|
||||
final ASTNode node = attribute.getNode();
|
||||
assert node != null;
|
||||
@@ -62,7 +63,7 @@ public abstract class HtmlUnknownElementInspection extends HtmlLocalInspectionTo
|
||||
if (nameNode != null) {
|
||||
final PsiElement nameElement = nameNode.getPsi();
|
||||
if (nameElement.getTextLength() > 0) {
|
||||
holder.registerProblem(nameElement, message, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, quickfixes);
|
||||
holder.registerProblem(nameElement, message, highlightType, quickfixes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,14 @@
|
||||
package com.intellij.codeInspection.htmlInspections;
|
||||
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.ProblemHighlightType;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.xml.XmlAttribute;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -20,8 +24,12 @@ public interface XmlUnknownAttributeQuickFixProvider {
|
||||
*
|
||||
* @param tag tag with unknown attribute
|
||||
* @param name name of unknown attribute
|
||||
* @param isFixRequired true if no check required, see {@link HtmlUnknownAttributeInspectionBase#checkAttribute(com.intellij.psi.xml.XmlAttribute, ProblemsHolder, boolean)}
|
||||
* @param isFixRequired true if no check required, see {@link HtmlUnknownAttributeInspectionBase#checkAttribute(XmlAttribute, ProblemsHolder, boolean)}
|
||||
* @return collection of quick fixes for unknown attribute
|
||||
*/
|
||||
@NotNull Collection<@NotNull LocalQuickFix> getOrRegisterAttributeFixes(@NotNull XmlTag tag, @NotNull String name, ProblemsHolder holder, boolean isFixRequired);
|
||||
|
||||
default @Nullable ProblemHighlightType getProblemHighlightType(@NotNull PsiElement element) {
|
||||
return ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user