mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
disable add required attribute in batch mode
EA-73302 - NPE: InsertRequiredAttributeFix.lambda$null$
This commit is contained in:
@@ -89,13 +89,17 @@ public class InspectionMappingConsistencyInspection extends DevKitInspectionBase
|
||||
|
||||
private static void registerProblem(DomElement element, ProblemsHolder holder, String message, String... createAttrs) {
|
||||
final Pair<TextRange, PsiElement> range = DomUtil.getProblemRange(element.getXmlTag());
|
||||
holder.registerProblem(range.second, range.first, message, ContainerUtil.map(createAttrs,
|
||||
s -> new InsertRequiredAttributeFix(PsiTreeUtil.getParentOfType(range.second, XmlTag.class, false), s) {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return MessageFormat.format("Insert ''{0}'' attribute", s);
|
||||
}
|
||||
}, new LocalQuickFix[createAttrs.length]));
|
||||
holder.registerProblem(range.second, range.first, message,
|
||||
holder.isOnTheFly()
|
||||
? ContainerUtil.map(createAttrs,
|
||||
s -> new InsertRequiredAttributeFix(
|
||||
PsiTreeUtil.getParentOfType(range.second, XmlTag.class, false), s) {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return MessageFormat.format("Insert ''{0}'' attribute", s);
|
||||
}
|
||||
}, new LocalQuickFix[createAttrs.length])
|
||||
: LocalQuickFix.EMPTY_ARRAY);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-15
@@ -126,7 +126,7 @@ public class RequiredAttributesInspectionBase extends HtmlLocalInspectionTool im
|
||||
if (!hasAttribute(tag, attrName) &&
|
||||
!XmlExtension.getExtension(tag.getContainingFile()).isRequiredAttributeImplicitlyPresent(tag, attrName)) {
|
||||
|
||||
LocalQuickFix insertRequiredAttributeIntention = XmlQuickFixFactory.getInstance().insertRequiredAttributeFix(tag, attrName);
|
||||
LocalQuickFix insertRequiredAttributeIntention = isOnTheFly ? XmlQuickFixFactory.getInstance().insertRequiredAttributeFix(tag, attrName) : null;
|
||||
final String localizedMessage = XmlErrorMessages.message("element.doesnt.have.required.attribute", name, attrName);
|
||||
reportOneTagProblem(
|
||||
tag,
|
||||
@@ -163,24 +163,17 @@ public class RequiredAttributesInspectionBase extends HtmlLocalInspectionTool im
|
||||
if(isAdditionallyDeclared(getAdditionalEntries(), name)) return;
|
||||
}
|
||||
|
||||
LocalQuickFix[] fixes;
|
||||
ProblemHighlightType highlightType;
|
||||
if (htmlTag) {
|
||||
addElementsForTag(
|
||||
tag,
|
||||
localizedMessage,
|
||||
isInjectedWithoutValidation(tag) ? ProblemHighlightType.INFORMATION : ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
|
||||
holder,
|
||||
addAttributeFix,
|
||||
basicIntention);
|
||||
fixes = basicIntention == null ? new LocalQuickFix[] {addAttributeFix} : new LocalQuickFix[]{addAttributeFix, basicIntention};
|
||||
highlightType = isInjectedWithoutValidation(tag) ? ProblemHighlightType.INFORMATION : ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
|
||||
}
|
||||
else {
|
||||
addElementsForTag(
|
||||
tag,
|
||||
localizedMessage,
|
||||
ProblemHighlightType.ERROR,
|
||||
holder,
|
||||
basicIntention
|
||||
);
|
||||
fixes = basicIntention == null ? LocalQuickFix.EMPTY_ARRAY : new LocalQuickFix[] {basicIntention};
|
||||
highlightType = ProblemHighlightType.ERROR;
|
||||
}
|
||||
addElementsForTag(tag, localizedMessage, highlightType, holder, fixes);
|
||||
}
|
||||
|
||||
private static void addElementsForTag(XmlTag tag,
|
||||
|
||||
@@ -221,9 +221,12 @@ public abstract class XmlTagRuleProviderBase extends XmlTagRuleProvider {
|
||||
PsiElement tagNameElement = getTagNameElement(tag);
|
||||
if (tagNameElement == null) return;
|
||||
|
||||
LocalQuickFix[] fixes = new LocalQuickFix[myAttributeNames.length];
|
||||
for (int i = 0; i < myAttributeNames.length; i++) {
|
||||
fixes[i] = XmlQuickFixFactory.getInstance().insertRequiredAttributeFix(tag, myAttributeNames[i]);
|
||||
LocalQuickFix[] fixes = LocalQuickFix.EMPTY_ARRAY;
|
||||
if (holder.isOnTheFly()) {
|
||||
fixes = new LocalQuickFix[myAttributeNames.length];
|
||||
for (int i = 0; i < myAttributeNames.length; i++) {
|
||||
fixes[i] = XmlQuickFixFactory.getInstance().insertRequiredAttributeFix(tag, myAttributeNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
holder.registerProblem(tagNameElement, "Tag should have one of following attributes: " + StringUtil.join(myAttributeNames, ", "),
|
||||
|
||||
Reference in New Issue
Block a user