assert no null LocalQuickFixes are passed to CommonProblemDescriptorImpl inside the "quickFixes" array (IDEA-312632), fix usages

null arrays still can be passed, but arrays with null elements are rejected because:
- consistency: it was very complicated (for both clients and implementation code) to understand if this particular fix could be null or not, and
- performance: filtering out null elements from the array and reallocating them back were noticeably expensive.
Currently, this assertion works inside tests only, to avoid irrecoverable failures in third-party plugins

GitOrigin-RevId: b71bc59eb811a807a0e6aae9609c368806f54869
This commit is contained in:
Alexey Kudravtsev
2023-02-13 16:49:36 +01:00
committed by intellij-monorepo-bot
parent 8e15908b31
commit 91cd121707
66 changed files with 209 additions and 174 deletions

View File

@@ -52,7 +52,7 @@ public abstract class HtmlUnknownElementInspection extends HtmlLocalInspectionTo
protected static void registerProblemOnAttributeName(@NotNull XmlAttribute attribute,
@InspectionMessage String message,
@NotNull ProblemsHolder holder,
LocalQuickFix... quickfixes) {
@NotNull LocalQuickFix @NotNull ... quickfixes) {
final ASTNode node = attribute.getNode();
assert node != null;
final ASTNode nameNode = XmlChildRole.ATTRIBUTE_NAME_FINDER.findChild(node);

View File

@@ -75,6 +75,7 @@ public class RequiredAttributesInspectionBase extends HtmlLocalInspectionTool im
myAdditionalRequiredHtmlAttributes = appendName(getAdditionalEntries(), text);
}
@NotNull
public static LocalQuickFix getIntentionAction(String name) {
return new AddHtmlTagOrAttributeToCustomsIntention(SHORT_NAME_KEY, name, XmlAnalysisBundle.message(
"html.quickfix.add.optional.html.attribute", name));
@@ -142,7 +143,7 @@ public class RequiredAttributesInspectionBase extends HtmlLocalInspectionTool im
@NotNull @InspectionMessage String localizedMessage,
final LocalQuickFix basicIntention,
ProblemsHolder holder,
final LocalQuickFix addAttributeFix,
@NotNull LocalQuickFix addAttributeFix,
boolean isOnTheFly) {
boolean htmlTag = false;
@@ -171,7 +172,7 @@ public class RequiredAttributesInspectionBase extends HtmlLocalInspectionTool im
ProblemHighlightType error,
ProblemsHolder holder,
boolean isOnTheFly,
LocalQuickFix... fixes) {
@NotNull LocalQuickFix @NotNull ... fixes) {
registerProblem(message, error, holder, XmlTagUtil.getStartTagNameElement(tag), fixes);
if (isOnTheFly) {
registerProblem(message, error, holder, XmlTagUtil.getEndTagNameElement(tag), fixes);

View File

@@ -15,5 +15,5 @@ import java.util.Collection;
public interface XmlAttributeRenameProvider {
ExtensionPointName<XmlAttributeRenameProvider> EP_NAME = ExtensionPointName.create("com.intellij.xml.xmlAttributeRenameProvider");
@NotNull Collection<LocalQuickFix> getAttributeFixes(@NotNull XmlTag tag, @NotNull String name);
@NotNull Collection<@NotNull LocalQuickFix> getAttributeFixes(@NotNull XmlTag tag, @NotNull String name);
}

View File

@@ -2,6 +2,7 @@
package com.intellij.xml.util;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.codeInspection.XmlSuppressableInspectionTool;
import com.intellij.lang.ASTNode;
@@ -45,7 +46,7 @@ public class CheckTagEmptyBodyInspection extends XmlSuppressableInspectionTool {
holder.registerProblem(
tag,
XmlAnalysisBundle.message("xml.inspections.tag.empty.body"),
isCollapsibleTag(tag) ? new CollapseTagIntention() : null
LocalQuickFix.notNullElements(isCollapsibleTag(tag) ? new CollapseTagIntention() : null)
);
}
}